[crunchyroll] Extract uploader name that's not a link
[youtube-dl] / youtube_dl / extractor / crunchyroll.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 import re
5 import json
6 import base64
7 import zlib
8
9 from hashlib import sha1
10 from math import pow, sqrt, floor
11 from .common import InfoExtractor
12 from ..compat import (
13     compat_etree_fromstring,
14     compat_urllib_parse_urlencode,
15     compat_urllib_request,
16     compat_urlparse,
17 )
18 from ..utils import (
19     ExtractorError,
20     bytes_to_intlist,
21     intlist_to_bytes,
22     int_or_none,
23     lowercase_escape,
24     remove_end,
25     sanitized_Request,
26     unified_strdate,
27     urlencode_postdata,
28     xpath_text,
29     extract_attributes,
30 )
31 from ..aes import (
32     aes_cbc_decrypt,
33 )
34
35
36 class CrunchyrollBaseIE(InfoExtractor):
37     _LOGIN_URL = 'https://www.crunchyroll.com/login'
38     _LOGIN_FORM = 'login_form'
39     _NETRC_MACHINE = 'crunchyroll'
40
41     def _login(self):
42         (username, password) = self._get_login_info()
43         if username is None:
44             return
45
46         login_page = self._download_webpage(
47             self._LOGIN_URL, None, 'Downloading login page')
48
49         def is_logged(webpage):
50             return '<title>Redirecting' in webpage
51
52         # Already logged in
53         if is_logged(login_page):
54             return
55
56         login_form_str = self._search_regex(
57             r'(?P<form><form[^>]+?id=(["\'])%s\2[^>]*>)' % self._LOGIN_FORM,
58             login_page, 'login form', group='form')
59
60         post_url = extract_attributes(login_form_str).get('action')
61         if not post_url:
62             post_url = self._LOGIN_URL
63         elif not post_url.startswith('http'):
64             post_url = compat_urlparse.urljoin(self._LOGIN_URL, post_url)
65
66         login_form = self._form_hidden_inputs(self._LOGIN_FORM, login_page)
67
68         login_form.update({
69             'login_form[name]': username,
70             'login_form[password]': password,
71         })
72
73         response = self._download_webpage(
74             post_url, None, 'Logging in', 'Wrong login info',
75             data=urlencode_postdata(login_form),
76             headers={'Content-Type': 'application/x-www-form-urlencoded'})
77
78         # Successful login
79         if is_logged(response):
80             return
81
82         error = self._html_search_regex(
83             '(?s)<ul[^>]+class=["\']messages["\'][^>]*>(.+?)</ul>',
84             response, 'error message', default=None)
85         if error:
86             raise ExtractorError('Unable to login: %s' % error, expected=True)
87
88         raise ExtractorError('Unable to log in')
89
90     def _real_initialize(self):
91         self._login()
92
93     def _download_webpage(self, url_or_request, *args, **kwargs):
94         request = (url_or_request if isinstance(url_or_request, compat_urllib_request.Request)
95                    else sanitized_Request(url_or_request))
96         # Accept-Language must be set explicitly to accept any language to avoid issues
97         # similar to https://github.com/rg3/youtube-dl/issues/6797.
98         # Along with IP address Crunchyroll uses Accept-Language to guess whether georestriction
99         # should be imposed or not (from what I can see it just takes the first language
100         # ignoring the priority and requires it to correspond the IP). By the way this causes
101         # Crunchyroll to not work in georestriction cases in some browsers that don't place
102         # the locale lang first in header. However allowing any language seems to workaround the issue.
103         request.add_header('Accept-Language', '*')
104         return super(CrunchyrollBaseIE, self)._download_webpage(request, *args, **kwargs)
105
106     @staticmethod
107     def _add_skip_wall(url):
108         parsed_url = compat_urlparse.urlparse(url)
109         qs = compat_urlparse.parse_qs(parsed_url.query)
110         # Always force skip_wall to bypass maturity wall, namely 18+ confirmation message:
111         # > This content may be inappropriate for some people.
112         # > Are you sure you want to continue?
113         # since it's not disabled by default in crunchyroll account's settings.
114         # See https://github.com/rg3/youtube-dl/issues/7202.
115         qs['skip_wall'] = ['1']
116         return compat_urlparse.urlunparse(
117             parsed_url._replace(query=compat_urllib_parse_urlencode(qs, True)))
118
119
120 class CrunchyrollIE(CrunchyrollBaseIE):
121     _VALID_URL = r'https?://(?:(?P<prefix>www|m)\.)?(?P<url>crunchyroll\.(?:com|fr)/(?:media(?:-|/\?id=)|[^/]*/[^/?&]*?)(?P<video_id>[0-9]+))(?:[/?&]|$)'
122     _TESTS = [{
123         'url': 'http://www.crunchyroll.com/wanna-be-the-strongest-in-the-world/episode-1-an-idol-wrestler-is-born-645513',
124         'info_dict': {
125             'id': '645513',
126             'ext': 'mp4',
127             'title': 'Wanna be the Strongest in the World Episode 1 – An Idol-Wrestler is Born!',
128             'description': 'md5:2d17137920c64f2f49981a7797d275ef',
129             'thumbnail': 'http://img1.ak.crunchyroll.com/i/spire1-tmb/20c6b5e10f1a47b10516877d3c039cae1380951166_full.jpg',
130             'uploader': 'Yomiuri Telecasting Corporation (YTV)',
131             'upload_date': '20131013',
132             'url': 're:(?!.*&amp)',
133         },
134         'params': {
135             # rtmp
136             'skip_download': True,
137         },
138     }, {
139         'url': 'http://www.crunchyroll.com/media-589804/culture-japan-1',
140         'info_dict': {
141             'id': '589804',
142             'ext': 'flv',
143             'title': 'Culture Japan Episode 1 – Rebuilding Japan after the 3.11',
144             'description': 'md5:2fbc01f90b87e8e9137296f37b461c12',
145             'thumbnail': r're:^https?://.*\.jpg$',
146             'uploader': 'Danny Choo Network',
147             'upload_date': '20120213',
148         },
149         'params': {
150             # rtmp
151             'skip_download': True,
152         },
153         'skip': 'Video gone',
154     }, {
155         'url': 'http://www.crunchyroll.com/rezero-starting-life-in-another-world-/episode-5-the-morning-of-our-promise-is-still-distant-702409',
156         'info_dict': {
157             'id': '702409',
158             'ext': 'mp4',
159             'title': 'Re:ZERO -Starting Life in Another World- Episode 5 – The Morning of Our Promise Is Still Distant',
160             'description': 'md5:97664de1ab24bbf77a9c01918cb7dca9',
161             'thumbnail': r're:^https?://.*\.jpg$',
162             'uploader': 'TV TOKYO',
163             'upload_date': '20160508',
164         },
165         'params': {
166             # m3u8 download
167             'skip_download': True,
168         },
169     }, {
170         'url': 'http://www.crunchyroll.com/konosuba-gods-blessing-on-this-wonderful-world/episode-1-give-me-deliverance-from-this-judicial-injustice-727589',
171         'info_dict': {
172             'id': '727589',
173             'ext': 'mp4',
174             'title': "KONOSUBA -God's blessing on this wonderful world! 2 Episode 1 – Give Me Deliverance from this Judicial Injustice!",
175             'description': 'md5:cbcf05e528124b0f3a0a419fc805ea7d',
176             'thumbnail': r're:^https?://.*\.jpg$',
177             'uploader': 'Kadokawa Pictures Inc.',
178             'upload_date': '20170118',
179             'series': "KONOSUBA -God's blessing on this wonderful world!",
180             'season_number': 2,
181             'episode': 'Give Me Deliverance from this Judicial Injustice!',
182             'episode_number': 1,
183         },
184         'params': {
185             # m3u8 download
186             'skip_download': True,
187         },
188     }, {
189         'url': 'http://www.crunchyroll.fr/girl-friend-beta/episode-11-goodbye-la-mode-661697',
190         'only_matching': True,
191     }, {
192         # geo-restricted (US), 18+ maturity wall, non-premium available
193         'url': 'http://www.crunchyroll.com/cosplay-complex-ova/episode-1-the-birth-of-the-cosplay-club-565617',
194         'only_matching': True,
195     }, {
196         # A description with double quotes
197         'url': 'http://www.crunchyroll.com/11eyes/episode-1-piros-jszaka-red-night-535080',
198         'info_dict': {
199             'id': '535080',
200             'ext': 'mp4',
201             'title': '11eyes Episode 1 – Piros éjszaka - Red Night',
202             'description': 'Kakeru and Yuka are thrown into an alternate nightmarish world they call "Red Night".',
203             'uploader': 'Marvelous AQL Inc.',
204             'upload_date': '20091021',
205         },
206         'params': {
207             # Just test metadata extraction
208             'skip_download': True,
209         },
210     }, {
211         # make sure we can extract an uploader name that's not a link
212         'url': 'http://www.crunchyroll.com/hakuoki-reimeiroku/episode-1-dawn-of-the-divine-warriors-606899',
213         'info_dict': {
214             'id': '606899',
215             'ext': 'mp4',
216             'title': 'Hakuoki Reimeiroku Episode 1 – Dawn of the Divine Warriors',
217             'description': 'Ryunosuke was left to die, but Serizawa-san asked him a simple question "Do you want to live?"',
218             'uploader': 'Geneon Entertainment',
219             'upload_date': '20120717',
220         },
221         'params': {
222             # just test metadata extraction
223             'skip_download': True,
224         },
225     }]
226
227     _FORMAT_IDS = {
228         '360': ('60', '106'),
229         '480': ('61', '106'),
230         '720': ('62', '106'),
231         '1080': ('80', '108'),
232     }
233
234     def _decrypt_subtitles(self, data, iv, id):
235         data = bytes_to_intlist(base64.b64decode(data.encode('utf-8')))
236         iv = bytes_to_intlist(base64.b64decode(iv.encode('utf-8')))
237         id = int(id)
238
239         def obfuscate_key_aux(count, modulo, start):
240             output = list(start)
241             for _ in range(count):
242                 output.append(output[-1] + output[-2])
243             # cut off start values
244             output = output[2:]
245             output = list(map(lambda x: x % modulo + 33, output))
246             return output
247
248         def obfuscate_key(key):
249             num1 = int(floor(pow(2, 25) * sqrt(6.9)))
250             num2 = (num1 ^ key) << 5
251             num3 = key ^ num1
252             num4 = num3 ^ (num3 >> 3) ^ num2
253             prefix = intlist_to_bytes(obfuscate_key_aux(20, 97, (1, 2)))
254             shaHash = bytes_to_intlist(sha1(prefix + str(num4).encode('ascii')).digest())
255             # Extend 160 Bit hash to 256 Bit
256             return shaHash + [0] * 12
257
258         key = obfuscate_key(id)
259
260         decrypted_data = intlist_to_bytes(aes_cbc_decrypt(data, key, iv))
261         return zlib.decompress(decrypted_data)
262
263     def _convert_subtitles_to_srt(self, sub_root):
264         output = ''
265
266         for i, event in enumerate(sub_root.findall('./events/event'), 1):
267             start = event.attrib['start'].replace('.', ',')
268             end = event.attrib['end'].replace('.', ',')
269             text = event.attrib['text'].replace('\\N', '\n')
270             output += '%d\n%s --> %s\n%s\n\n' % (i, start, end, text)
271         return output
272
273     def _convert_subtitles_to_ass(self, sub_root):
274         output = ''
275
276         def ass_bool(strvalue):
277             assvalue = '0'
278             if strvalue == '1':
279                 assvalue = '-1'
280             return assvalue
281
282         output = '[Script Info]\n'
283         output += 'Title: %s\n' % sub_root.attrib['title']
284         output += 'ScriptType: v4.00+\n'
285         output += 'WrapStyle: %s\n' % sub_root.attrib['wrap_style']
286         output += 'PlayResX: %s\n' % sub_root.attrib['play_res_x']
287         output += 'PlayResY: %s\n' % sub_root.attrib['play_res_y']
288         output += """
289 [V4+ Styles]
290 Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
291 """
292         for style in sub_root.findall('./styles/style'):
293             output += 'Style: ' + style.attrib['name']
294             output += ',' + style.attrib['font_name']
295             output += ',' + style.attrib['font_size']
296             output += ',' + style.attrib['primary_colour']
297             output += ',' + style.attrib['secondary_colour']
298             output += ',' + style.attrib['outline_colour']
299             output += ',' + style.attrib['back_colour']
300             output += ',' + ass_bool(style.attrib['bold'])
301             output += ',' + ass_bool(style.attrib['italic'])
302             output += ',' + ass_bool(style.attrib['underline'])
303             output += ',' + ass_bool(style.attrib['strikeout'])
304             output += ',' + style.attrib['scale_x']
305             output += ',' + style.attrib['scale_y']
306             output += ',' + style.attrib['spacing']
307             output += ',' + style.attrib['angle']
308             output += ',' + style.attrib['border_style']
309             output += ',' + style.attrib['outline']
310             output += ',' + style.attrib['shadow']
311             output += ',' + style.attrib['alignment']
312             output += ',' + style.attrib['margin_l']
313             output += ',' + style.attrib['margin_r']
314             output += ',' + style.attrib['margin_v']
315             output += ',' + style.attrib['encoding']
316             output += '\n'
317
318         output += """
319 [Events]
320 Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
321 """
322         for event in sub_root.findall('./events/event'):
323             output += 'Dialogue: 0'
324             output += ',' + event.attrib['start']
325             output += ',' + event.attrib['end']
326             output += ',' + event.attrib['style']
327             output += ',' + event.attrib['name']
328             output += ',' + event.attrib['margin_l']
329             output += ',' + event.attrib['margin_r']
330             output += ',' + event.attrib['margin_v']
331             output += ',' + event.attrib['effect']
332             output += ',' + event.attrib['text']
333             output += '\n'
334
335         return output
336
337     def _extract_subtitles(self, subtitle):
338         sub_root = compat_etree_fromstring(subtitle)
339         return [{
340             'ext': 'srt',
341             'data': self._convert_subtitles_to_srt(sub_root),
342         }, {
343             'ext': 'ass',
344             'data': self._convert_subtitles_to_ass(sub_root),
345         }]
346
347     def _get_subtitles(self, video_id, webpage):
348         subtitles = {}
349         for sub_id, sub_name in re.findall(r'\bssid=([0-9]+)"[^>]+?\btitle="([^"]+)', webpage):
350             sub_page = self._download_webpage(
351                 'http://www.crunchyroll.com/xml/?req=RpcApiSubtitle_GetXml&subtitle_script_id=' + sub_id,
352                 video_id, note='Downloading subtitles for ' + sub_name)
353             id = self._search_regex(r'id=\'([0-9]+)', sub_page, 'subtitle_id', fatal=False)
354             iv = self._search_regex(r'<iv>([^<]+)', sub_page, 'subtitle_iv', fatal=False)
355             data = self._search_regex(r'<data>([^<]+)', sub_page, 'subtitle_data', fatal=False)
356             if not id or not iv or not data:
357                 continue
358             subtitle = self._decrypt_subtitles(data, iv, id).decode('utf-8')
359             lang_code = self._search_regex(r'lang_code=["\']([^"\']+)', subtitle, 'subtitle_lang_code', fatal=False)
360             if not lang_code:
361                 continue
362             subtitles[lang_code] = self._extract_subtitles(subtitle)
363         return subtitles
364
365     def _real_extract(self, url):
366         mobj = re.match(self._VALID_URL, url)
367         video_id = mobj.group('video_id')
368
369         if mobj.group('prefix') == 'm':
370             mobile_webpage = self._download_webpage(url, video_id, 'Downloading mobile webpage')
371             webpage_url = self._search_regex(r'<link rel="canonical" href="([^"]+)" />', mobile_webpage, 'webpage_url')
372         else:
373             webpage_url = 'http://www.' + mobj.group('url')
374
375         webpage = self._download_webpage(self._add_skip_wall(webpage_url), video_id, 'Downloading webpage')
376         note_m = self._html_search_regex(
377             r'<div class="showmedia-trailer-notice">(.+?)</div>',
378             webpage, 'trailer-notice', default='')
379         if note_m:
380             raise ExtractorError(note_m)
381
382         mobj = re.search(r'Page\.messaging_box_controller\.addItems\(\[(?P<msg>{.+?})\]\)', webpage)
383         if mobj:
384             msg = json.loads(mobj.group('msg'))
385             if msg.get('type') == 'error':
386                 raise ExtractorError('crunchyroll returned error: %s' % msg['message_body'], expected=True)
387
388         if 'To view this, please log in to verify you are 18 or older.' in webpage:
389             self.raise_login_required()
390
391         video_title = self._html_search_regex(
392             r'(?s)<h1[^>]*>((?:(?!<h1).)*?<span[^>]+itemprop=["\']title["\'][^>]*>(?:(?!<h1).)+?)</h1>',
393             webpage, 'video_title')
394         video_title = re.sub(r' {2,}', ' ', video_title)
395         video_description = self._parse_json(self._html_search_regex(
396             r'<script[^>]*>\s*.+?\[media_id=%s\].+?({.+?"description"\s*:.+?})\);' % video_id,
397             webpage, 'description', default='{}'), video_id).get('description')
398         if video_description:
399             video_description = lowercase_escape(video_description.replace(r'\r\n', '\n'))
400         video_upload_date = self._html_search_regex(
401             [r'<div>Availability for free users:(.+?)</div>', r'<div>[^<>]+<span>\s*(.+?\d{4})\s*</span></div>'],
402             webpage, 'video_upload_date', fatal=False, flags=re.DOTALL)
403         if video_upload_date:
404             video_upload_date = unified_strdate(video_upload_date)
405         video_uploader = self._html_search_regex(
406             # try looking for both an uploader that's a link and one that's not
407             [r'<a[^>]+href="/publisher/[^"]+"[^>]*>([^<]+)</a>', r'<div>\s*Publisher:\s*<span>\s*(.+?)\s*</span>\s*</div>'],
408             webpage, 'video_uploader', fatal=False)
409
410         available_fmts = []
411         for a, fmt in re.findall(r'(<a[^>]+token=["\']showmedia\.([0-9]{3,4})p["\'][^>]+>)', webpage):
412             attrs = extract_attributes(a)
413             href = attrs.get('href')
414             if href and '/freetrial' in href:
415                 continue
416             available_fmts.append(fmt)
417         if not available_fmts:
418             for p in (r'token=["\']showmedia\.([0-9]{3,4})p"', r'showmedia\.([0-9]{3,4})p'):
419                 available_fmts = re.findall(p, webpage)
420                 if available_fmts:
421                     break
422         video_encode_ids = []
423         formats = []
424         for fmt in available_fmts:
425             stream_quality, stream_format = self._FORMAT_IDS[fmt]
426             video_format = fmt + 'p'
427             streamdata_req = sanitized_Request(
428                 'http://www.crunchyroll.com/xml/?req=RpcApiVideoPlayer_GetStandardConfig&media_id=%s&video_format=%s&video_quality=%s'
429                 % (video_id, stream_format, stream_quality),
430                 compat_urllib_parse_urlencode({'current_page': url}).encode('utf-8'))
431             streamdata_req.add_header('Content-Type', 'application/x-www-form-urlencoded')
432             streamdata = self._download_xml(
433                 streamdata_req, video_id,
434                 note='Downloading media info for %s' % video_format)
435             stream_info = streamdata.find('./{default}preload/stream_info')
436             video_encode_id = xpath_text(stream_info, './video_encode_id')
437             if video_encode_id in video_encode_ids:
438                 continue
439             video_encode_ids.append(video_encode_id)
440
441             video_file = xpath_text(stream_info, './file')
442             if not video_file:
443                 continue
444             if video_file.startswith('http'):
445                 formats.extend(self._extract_m3u8_formats(
446                     video_file, video_id, 'mp4', entry_protocol='m3u8_native',
447                     m3u8_id='hls', fatal=False))
448                 continue
449
450             video_url = xpath_text(stream_info, './host')
451             if not video_url:
452                 continue
453             metadata = stream_info.find('./metadata')
454             format_info = {
455                 'format': video_format,
456                 'format_id': video_format,
457                 'height': int_or_none(xpath_text(metadata, './height')),
458                 'width': int_or_none(xpath_text(metadata, './width')),
459             }
460
461             if '.fplive.net/' in video_url:
462                 video_url = re.sub(r'^rtmpe?://', 'http://', video_url.strip())
463                 parsed_video_url = compat_urlparse.urlparse(video_url)
464                 direct_video_url = compat_urlparse.urlunparse(parsed_video_url._replace(
465                     netloc='v.lvlt.crcdn.net',
466                     path='%s/%s' % (remove_end(parsed_video_url.path, '/'), video_file.split(':')[-1])))
467                 if self._is_valid_url(direct_video_url, video_id, video_format):
468                     format_info.update({
469                         'url': direct_video_url,
470                     })
471                     formats.append(format_info)
472                     continue
473
474             format_info.update({
475                 'url': video_url,
476                 'play_path': video_file,
477                 'ext': 'flv',
478             })
479             formats.append(format_info)
480         self._sort_formats(formats)
481
482         metadata = self._download_xml(
483             'http://www.crunchyroll.com/xml', video_id,
484             note='Downloading media info', query={
485                 'req': 'RpcApiVideoPlayer_GetMediaMetadata',
486                 'media_id': video_id,
487             })
488
489         subtitles = self.extract_subtitles(video_id, webpage)
490
491         # webpage provide more accurate data than series_title from XML
492         series = self._html_search_regex(
493             r'id=["\']showmedia_about_episode_num[^>]+>\s*<a[^>]+>([^<]+)',
494             webpage, 'series', default=xpath_text(metadata, 'series_title'))
495
496         episode = xpath_text(metadata, 'episode_title')
497         episode_number = int_or_none(xpath_text(metadata, 'episode_number'))
498
499         season_number = int_or_none(self._search_regex(
500             r'(?s)<h4[^>]+id=["\']showmedia_about_episode_num[^>]+>.+?</h4>\s*<h4>\s*Season (\d+)',
501             webpage, 'season number', default=None))
502
503         return {
504             'id': video_id,
505             'title': video_title,
506             'description': video_description,
507             'thumbnail': xpath_text(metadata, 'episode_image_url'),
508             'uploader': video_uploader,
509             'upload_date': video_upload_date,
510             'series': series,
511             'season_number': season_number,
512             'episode': episode,
513             'episode_number': episode_number,
514             'subtitles': subtitles,
515             'formats': formats,
516         }
517
518
519 class CrunchyrollShowPlaylistIE(CrunchyrollBaseIE):
520     IE_NAME = 'crunchyroll:playlist'
521     _VALID_URL = r'https?://(?:(?P<prefix>www|m)\.)?(?P<url>crunchyroll\.com/(?!(?:news|anime-news|library|forum|launchcalendar|lineup|store|comics|freetrial|login))(?P<id>[\w\-]+))/?(?:\?|$)'
522
523     _TESTS = [{
524         'url': 'http://www.crunchyroll.com/a-bridge-to-the-starry-skies-hoshizora-e-kakaru-hashi',
525         'info_dict': {
526             'id': 'a-bridge-to-the-starry-skies-hoshizora-e-kakaru-hashi',
527             'title': 'A Bridge to the Starry Skies - Hoshizora e Kakaru Hashi'
528         },
529         'playlist_count': 13,
530     }, {
531         # geo-restricted (US), 18+ maturity wall, non-premium available
532         'url': 'http://www.crunchyroll.com/cosplay-complex-ova',
533         'info_dict': {
534             'id': 'cosplay-complex-ova',
535             'title': 'Cosplay Complex OVA'
536         },
537         'playlist_count': 3,
538         'skip': 'Georestricted',
539     }, {
540         # geo-restricted (US), 18+ maturity wall, non-premium will be available since 2015.11.14
541         'url': 'http://www.crunchyroll.com/ladies-versus-butlers?skip_wall=1',
542         'only_matching': True,
543     }]
544
545     def _real_extract(self, url):
546         show_id = self._match_id(url)
547
548         webpage = self._download_webpage(self._add_skip_wall(url), show_id)
549         title = self._html_search_regex(
550             r'(?s)<h1[^>]*>\s*<span itemprop="name">(.*?)</span>',
551             webpage, 'title')
552         episode_paths = re.findall(
553             r'(?s)<li id="showview_videos_media_(\d+)"[^>]+>.*?<a href="([^"]+)"',
554             webpage)
555         entries = [
556             self.url_result('http://www.crunchyroll.com' + ep, 'Crunchyroll', ep_id)
557             for ep_id, ep in episode_paths
558         ]
559         entries.reverse()
560
561         return {
562             '_type': 'playlist',
563             'id': show_id,
564             'title': title,
565             'entries': entries,
566         }