forked from linnoss/MediaApps2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ra.xsl
87 lines (81 loc) · 3.25 KB
/
ra.xsl
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" exclude-result-prefixes="xhtml itunes" version="1.0">
<xsl:output method="xml" indent="yes"/>
<!-- ROOT -->
<xsl:template match="/plugin">
<plugin>
<name>Royal Academy Of Arts</name>
<enabled>false</enabled>
<period>10080</period>
<description>Podcasts and lectures published by the Royal Acadamy of Arts</description>
<link>http://www.royalacademy.org.uk/</link>
<artwork>https://www.royalacademy.org.uk/assets/ra-logotype-3494ccc53fdc12b45b66728eddcb5fba.svg</artwork>
<container>/home</container>
</plugin>
</xsl:template>
<!-- HOME -->
<xsl:template match="/container[text() = '/home']">
<container name="Royal Academy Of Arts">
<xsl:for-each select="document('http://feeds.royalacademy.org.uk/royalacademyevents')/rss/channel/item">
<item>
<metadatum tag="type">audio</metadatum>
<metadatum tag="a.type">podcast</metadatum>
<metadatum tag="a.title">
<xsl:value-of select="title"/>
</metadatum>
<metadatum tag="a.description">
<xsl:value-of select="description"/>
</metadatum>
<metadatum tag="a.uri">
<xsl:value-of select="enclosure/@url" />
</metadatum>
<metadatum tag="a.channels">2</metadatum>
<metadatum tag="a.codec">mp3</metadatum>
<xsl:if test="itunes:duration">
<xsl:variable name="seconds">
<xsl:call-template name="seconds">
<xsl:with-param name="hhmmss" select="itunes:duration"/>
</xsl:call-template>
</xsl:variable>
<xsl:if test="$seconds != '0'">
<metadatum tag="a.duration">
<xsl:value-of select="$seconds" />
</metadatum>
</xsl:if>
</xsl:if>
</item>
</xsl:for-each>
</container>
</xsl:template>
<xsl:template name="seconds">
<xsl:param name="hhmmss" />
<xsl:choose>
<xsl:when test="substring($hhmmss, 2, 1) = ':'">
<xsl:variable name="hh">
<xsl:value-of select="substring($hhmmss, 1, 1)" />
</xsl:variable>
<xsl:variable name="mm">
<xsl:value-of select="substring($hhmmss, 3, 2)" />
</xsl:variable>
<xsl:variable name="ss">
<xsl:value-of select="substring($hhmmss, 6, 2)" />
</xsl:variable>
<xsl:value-of select="number($hh) * 3600 + number($mm) * 60 + number($ss)" />
</xsl:when>
<xsl:when test="substring($hhmmss, 3, 1) = ':'">
<xsl:variable name="hh">
<xsl:value-of select="substring($hhmmss, 1, 2)" />
</xsl:variable>
<xsl:variable name="mm">
<xsl:value-of select="substring($hhmmss, 4, 2)" />
</xsl:variable>
<xsl:variable name="ss">
<xsl:value-of select="substring($hhmmss, 7, 2)" />
</xsl:variable>
<xsl:value-of select="number($hh) * 3600 + number($mm) * 60 + number($ss)" />
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>