]>
Commit | Line | Data |
---|---|---|
c8434e83 | 1 | # encoding: utf-8 |
38a40276 | 2 | from __future__ import unicode_literals |
3 | ||
34440095 | 4 | import re |
1d430674 | 5 | import json |
34440095 S |
6 | import base64 |
7 | import zlib | |
8 | ||
c8434e83 | 9 | from hashlib import sha1 |
10 | from math import pow, sqrt, floor | |
b5857f62 | 11 | from .common import InfoExtractor |
1cc79574 | 12 | from ..compat import ( |
36e6f62c | 13 | compat_etree_fromstring, |
c8434e83 | 14 | compat_urllib_parse, |
a60cccbf | 15 | compat_urllib_parse_unquote, |
c8434e83 | 16 | compat_urllib_request, |
a01da8bb | 17 | compat_urlparse, |
1cc79574 PH |
18 | ) |
19 | from ..utils import ( | |
20 | ExtractorError, | |
c8434e83 | 21 | bytes_to_intlist, |
22 | intlist_to_bytes, | |
725d1c58 | 23 | int_or_none, |
6d02b9a3 | 24 | lowercase_escape, |
a01da8bb | 25 | remove_end, |
5c2266df | 26 | sanitized_Request, |
c8434e83 | 27 | unified_strdate, |
723e04d0 | 28 | urlencode_postdata, |
725d1c58 | 29 | xpath_text, |
c8434e83 | 30 | ) |
31 | from ..aes import ( | |
32 | aes_cbc_decrypt, | |
c8434e83 | 33 | ) |
34 | ||
34440095 | 35 | |
12810c9c | 36 | class CrunchyrollBaseIE(InfoExtractor): |
80f48920 S |
37 | _NETRC_MACHINE = 'crunchyroll' |
38 | ||
39 | def _login(self): | |
40 | (username, password) = self._get_login_info() | |
41 | if username is None: | |
42 | return | |
43 | self.report_login() | |
44 | login_url = 'https://www.crunchyroll.com/?a=formhandler' | |
45 | data = urlencode_postdata({ | |
46 | 'formname': 'RpcApiUser_Login', | |
47 | 'name': username, | |
48 | 'password': password, | |
49 | }) | |
5c2266df | 50 | login_request = sanitized_Request(login_url, data) |
80f48920 S |
51 | login_request.add_header('Content-Type', 'application/x-www-form-urlencoded') |
52 | self._download_webpage(login_request, None, False, 'Wrong login info') | |
53 | ||
54 | def _real_initialize(self): | |
55 | self._login() | |
56 | ||
12810c9c S |
57 | def _download_webpage(self, url_or_request, video_id, note=None, errnote=None, fatal=True, tries=1, timeout=5, encoding=None): |
58 | request = (url_or_request if isinstance(url_or_request, compat_urllib_request.Request) | |
5c2266df | 59 | else sanitized_Request(url_or_request)) |
12810c9c S |
60 | # Accept-Language must be set explicitly to accept any language to avoid issues |
61 | # similar to https://github.com/rg3/youtube-dl/issues/6797. | |
62 | # Along with IP address Crunchyroll uses Accept-Language to guess whether georestriction | |
63 | # should be imposed or not (from what I can see it just takes the first language | |
64 | # ignoring the priority and requires it to correspond the IP). By the way this causes | |
65 | # Crunchyroll to not work in georestriction cases in some browsers that don't place | |
66 | # the locale lang first in header. However allowing any language seems to workaround the issue. | |
67 | request.add_header('Accept-Language', '*') | |
68 | return super(CrunchyrollBaseIE, self)._download_webpage( | |
69 | request, video_id, note, errnote, fatal, tries, timeout, encoding) | |
70 | ||
80f48920 S |
71 | @staticmethod |
72 | def _add_skip_wall(url): | |
73 | parsed_url = compat_urlparse.urlparse(url) | |
74 | qs = compat_urlparse.parse_qs(parsed_url.query) | |
75 | # Always force skip_wall to bypass maturity wall, namely 18+ confirmation message: | |
76 | # > This content may be inappropriate for some people. | |
77 | # > Are you sure you want to continue? | |
78 | # since it's not disabled by default in crunchyroll account's settings. | |
79 | # See https://github.com/rg3/youtube-dl/issues/7202. | |
80 | qs['skip_wall'] = ['1'] | |
81 | return compat_urlparse.urlunparse( | |
82 | parsed_url._replace(query=compat_urllib_parse.urlencode(qs, True))) | |
83 | ||
12810c9c S |
84 | |
85 | class CrunchyrollIE(CrunchyrollBaseIE): | |
ede21449 | 86 | _VALID_URL = r'https?://(?:(?P<prefix>www|m)\.)?(?P<url>crunchyroll\.(?:com|fr)/(?:media(?:-|/\?id=)|[^/]*/[^/?&]*?)(?P<video_id>[0-9]+))(?:[/?&]|$)' |
a8896c5a | 87 | _TESTS = [{ |
38a40276 | 88 | 'url': 'http://www.crunchyroll.com/wanna-be-the-strongest-in-the-world/episode-1-an-idol-wrestler-is-born-645513', |
38a40276 | 89 | 'info_dict': { |
34440095 S |
90 | 'id': '645513', |
91 | 'ext': 'flv', | |
38a40276 | 92 | 'title': 'Wanna be the Strongest in the World Episode 1 – An Idol-Wrestler is Born!', |
93 | 'description': 'md5:2d17137920c64f2f49981a7797d275ef', | |
94 | 'thumbnail': 'http://img1.ak.crunchyroll.com/i/spire1-tmb/20c6b5e10f1a47b10516877d3c039cae1380951166_full.jpg', | |
95 | 'uploader': 'Yomiuri Telecasting Corporation (YTV)', | |
96 | 'upload_date': '20131013', | |
b1edd7a4 | 97 | 'url': 're:(?!.*&)', |
c8434e83 | 98 | }, |
38a40276 | 99 | 'params': { |
c8434e83 | 100 | # rtmp |
38a40276 | 101 | 'skip_download': True, |
c8434e83 | 102 | }, |
ede21449 S |
103 | }, { |
104 | 'url': 'http://www.crunchyroll.com/media-589804/culture-japan-1', | |
105 | 'info_dict': { | |
106 | 'id': '589804', | |
107 | 'ext': 'flv', | |
108 | 'title': 'Culture Japan Episode 1 – Rebuilding Japan after the 3.11', | |
6d02b9a3 | 109 | 'description': 'md5:2fbc01f90b87e8e9137296f37b461c12', |
ede21449 S |
110 | 'thumbnail': 're:^https?://.*\.jpg$', |
111 | 'uploader': 'Danny Choo Network', | |
112 | 'upload_date': '20120213', | |
113 | }, | |
114 | 'params': { | |
115 | # rtmp | |
116 | 'skip_download': True, | |
117 | }, | |
a8896c5a S |
118 | }, { |
119 | 'url': 'http://www.crunchyroll.fr/girl-friend-beta/episode-11-goodbye-la-mode-661697', | |
120 | 'only_matching': True, | |
49941c4e S |
121 | }, { |
122 | # geo-restricted (US), 18+ maturity wall, non-premium available | |
123 | 'url': 'http://www.crunchyroll.com/cosplay-complex-ova/episode-1-the-birth-of-the-cosplay-club-565617', | |
124 | 'only_matching': True, | |
a8896c5a | 125 | }] |
c8434e83 | 126 | |
127 | _FORMAT_IDS = { | |
38a40276 | 128 | '360': ('60', '106'), |
129 | '480': ('61', '106'), | |
130 | '720': ('62', '106'), | |
131 | '1080': ('80', '108'), | |
c8434e83 | 132 | } |
133 | ||
134 | def _decrypt_subtitles(self, data, iv, id): | |
1a5b77dc S |
135 | data = bytes_to_intlist(base64.b64decode(data.encode('utf-8'))) |
136 | iv = bytes_to_intlist(base64.b64decode(iv.encode('utf-8'))) | |
c8434e83 | 137 | id = int(id) |
138 | ||
139 | def obfuscate_key_aux(count, modulo, start): | |
140 | output = list(start) | |
141 | for _ in range(count): | |
142 | output.append(output[-1] + output[-2]) | |
143 | # cut off start values | |
144 | output = output[2:] | |
145 | output = list(map(lambda x: x % modulo + 33, output)) | |
146 | return output | |
147 | ||
148 | def obfuscate_key(key): | |
149 | num1 = int(floor(pow(2, 25) * sqrt(6.9))) | |
150 | num2 = (num1 ^ key) << 5 | |
151 | num3 = key ^ num1 | |
152 | num4 = num3 ^ (num3 >> 3) ^ num2 | |
153 | prefix = intlist_to_bytes(obfuscate_key_aux(20, 97, (1, 2))) | |
38a40276 | 154 | shaHash = bytes_to_intlist(sha1(prefix + str(num4).encode('ascii')).digest()) |
c8434e83 | 155 | # Extend 160 Bit hash to 256 Bit |
156 | return shaHash + [0] * 12 | |
34440095 | 157 | |
c8434e83 | 158 | key = obfuscate_key(id) |
5f6a1245 | 159 | |
c8434e83 | 160 | decrypted_data = intlist_to_bytes(aes_cbc_decrypt(data, key, iv)) |
161 | return zlib.decompress(decrypted_data) | |
162 | ||
d65d6286 | 163 | def _convert_subtitles_to_srt(self, sub_root): |
38a40276 | 164 | output = '' |
d65d6286 JMF |
165 | |
166 | for i, event in enumerate(sub_root.findall('./events/event'), 1): | |
167 | start = event.attrib['start'].replace('.', ',') | |
168 | end = event.attrib['end'].replace('.', ',') | |
169 | text = event.attrib['text'].replace('\\N', '\n') | |
38a40276 | 170 | output += '%d\n%s --> %s\n%s\n\n' % (i, start, end, text) |
c8434e83 | 171 | return output |
172 | ||
d65d6286 | 173 | def _convert_subtitles_to_ass(self, sub_root): |
78272a07 A |
174 | output = '' |
175 | ||
176 | def ass_bool(strvalue): | |
177 | assvalue = '0' | |
178 | if strvalue == '1': | |
179 | assvalue = '-1' | |
180 | return assvalue | |
181 | ||
78272a07 A |
182 | output = '[Script Info]\n' |
183 | output += 'Title: %s\n' % sub_root.attrib["title"] | |
184 | output += 'ScriptType: v4.00+\n' | |
185 | output += 'WrapStyle: %s\n' % sub_root.attrib["wrap_style"] | |
186 | output += 'PlayResX: %s\n' % sub_root.attrib["play_res_x"] | |
187 | output += 'PlayResY: %s\n' % sub_root.attrib["play_res_y"] | |
188 | output += """ScaledBorderAndShadow: yes | |
189 | ||
190 | [V4+ Styles] | |
191 | Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding | |
192 | """ | |
193 | for style in sub_root.findall('./styles/style'): | |
194 | output += 'Style: ' + style.attrib["name"] | |
195 | output += ',' + style.attrib["font_name"] | |
196 | output += ',' + style.attrib["font_size"] | |
197 | output += ',' + style.attrib["primary_colour"] | |
198 | output += ',' + style.attrib["secondary_colour"] | |
199 | output += ',' + style.attrib["outline_colour"] | |
200 | output += ',' + style.attrib["back_colour"] | |
201 | output += ',' + ass_bool(style.attrib["bold"]) | |
202 | output += ',' + ass_bool(style.attrib["italic"]) | |
203 | output += ',' + ass_bool(style.attrib["underline"]) | |
204 | output += ',' + ass_bool(style.attrib["strikeout"]) | |
205 | output += ',' + style.attrib["scale_x"] | |
206 | output += ',' + style.attrib["scale_y"] | |
207 | output += ',' + style.attrib["spacing"] | |
208 | output += ',' + style.attrib["angle"] | |
209 | output += ',' + style.attrib["border_style"] | |
210 | output += ',' + style.attrib["outline"] | |
211 | output += ',' + style.attrib["shadow"] | |
212 | output += ',' + style.attrib["alignment"] | |
213 | output += ',' + style.attrib["margin_l"] | |
214 | output += ',' + style.attrib["margin_r"] | |
215 | output += ',' + style.attrib["margin_v"] | |
216 | output += ',' + style.attrib["encoding"] | |
217 | output += '\n' | |
218 | ||
219 | output += """ | |
220 | [Events] | |
221 | Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text | |
222 | """ | |
223 | for event in sub_root.findall('./events/event'): | |
224 | output += 'Dialogue: 0' | |
225 | output += ',' + event.attrib["start"] | |
226 | output += ',' + event.attrib["end"] | |
227 | output += ',' + event.attrib["style"] | |
228 | output += ',' + event.attrib["name"] | |
229 | output += ',' + event.attrib["margin_l"] | |
230 | output += ',' + event.attrib["margin_r"] | |
231 | output += ',' + event.attrib["margin_v"] | |
232 | output += ',' + event.attrib["effect"] | |
233 | output += ',' + event.attrib["text"] | |
234 | output += '\n' | |
235 | ||
236 | return output | |
237 | ||
0385d642 | 238 | def _extract_subtitles(self, subtitle): |
36e6f62c | 239 | sub_root = compat_etree_fromstring(subtitle) |
0385d642 S |
240 | return [{ |
241 | 'ext': 'srt', | |
242 | 'data': self._convert_subtitles_to_srt(sub_root), | |
243 | }, { | |
244 | 'ext': 'ass', | |
245 | 'data': self._convert_subtitles_to_ass(sub_root), | |
246 | }] | |
247 | ||
b5857f62 JMF |
248 | def _get_subtitles(self, video_id, webpage): |
249 | subtitles = {} | |
76907875 | 250 | for sub_id, sub_name in re.findall(r'\bssid=([0-9]+)"[^>]+?\btitle="([^"]+)', webpage): |
b5857f62 JMF |
251 | sub_page = self._download_webpage( |
252 | 'http://www.crunchyroll.com/xml/?req=RpcApiSubtitle_GetXml&subtitle_script_id=' + sub_id, | |
253 | video_id, note='Downloading subtitles for ' + sub_name) | |
254 | id = self._search_regex(r'id=\'([0-9]+)', sub_page, 'subtitle_id', fatal=False) | |
255 | iv = self._search_regex(r'<iv>([^<]+)', sub_page, 'subtitle_iv', fatal=False) | |
256 | data = self._search_regex(r'<data>([^<]+)', sub_page, 'subtitle_data', fatal=False) | |
257 | if not id or not iv or not data: | |
258 | continue | |
b5857f62 JMF |
259 | subtitle = self._decrypt_subtitles(data, iv, id).decode('utf-8') |
260 | lang_code = self._search_regex(r'lang_code=["\']([^"\']+)', subtitle, 'subtitle_lang_code', fatal=False) | |
261 | if not lang_code: | |
262 | continue | |
0385d642 | 263 | subtitles[lang_code] = self._extract_subtitles(subtitle) |
b5857f62 JMF |
264 | return subtitles |
265 | ||
5f6a1245 | 266 | def _real_extract(self, url): |
c8434e83 | 267 | mobj = re.match(self._VALID_URL, url) |
38a40276 | 268 | video_id = mobj.group('video_id') |
269 | ||
270 | if mobj.group('prefix') == 'm': | |
271 | mobile_webpage = self._download_webpage(url, video_id, 'Downloading mobile webpage') | |
272 | webpage_url = self._search_regex(r'<link rel="canonical" href="([^"]+)" />', mobile_webpage, 'webpage_url') | |
273 | else: | |
274 | webpage_url = 'http://www.' + mobj.group('url') | |
c8434e83 | 275 | |
80f48920 | 276 | webpage = self._download_webpage(self._add_skip_wall(webpage_url), video_id, 'Downloading webpage') |
2f72e83b S |
277 | note_m = self._html_search_regex( |
278 | r'<div class="showmedia-trailer-notice">(.+?)</div>', | |
279 | webpage, 'trailer-notice', default='') | |
c8434e83 | 280 | if note_m: |
281 | raise ExtractorError(note_m) | |
282 | ||
1d430674 S |
283 | mobj = re.search(r'Page\.messaging_box_controller\.addItems\(\[(?P<msg>{.+?})\]\)', webpage) |
284 | if mobj: | |
285 | msg = json.loads(mobj.group('msg')) | |
286 | if msg.get('type') == 'error': | |
287 | raise ExtractorError('crunchyroll returned error: %s' % msg['message_body'], expected=True) | |
2f72e83b S |
288 | |
289 | if 'To view this, please log in to verify you are 18 or older.' in webpage: | |
39affb5a | 290 | self.raise_login_required() |
1d430674 | 291 | |
5214f1e3 S |
292 | video_title = self._html_search_regex( |
293 | r'(?s)<h1[^>]*>((?:(?!<h1).)*?<span[^>]+itemprop=["\']title["\'][^>]*>(?:(?!<h1).)+?)</h1>', | |
294 | webpage, 'video_title') | |
38a40276 | 295 | video_title = re.sub(r' {2,}', ' ', video_title) |
2c740cf2 | 296 | video_description = self._html_search_regex( |
6d02b9a3 S |
297 | r'<script[^>]*>\s*.+?\[media_id=%s\].+?"description"\s*:\s*"([^"]+)' % video_id, |
298 | webpage, 'description', default=None) | |
299 | if video_description: | |
300 | video_description = lowercase_escape(video_description.replace(r'\r\n', '\n')) | |
47004d95 S |
301 | video_upload_date = self._html_search_regex( |
302 | [r'<div>Availability for free users:(.+?)</div>', r'<div>[^<>]+<span>\s*(.+?\d{4})\s*</span></div>'], | |
303 | webpage, 'video_upload_date', fatal=False, flags=re.DOTALL) | |
c8434e83 | 304 | if video_upload_date: |
305 | video_upload_date = unified_strdate(video_upload_date) | |
47004d95 S |
306 | video_uploader = self._html_search_regex( |
307 | r'<a[^>]+href="/publisher/[^"]+"[^>]*>([^<]+)</a>', webpage, | |
308 | 'video_uploader', fatal=False) | |
c8434e83 | 309 | |
a60cccbf | 310 | playerdata_url = compat_urllib_parse_unquote(self._html_search_regex(r'"config_url":"([^"]+)', webpage, 'playerdata_url')) |
5c2266df | 311 | playerdata_req = sanitized_Request(playerdata_url) |
38a40276 | 312 | playerdata_req.data = compat_urllib_parse.urlencode({'current_page': webpage_url}) |
313 | playerdata_req.add_header('Content-Type', 'application/x-www-form-urlencoded') | |
314 | playerdata = self._download_webpage(playerdata_req, video_id, note='Downloading media info') | |
34440095 | 315 | |
38a40276 | 316 | stream_id = self._search_regex(r'<media_id>([^<]+)', playerdata, 'stream_id') |
317 | video_thumbnail = self._search_regex(r'<episode_image_url>([^<]+)', playerdata, 'thumbnail', fatal=False) | |
c8434e83 | 318 | |
319 | formats = [] | |
a221f229 | 320 | for fmt in re.findall(r'showmedia\.([0-9]{3,4})p', webpage): |
c8434e83 | 321 | stream_quality, stream_format = self._FORMAT_IDS[fmt] |
2514d263 | 322 | video_format = fmt + 'p' |
5c2266df | 323 | streamdata_req = sanitized_Request( |
ede21449 S |
324 | 'http://www.crunchyroll.com/xml/?req=RpcApiVideoPlayer_GetStandardConfig&media_id=%s&video_format=%s&video_quality=%s' |
325 | % (stream_id, stream_format, stream_quality), | |
326 | compat_urllib_parse.urlencode({'current_page': url}).encode('utf-8')) | |
38a40276 | 327 | streamdata_req.add_header('Content-Type', 'application/x-www-form-urlencoded') |
b1edd7a4 PH |
328 | streamdata = self._download_xml( |
329 | streamdata_req, video_id, | |
330 | note='Downloading media info for %s' % video_format) | |
ede21449 S |
331 | stream_info = streamdata.find('./{default}preload/stream_info') |
332 | video_url = stream_info.find('./host').text | |
333 | video_play_path = stream_info.find('./file').text | |
725d1c58 JMF |
334 | metadata = stream_info.find('./metadata') |
335 | format_info = { | |
336 | 'format': video_format, | |
337 | 'format_id': video_format, | |
338 | 'height': int_or_none(xpath_text(metadata, './height')), | |
339 | 'width': int_or_none(xpath_text(metadata, './width')), | |
340 | } | |
a01da8bb S |
341 | |
342 | if '.fplive.net/' in video_url: | |
343 | video_url = re.sub(r'^rtmpe?://', 'http://', video_url.strip()) | |
344 | parsed_video_url = compat_urlparse.urlparse(video_url) | |
345 | direct_video_url = compat_urlparse.urlunparse(parsed_video_url._replace( | |
346 | netloc='v.lvlt.crcdn.net', | |
347 | path='%s/%s' % (remove_end(parsed_video_url.path, '/'), video_play_path.split(':')[-1]))) | |
348 | if self._is_valid_url(direct_video_url, video_id, video_format): | |
725d1c58 | 349 | format_info.update({ |
a01da8bb | 350 | 'url': direct_video_url, |
a01da8bb | 351 | }) |
725d1c58 | 352 | formats.append(format_info) |
a01da8bb S |
353 | continue |
354 | ||
725d1c58 | 355 | format_info.update({ |
38a40276 | 356 | 'url': video_url, |
b1edd7a4 | 357 | 'play_path': video_play_path, |
38a40276 | 358 | 'ext': 'flv', |
c8434e83 | 359 | }) |
725d1c58 | 360 | formats.append(format_info) |
c8434e83 | 361 | |
b5857f62 | 362 | subtitles = self.extract_subtitles(video_id, webpage) |
11b3ce85 | 363 | |
c8434e83 | 364 | return { |
8bcc8756 JW |
365 | 'id': video_id, |
366 | 'title': video_title, | |
38a40276 | 367 | 'description': video_description, |
8bcc8756 JW |
368 | 'thumbnail': video_thumbnail, |
369 | 'uploader': video_uploader, | |
38a40276 | 370 | 'upload_date': video_upload_date, |
8bcc8756 JW |
371 | 'subtitles': subtitles, |
372 | 'formats': formats, | |
d0a72674 | 373 | } |
8230018c GS |
374 | |
375 | ||
12810c9c | 376 | class CrunchyrollShowPlaylistIE(CrunchyrollBaseIE): |
8230018c | 377 | IE_NAME = "crunchyroll:playlist" |
80f48920 | 378 | _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\-]+))/?(?:\?|$)' |
8230018c GS |
379 | |
380 | _TESTS = [{ | |
09e5d6a6 PH |
381 | 'url': 'http://www.crunchyroll.com/a-bridge-to-the-starry-skies-hoshizora-e-kakaru-hashi', |
382 | 'info_dict': { | |
383 | 'id': 'a-bridge-to-the-starry-skies-hoshizora-e-kakaru-hashi', | |
384 | 'title': 'A Bridge to the Starry Skies - Hoshizora e Kakaru Hashi' | |
8230018c | 385 | }, |
09e5d6a6 | 386 | 'playlist_count': 13, |
49941c4e S |
387 | }, { |
388 | # geo-restricted (US), 18+ maturity wall, non-premium available | |
389 | 'url': 'http://www.crunchyroll.com/cosplay-complex-ova', | |
390 | 'info_dict': { | |
391 | 'id': 'cosplay-complex-ova', | |
392 | 'title': 'Cosplay Complex OVA' | |
393 | }, | |
394 | 'playlist_count': 3, | |
395 | 'skip': 'Georestricted', | |
396 | }, { | |
397 | # geo-restricted (US), 18+ maturity wall, non-premium will be available since 2015.11.14 | |
398 | 'url': 'http://www.crunchyroll.com/ladies-versus-butlers?skip_wall=1', | |
399 | 'only_matching': True, | |
8230018c GS |
400 | }] |
401 | ||
8230018c | 402 | def _real_extract(self, url): |
09e5d6a6 PH |
403 | show_id = self._match_id(url) |
404 | ||
80f48920 | 405 | webpage = self._download_webpage(self._add_skip_wall(url), show_id) |
09e5d6a6 PH |
406 | title = self._html_search_regex( |
407 | r'(?s)<h1[^>]*>\s*<span itemprop="name">(.*?)</span>', | |
408 | webpage, 'title') | |
409 | episode_paths = re.findall( | |
410 | r'(?s)<li id="showview_videos_media_[0-9]+"[^>]+>.*?<a href="([^"]+)"', | |
411 | webpage) | |
412 | entries = [ | |
413 | self.url_result('http://www.crunchyroll.com' + ep, 'Crunchyroll') | |
414 | for ep in episode_paths | |
415 | ] | |
416 | entries.reverse() | |
417 | ||
8230018c | 418 | return { |
09e5d6a6 PH |
419 | '_type': 'playlist', |
420 | 'id': show_id, | |
421 | 'title': title, | |
422 | 'entries': entries, | |
423 | } |