X-Git-Url: http://git.cielonegro.org/gitweb.cgi?a=blobdiff_plain;f=youtube_dl%2Fextractor%2Frutv.py;h=1ec2c86e5776a88604cb8a294ba67861f61cff82;hb=7212560f4d6b0de5b76eb41090c639855915946e;hp=5c38cbc02b7748b49daf3654291dfe5fe2b49a50;hpb=6e25c58ed74505f69770ee01fd762f416d7405d3;p=youtube-dl.git diff --git a/youtube_dl/extractor/rutv.py b/youtube_dl/extractor/rutv.py index 5c38cbc02..1ec2c86e5 100644 --- a/youtube_dl/extractor/rutv.py +++ b/youtube_dl/extractor/rutv.py @@ -12,7 +12,12 @@ from ..utils import ( class RUTVIE(InfoExtractor): IE_DESC = 'RUTV.RU' - _VALID_URL = r'https?://player\.(?:rutv\.ru|vgtrk\.com)/(?:flash2v/container\.swf\?id=|iframe/(?Pswf|video|live)/id/)(?P\d+)' + _VALID_URL = r'''(?x) + https?://player\.(?:rutv\.ru|vgtrk\.com)/ + (?Pflash2v/container\.swf\?id= + |iframe/(?Pswf|video|live)/id/ + |index/iframe/cast_id/) + (?P\d+)''' _TESTS = [ { @@ -79,23 +84,32 @@ class RUTVIE(InfoExtractor): 'title': 'Сочи-2014. Биатлон. Индивидуальная гонка. Мужчины ', 'description': 'md5:9e0ed5c9d2fa1efbfdfed90c9a6d179c', }, + 'skip': 'Translation has finished', + }, + { + 'url': 'http://live.russia.tv/index/index/channel_id/3', + 'info_dict': { + 'id': '21', + 'ext': 'mp4', + 'title': 're:^Россия 24. Прямой эфир [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$', + 'is_live': True, + }, 'params': { - # rtmp download + # m3u8 download 'skip_download': True, }, - 'skip': 'Translation has finished', }, ] @classmethod def _extract_url(cls, webpage): mobj = re.search( - r']+?src=(["\'])(?Phttps?://player\.rutv\.ru/iframe/(?:swf|video|live)/id/.+?)\1', webpage) + r']+?src=(["\'])(?Phttps?://player\.rutv\.ru/(?:iframe/(?:swf|video|live)/id|index/iframe/cast_id)/.+?)\1', webpage) if mobj: return mobj.group('url') mobj = re.search( - r']+?property=(["\'])og:video\1[^>]+?content=(["\'])(?Phttp://player\.(?:rutv\.ru|vgtrk\.com)/flash2v/container\.swf\?id=.+?\2)', + r']+?property=(["\'])og:video\1[^>]+?content=(["\'])(?Phttps?://player\.(?:rutv\.ru|vgtrk\.com)/flash2v/container\.swf\?id=.+?\2)', webpage) if mobj: return mobj.group('url') @@ -103,10 +117,16 @@ class RUTVIE(InfoExtractor): def _real_extract(self, url): mobj = re.match(self._VALID_URL, url) video_id = mobj.group('id') - video_type = mobj.group('type') + video_path = mobj.group('path') - if not video_type or video_type == 'swf': + if video_path.startswith('flash2v'): video_type = 'video' + elif video_path.startswith('iframe'): + video_type = mobj.group('type') + if video_type == 'swf': + video_type = 'video' + elif video_path.startswith('index/iframe/cast_id'): + video_type = 'live' json_data = self._download_json( 'http://player.rutv.ru/iframe/%splay/id/%s' % ('live-' if video_type == 'live' else '', video_id), @@ -151,10 +171,8 @@ class RUTVIE(InfoExtractor): 'vbr': int(quality), } elif transport == 'm3u8': - fmt = { - 'url': url, - 'ext': 'mp4', - } + formats.extend(self._extract_m3u8_formats(url, video_id, 'mp4')) + continue else: fmt = { 'url': url @@ -172,12 +190,15 @@ class RUTVIE(InfoExtractor): self._sort_formats(formats) + is_live = video_type == 'live' + return { 'id': video_id, - 'title': title, + 'title': self._live_title(title) if is_live else title, 'description': description, 'thumbnail': thumbnail, 'view_count': view_count, 'duration': duration, 'formats': formats, - } \ No newline at end of file + 'is_live': is_live, + }