X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=youtube_dl%2Fextractor%2Fcrunchyroll.py;h=2dca5266000db8ed558f149142e3b235e267a910;hb=274b12b5a8229242cd750fa95205ab63621c2c40;hp=f99888ecc378ea2a5404fe42d8d32a6a8c4093fb;hpb=11b3ce85097430e1d26ddff0f51aa895c9d5af43;p=youtube-dl diff --git a/youtube_dl/extractor/crunchyroll.py b/youtube_dl/extractor/crunchyroll.py index f99888ecc..2dca52660 100644 --- a/youtube_dl/extractor/crunchyroll.py +++ b/youtube_dl/extractor/crunchyroll.py @@ -24,6 +24,7 @@ from ..aes import ( aes_cbc_decrypt, inc, ) +from .common import InfoExtractor class CrunchyrollIE(SubtitlesInfoExtractor): @@ -39,6 +40,7 @@ class CrunchyrollIE(SubtitlesInfoExtractor): 'thumbnail': 'http://img1.ak.crunchyroll.com/i/spire1-tmb/20c6b5e10f1a47b10516877d3c039cae1380951166_full.jpg', 'uploader': 'Yomiuri Telecasting Corporation (YTV)', 'upload_date': '20131013', + 'url': 're:(?!.*&)', }, 'params': { # rtmp @@ -237,12 +239,14 @@ Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text streamdata_req.data = 'req=RpcApiVideoEncode%5FGetStreamInfo&video%5Fencode%5Fquality='+stream_quality+'&media%5Fid='+stream_id+'&video%5Fformat='+stream_format streamdata_req.add_header('Content-Type', 'application/x-www-form-urlencoded') streamdata_req.add_header('Content-Length', str(len(streamdata_req.data))) - streamdata = self._download_webpage(streamdata_req, video_id, note='Downloading media info for '+video_format) - video_url = self._search_regex(r'([^<]+)', streamdata, 'video_url') - video_play_path = self._search_regex(r'([^<]+)', streamdata, 'video_play_path') + streamdata = self._download_xml( + streamdata_req, video_id, + note='Downloading media info for %s' % video_format) + video_url = streamdata.find('.//host').text + video_play_path = streamdata.find('.//file').text formats.append({ 'url': video_url, - 'play_path': video_play_path, + 'play_path': video_play_path, 'ext': 'flv', 'format': video_format, 'format_id': video_format, @@ -285,3 +289,38 @@ Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text 'subtitles': subtitles, 'formats': formats, } + + +class CrunchyrollShowPlaylistIE(InfoExtractor): + IE_NAME = "crunchyroll:playlist" + _VALID_URL = r'https?://(?:(?Pwww|m)\.)?(?Pcrunchyroll\.com/(?!(?:news|anime-news|library|forum|launchcalendar|lineup|store|comics|freetrial|login))(?P[\w\-]+))/?$' + _TITLE_EXTR = r'\s*(?P[\w\s]+)' + + _TESTS = [{ + 'url' : 'http://www.crunchyroll.com/attack-on-titan', + 'info_dict' : { + 'title' : 'Attack on Titan' + }, + 'playlist_count' : 15 + }] + + def _extract_title_entries(self,id,webpage): + _EPISODE_ID_EXTR = r'id="showview_videos_media_(?P\d+)".*?href="/{0}/(?P[\w\-]+-(?P=vidid))"'.format(id) + title = self._html_search_regex(self._TITLE_EXTR,webpage,"title",flags=re.UNICODE|re.MULTILINE) + episode_urls = [self.url_result('http://www.crunchyroll.com/{0}/{1}'.format(id, showmatch[1])) for + showmatch in re.findall(_EPISODE_ID_EXTR, webpage,re.UNICODE|re.MULTILINE|re.DOTALL)] + episode_urls.reverse() + return title, episode_urls + + + def _real_extract(self, url): + url_match = re.match(self._VALID_URL,url) + show_id = url_match.group('show') + webpage = self._download_webpage(url,show_id) + (title,entries) = self._extract_title_entries(show_id,webpage) + return { + '_type' : 'playlist', + 'id' : show_id, + 'title' : title, + 'entries' : entries + } \ No newline at end of file