-
Notifications
You must be signed in to change notification settings - Fork 7
/
generate_playlist.xslt
54 lines (44 loc) · 1.73 KB
/
generate_playlist.xslt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="utf-8" />
<xsl:param name="break" select="'
'" />
<xsl:template match="/">
<xsl:value-of select="'#EXTM3U'" />
<xsl:value-of select="$break" />
<xsl:apply-templates select="setupResponse/services/service-list/service/dvb-ip" />
</xsl:template>
<xsl:template match="dvb-ip">
<xsl:value-of select="'#EXTINF:0,1 - '" />
<xsl:value-of select="parent::*/name" />
<xsl:value-of select="' - '" />
<xsl:value-of select="label" />
<xsl:value-of select="$break" />
<xsl:variable name="urlRtp">
<xsl:call-template name="string-replace-all">
<xsl:with-param name="text" select="url" />
<xsl:with-param name="replace" select="'igmp://'" />
<xsl:with-param name="by" select="'rtp://'" />
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="$urlRtp" />
<xsl:value-of select="$break" />
</xsl:template>
<xsl:template name="string-replace-all">
<xsl:param name="text" />
<xsl:param name="replace" />
<xsl:param name="by" />
<xsl:choose>
<xsl:when test="contains($text, $replace)">
<xsl:value-of select="substring-before($text,$replace)" />
<xsl:value-of select="$by" />
<xsl:call-template name="string-replace-all">
<xsl:with-param name="text" select="substring-after($text,$replace)" />
<xsl:with-param name="replace" select="$replace" />
<xsl:with-param name="by" select="$by" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$text" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>