/
serialzone.cz.xml
403 lines (383 loc) · 22.9 KB
/
serialzone.cz.xml
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
<?xml version="1.0" encoding="utf-8"?>
<scraper framework="1.1" date="2012-03-12">
<!-- version 2.3 -->
<!-- input : $$1=nfo file -->
<!-- output: <url>*</url> -->
<NfoUrl dest="8">
<RegExp input="$$1" output="<url cache="SZ.detail-\1.xml">http://api.serialzone.cz/xbmc/serial/\1/</url>" dest="8">
<expression>(?:https?://)(?:www\.)?serialzone.cz/serial/([^/]+)</expression>
</RegExp>
</NfoUrl>
<!-- input : $$1=query string -->
<!-- output: <url>*</url> -->
<CreateSearchUrl dest="8">
<RegExp input="$$1" output="<url cache="SZ.hledani-\1.xml">http://api.serialzone.cz/xbmc/?co=\1</url>" dest="8">
<expression/>
</RegExp>
</CreateSearchUrl>
<!-- input : $$1=search html -->
<!-- input : $$2=search url -->
<!-- output: <results><entity><title>*</title><url>*</url></entity>*</results> -->
<GetSearchResults dest="8">
<XSLT input="$$1" output="\1" dest="8">
<xsl:stylesheet version = "1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="data">
<results>
<xsl:apply-templates/>
</results>
</xsl:template>
<xsl:template match="tvshow">
<xsl:variable name="id" select="substring-before(substring-after(url, '/xbmc/serial/'), '/')"/>
<entity>
<title><xsl:value-of select="cz"/><xsl:if test="not(en=cz)"> (<xsl:value-of select="en"/>)</xsl:if></title>
<url><xsl:attribute name="cache">SZ.detail-<xsl:value-of select="$id"/>.xml</xsl:attribute>http://api.serialzone.cz/xbmc/serial/<xsl:value-of select="$id"/>/</url>
<year><xsl:choose><xsl:when test="contains(years, '-')"><xsl:value-of select="substring-before(years, '-')"/></xsl:when><xsl:otherwise><xsl:value-of select="years"/></xsl:otherwise></xsl:choose></year>
</entity>
</xsl:template>
</xsl:stylesheet>
</XSLT>
</GetSearchResults>
<!-- input : $$1=series html -->
<!-- input : $$2=id -->
<!-- input : $$3=series url -->
<!-- output: <details><title>*</title><plot>*</plot><id>*</id>...etc...<episodeguide>*</episodeguide></details> -->
<GetDetails dest="8">
<XSLT input="$$1" output="\1" dest="8">
<xsl:stylesheet version = "1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="data">
<xsl:variable name="id" select="substring-before(substring-after('$$3', '/xbmc/serial/'), '/')"/>
<xsl:variable name="entitle" select="normalize-space(en)"/>
<details>
<xsl:choose>
<xsl:when test="'$INFO[szsengname]' = 'true'">
<title><xsl:value-of select="$entitle"/></title>
</xsl:when>
<xsl:otherwise>
<title><xsl:value-of select="normalize-space(cz)"/><xsl:if test="'$INFO[szsorigname]' = 'true' and not(cz = en)"> (<xsl:value-of select="$entitle"/>)</xsl:if></title>
<originaltitle><xsl:value-of select="$entitle"/></originaltitle>
</xsl:otherwise>
</xsl:choose>
<premiered><xsl:value-of select="firstaired"/></premiered>
<year><xsl:value-of select="yearstart"/></year>
<rating><xsl:attribute name="max">100</xsl:attribute><xsl:value-of select="rating"/></rating>
<xsl:for-each select="creators/creator">
<credits><xsl:value-of select="name"/></credits>
</xsl:for-each>
<xsl:copy-of select="plot|runtime|votes|director|genres/*|countries/*|actors/*|episodeguide"/>
<xsl:choose>
<xsl:when test="imdb and not(imdb = 'tt0000000')">
<uniqueid><xsl:attribute name="type">imdb</xsl:attribute><xsl:value-of select="imdb"/></uniqueid>
<chain><xsl:attribute name="function">GetTVDBArt</xsl:attribute><xsl:value-of select="imdb"/></chain>
</xsl:when>
<xsl:otherwise>
<xsl:comment>Missing imdbid, so no data from TVDB</xsl:comment>
</xsl:otherwise>
</xsl:choose>
<url><xsl:attribute name="function">GetSZArt</xsl:attribute><xsl:attribute name="cache">SZ.detail-<xsl:value-of select="$id"/>.xml</xsl:attribute>$$3</url>
</details>
</xsl:template>
</xsl:stylesheet>
</XSLT>
</GetDetails>
<!-- input : $$1=episodeguide html -->
<!-- input : $$2=episodeguide url -->
<!-- output: <episodeguide><episode><title>*</title><url>*</url><season>*</season><epnum>*</epnum><thumb>*</thumb><id>*</id><aired>*</aired></episode>*</episodeguide> !-->
<GetEpisodeList dest="8">
<XSLT input="$$1" output="\1" dest="8">
<xsl:stylesheet version = "1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="data">
<episodeguide>
<xsl:apply-templates/>
</episodeguide>
</xsl:template>
<xsl:template match="episode">
<xsl:variable name="entitle" select="normalize-space(en)"/>
<episode>
<xsl:choose>
<xsl:when test="'$INFO[szeengname]' = 'true'">
<title><xsl:value-of select="$entitle"/></title>
</xsl:when>
<xsl:otherwise>
<title><xsl:value-of select="normalize-space(cz)"/><xsl:if test="'$INFO[szeorigname]' = 'true' and not(cz = en)"> (<xsl:value-of select="$entitle"/>)</xsl:if></title>
<originaltitle><xsl:value-of select="$entitle"/></originaltitle>
</xsl:otherwise>
</xsl:choose>
<xsl:copy-of select="url|season|epnum"/>
</episode>
</xsl:template>
</xsl:stylesheet>
</XSLT>
</GetEpisodeList>
<!-- input : $$1=episode html -->
<!-- input : $$2=id -->
<!-- input : $$3=episode url -->
<!-- output: <details><title>*</title><plot>*</plot><uniqueid>*</uniqueid><aired>*</aired><episode>*</episode><season>*</season></details> -->
<GetEpisodeDetails dest="8">
<XSLT input="$$1" output="\1" dest="8">
<xsl:stylesheet version = "1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="data">
<xsl:variable name="id" select="substring-before(substring-after('$$3', '/xbmc/serial/'), '/')"/>
<xsl:variable name="entitle" select="normalize-space(en)"/>
<details>
<xsl:choose>
<xsl:when test="'$INFO[szeengname]' = 'true'">
<title><xsl:value-of select="$entitle"/></title>
</xsl:when>
<xsl:otherwise>
<title><xsl:value-of select="normalize-space(cz)"/><xsl:if test="'$INFO[szeorigname]' = 'true' and not(cz = en)"> (<xsl:value-of select="$entitle"/>)</xsl:if></title>
<originaltitle><xsl:value-of select="$entitle"/></originaltitle>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="not(imdb = 'tt0000000')">
<uniqueid><xsl:attribute name="type">imdb</xsl:attribute><xsl:value-of select="imdb"/></uniqueid>
</xsl:if>
<aired><xsl:value-of select="firstaired"/></aired>
<xsl:if test="rating">
<rating><xsl:attribute name="max">100</xsl:attribute><xsl:value-of select="rating"/></rating>
</xsl:if>
<xsl:for-each select="creators/creator">
<credits><xsl:value-of select="name"/></credits>
</xsl:for-each>
<xsl:if test="directors/director/name">
<director><xsl:value-of select="directors/director/name"/></director>
</xsl:if>
<xsl:copy-of select="season|epnum|plot|runtime|votes|countries/*|actors/*"/>
</details>
</xsl:template>
</xsl:stylesheet>
</XSLT>
</GetEpisodeDetails>
<GetSZArt dest="8">
<XSLT input="$$1" output="\1" dest="8">
<xsl:stylesheet version = "1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="text()"/>
<xsl:template match="data">
<details>
<xsl:apply-templates/>
</details>
</xsl:template>
<xsl:template match="poster">
<xsl:if test="'$INFO[szposter]' = 'true'">
<thumb><xsl:attribute name="aspect">poster</xsl:attribute><xsl:value-of select="."/></thumb>
</xsl:if>
</xsl:template>
<xsl:template match="banners">
<xsl:apply-templates/>
<fanart>
<xsl:apply-templates/>
</fanart>
</xsl:template>
<xsl:template match="banner[@serie]">
<thumb><xsl:attribute name="aspect">banner</xsl:attribute>
<xsl:attribute name="type">season</xsl:attribute>
<xsl:attribute name="season"><xsl:value-of select="./@serie"/></xsl:attribute>
<xsl:value-of select="."/>
</thumb>
</xsl:template>
<xsl:template match="banner">
<thumb><xsl:attribute name="aspect">banner</xsl:attribute>
<xsl:value-of select="."/>
</thumb>
</xsl:template>
</xsl:stylesheet>
</XSLT>
</GetSZArt>
<!-- input : $$1=IMDBid -->
<!-- output: $$17=IMDBid -->
<!-- output: <details><url>...</url></detials> -->
<GetTVDBArt dest="3" clearbuffers="no">
<RegExp input="$$4" output="<details>\1</details>" dest="3">
<RegExp input="$$1" output="<url function="GetTVDBArtAuth" post="yes" cache="auth.json">https://api.thetvdb.com/login?{"apikey":"92B392A21386A7AB"}|Content-Type=application/json" dest="4">
<expression/>
</RegExp>
<RegExp input="" output="$$1" dest="17">
<expression/>
</RegExp>
<expression noclean="1"/>
</RegExp>
</GetTVDBArt>
<!-- input : $$1= language to switch -->
<!-- output: $$16= switched language -->
<!-- output: <details>comment with switch</detials> -->
<SwitchLanguage dest="3" clearbuffers="no">
<RegExp input="" output="<details><!-- switching language from $$16 to $$1 --></details>" dest="3">
<expression noclean="1"/>
</RegExp>
<RegExp input="$$1" output="\1" dest="16">
<expression/>
</RegExp>
</SwitchLanguage>
<!-- input : $$1=auth token json -->
<!-- input : $$17=IMDBid -->
<!-- output: $$19=auth_token with "Bearer " prefix -->
<!-- output: <details><url>...</url></detials> -->
<GetTVDBArtAuth dest="3" clearbuffers="no">
<RegExp input="$$1" output="Bearer \1" dest="19">
<expression>"token":\s*?"(.*)"</expression>
</RegExp>
<RegExp input="$$4" output="<details>\1</details>" dest="3">
<RegExp input="" output="<url function="GetTVDBId" cache="$$17-search-id.json">https://api.thetvdb.com/search/series?imdbId=$$17|Authorization=$$19</url>" dest="4">
<expression/>
</RegExp>
<expression noclean="1"/>
</RegExp>
</GetTVDBArtAuth>
<!-- input : $$1=search result json -->
<!-- input : $$17=IMDBid -->
<!-- input : $$19=auth_token with "Bearer " prefix -->
<!-- output: $$10="" -->
<!-- output: $$18=TVDBId -->
<!-- output: <details><url>...</url><chain>...</chain></detials> -->
<GetTVDBId dest="3" clearbuffers="no">
<RegExp input="$$1" output="\1" dest="18">
<expression clear="yes">"id":\s*?(\d+),</expression>
</RegExp>
<RegExp input="" output="" dest="10">
<expression/>
</RegExp>
<RegExp input="$$4" output="<details>\1</details>" dest="3">
<RegExp input="" output="<!-- Cannot find TVDBid from IMDBid $$17 -->" dest="4">
<expression/>
</RegExp>
<!-- not continue if missing tvdbid -->
<RegExp input="$$18" output="$$5" dest="4">
<RegExp input="" output="<id>$$18</id><uniqueid type="tvdb" default="true">$$18</uniqueid>" dest="5+">
<expression/>
</RegExp>
<RegExp input="" output="<url function="GetTVDBArtParams" cache="$$18-art-params.json">https://api.thetvdb.com/series/$$18/images/query/params|Authorization=$$19</url>" dest="5+">
<expression/>
</RegExp>
<RegExp input="" output="<chain function="ParseTVDBArt"></chain>" dest="5+">
<expression/>
</RegExp>
<expression clear="yes">(\d+)</expression>
</RegExp>
<expression noclean="1"/>
</RegExp>
</GetTVDBId>
<!-- input : $$1=image query params json -->
<!-- input : $$17=IMDBid -->
<!-- input : $$18=TVDBId -->
<!-- input : $$19=auth_token with "Bearer " prefix -->
<!-- output: $$16=actual language -->
<!-- output: <details><url>...$INFO[szregionallang]</url><url>...en</url></detials> -->
<GetTVDBArtParams dest="3" clearbuffers="no">
<RegExp input="$$4" output="<details>\1</details>" dest="3">
<RegExp conditional="szregional" input="" output="$INFO[szregionallang]" dest="16">
<expression/>
</RegExp>
<RegExp conditional="szregional" input="$$1" output="<url function="LoadTVDBArt" cache="$$18-art-\1-$$16.json">https://api.thetvdb.com/series/$$18/images/query?keyType=\1|Authorization=$$19&accept-language=$$16</url>" dest="4">
<expression clear="yes" repeat="yes">"keyType":\s*?"([^"]+)"</expression>
</RegExp>
<RegExp input="" output="<chain function="SwitchLanguage">en</chain>" dest="4+">
<expression noclean="1"/>
</RegExp>
<RegExp input="$$1" output="<url function="LoadTVDBArt" cache="$$18-art-\1-en.json">https://api.thetvdb.com/series/$$18/images/query?keyType=\1|Authorization=$$19&accept-language=en</url>" dest="4+">
<expression repeat="yes">"keyType":\s*?"([^"]+)"</expression>
</RegExp>
<expression noclean="1"/>
</RegExp>
</GetTVDBArtParams>
<!-- input : $$1=image query result json -->
<!-- input : $$16=actual language -->
<!-- input : $$17=IMDBid -->
<!-- input : $$18=TVDBId -->
<!-- input : $$19=auth_token with "Bearer " prefix -->
<!-- output: $$10=XML with images from result -->
<!-- output: <details>comment with type</detials> -->
<LoadTVDBArt dest="3" clearbuffers="no">
<RegExp input="$$1" output="<details><!-- $$16 \1 loaded --></details>" dest="3">
<RegExp input="$$1" output="<Banner><id>\1</id><keyType>\2</keyType><subKey>\3</subKey><fileName>\4</fileName><language>\5</language><resolution>\6</resolution><average>\7</average><thumbnail>\8</thumbnail></Banner>" dest="10+">
<expression repeat="yes">"id":\s*?(\d+),\s*?"keyType":\s*?"([^"]+)",\s*?"subKey":\s*?"([^"]*)",\s*?"fileName":\s*?"([^"]+)","languageId":\s*?\d+,\s*?"language":\s*?"([^"]*)",\s*?"resolution":\s*?"([^"]*)",\s*?"ratingsInfo":\s*?{\s*?"average":\s*?(?:([\d\.]+)|null),\s*?"count":\s*?\d+\s*?},\s*?"thumbnail":\s*?"([^"]*?)"</expression>
</RegExp>
<expression noclean="1">"keyType":\s*?"([^"]+)",</expression>
</RegExp>
</LoadTVDBArt>
<!-- input : $$1=chain call - empty -->
<!-- input : $$16=actual language -->
<!-- input : $$17=IMDBid -->
<!-- input : $$18=TVDBId -->
<!-- input : $$19=auth_token with "Bearer " prefix -->
<!-- input : $$10=XML with images from LoadTVDBArt result -->
<!-- output: <details><thumb>...</thumb></detials> -->
<ParseTVDBArt dest="4" clearbuffers="no">
<RegExp input="" output="" dest="4">
<expression/>
</RegExp>
<XSLT input="<Banners>$$10</Banners>" output="\1" dest="4">
<xsl:stylesheet version = "1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:key name="BannersById" match="Banner" use="id"/>
<xsl:template match="Banners">
<details>
<fanart url="http://www.thetvdb.com/banners/">
<xsl:apply-templates select="Banner[(keyType='fanart') and (generate-id()=generate-id(key('BannersById', id)[1]))]">
<xsl:sort data-type="number" order="descending" select="average"/>
</xsl:apply-templates>
</fanart>
<xsl:apply-templates select="Banner[(keyType!='fanart') and (generate-id()=generate-id(key('BannersById', id)[1]))]">
<xsl:sort data-type="number" order="ascending" select="(1 * number(keyType='poster'))
+ (2 * number(keyType='series'))
+ (3 * number(keyType='season'))
+ (4 * number(keyType='seasonwide'))"/>
<xsl:sort data-type="number" order="ascending" select="(1 * number(subKey='graphical'))
+ (2 * number(subKey='text'))
+ (3 * number(subKey='blank'))
+ (4 * number(subKey))"/>
<xsl:sort data-type="number" order="ascending" select="(1 * number(language='$INFO[szregionallang]'))
+ (2 * number(language='en'))"/>
<xsl:sort data-type="number" order="descending" select="average"/>
</xsl:apply-templates>
<xsl:apply-templates select="Banner[((keyType='poster') or (keyType='series')) and (generate-id()=generate-id(key('BannersById', id)[1]))]" mode="allseasons"/>
</details>
</xsl:template>
<xsl:template match="Banner[keyType='fanart']">
<thumb>
<xsl:attribute name="dim"><xsl:value-of select="resolution"/></xsl:attribute>
<xsl:attribute name="preview"><xsl:value-of select="thumbnail"/></xsl:attribute>
<xsl:value-of select="fileName"/>
</thumb>
</xsl:template>
<xsl:template match="Banner">
<thumb>
<xsl:attribute name="aspect">
<xsl:choose>
<xsl:when test="(keyType='poster') or (keyType='season')">poster</xsl:when>
<xsl:otherwise>banner</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:if test="(keyType='season') or (keyType='seasonwide')">
<xsl:attribute name="type">season</xsl:attribute>
<xsl:attribute name="season"><xsl:value-of select="subKey"/></xsl:attribute>
</xsl:if>
<xsl:attribute name="language"><xsl:value-of select="language"/></xsl:attribute>http://www.thetvdb.com/banners/<xsl:value-of select="fileName"/>
</thumb>
</xsl:template>
<xsl:template match="Banner" mode="allseasons">
<thumb>
<xsl:attribute name="aspect">
<xsl:choose>
<xsl:when test="(keyType='poster')">poster</xsl:when>
<xsl:otherwise>banner</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:attribute name="type">season</xsl:attribute>
<xsl:attribute name="season">-1</xsl:attribute>
<xsl:attribute name="language"><xsl:value-of select="language"/></xsl:attribute>http://www.thetvdb.com/banners/<xsl:value-of select="fileName"/></thumb>
</xsl:template>
</xsl:stylesheet>
</XSLT>
</ParseTVDBArt>
</scraper>