aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey M․ <dstftw@gmail.com>2014-03-17 01:59:40 +0700
committerSergey M․ <dstftw@gmail.com>2014-03-17 01:59:40 +0700
commita7515ec26539f38c78f1fc01a905dc3f57f70d74 (patch)
treedc3120e2c76e0e97243ae9587b7ab8bb1e27f8b0
parentb6c1ceccc229c174cae5432c7701399267d41943 (diff)
downloadyoutube-dl-a7515ec26539f38c78f1fc01a905dc3f57f70d74.tar.xz
[rutv] Refactor vgtrk/rutv extractor
-rw-r--r--youtube_dl/extractor/__init__.py2
-rw-r--r--youtube_dl/extractor/rutv.py (renamed from youtube_dl/extractor/vgtrk.py)167
2 files changed, 37 insertions, 132 deletions
diff --git a/youtube_dl/extractor/__init__.py b/youtube_dl/extractor/__init__.py
index 313414e7d..ceba2af3d 100644
--- a/youtube_dl/extractor/__init__.py
+++ b/youtube_dl/extractor/__init__.py
@@ -196,6 +196,7 @@ from .rutube import (
RutubeMovieIE,
RutubePersonIE,
)
+from .rutv import RUTVIE
from .savefrom import SaveFromIE
from .servingsys import ServingSysIE
from .sina import SinaIE
@@ -252,7 +253,6 @@ from .vbox7 import Vbox7IE
from .veehd import VeeHDIE
from .veoh import VeohIE
from .vevo import VevoIE
-from .vgtrk import VGTRKIE
from .vice import ViceIE
from .viddler import ViddlerIE
from .videobam import VideoBamIE
diff --git a/youtube_dl/extractor/vgtrk.py b/youtube_dl/extractor/rutv.py
index 429b8bc72..5c38cbc02 100644
--- a/youtube_dl/extractor/vgtrk.py
+++ b/youtube_dl/extractor/rutv.py
@@ -10,33 +10,19 @@ from ..utils import (
)
-class VGTRKIE(InfoExtractor):
- IE_DESC = 'ВГТРК'
- _VALID_URL = r'http://(?:.+?\.)?(?:vesti\.ru|russia2?\.tv|tvkultura\.ru|rutv\.ru)/(?P<id>.+)'
+class RUTVIE(InfoExtractor):
+ IE_DESC = 'RUTV.RU'
+ _VALID_URL = r'https?://player\.(?:rutv\.ru|vgtrk\.com)/(?:flash2v/container\.swf\?id=|iframe/(?P<type>swf|video|live)/id/)(?P<id>\d+)'
_TESTS = [
{
- 'url': 'http://www.vesti.ru/videos?vid=575582&cid=1',
+ 'url': 'http://player.rutv.ru/flash2v/container.swf?id=774471&sid=kultura&fbv=true&isPlay=true&ssl=false&i=560&acc_video_id=episode_id/972347/video_id/978186/brand_id/31724',
'info_dict': {
- 'id': '765035',
- 'ext': 'mp4',
- 'title': 'Вести.net: биткоины в России не являются законными',
- 'description': 'md5:d4bb3859dc1177b28a94c5014c35a36b',
- 'duration': 302,
- },
- 'params': {
- # m3u8 download
- 'skip_download': True,
- },
- },
- {
- 'url': 'http://www.vesti.ru/doc.html?id=1349233',
- 'info_dict': {
- 'id': '773865',
+ 'id': '774471',
'ext': 'mp4',
- 'title': 'Участники митинга штурмуют Донецкую областную администрацию',
- 'description': 'md5:1a160e98b3195379b4c849f2f4958009',
- 'duration': 210,
+ 'title': 'Монологи на все времена',
+ 'description': 'md5:18d8b5e6a41fb1faa53819471852d5d5',
+ 'duration': 2906,
},
'params': {
# m3u8 download
@@ -44,13 +30,13 @@ class VGTRKIE(InfoExtractor):
},
},
{
- 'url': 'http://www.vesti.ru/only_video.html?vid=576180',
+ 'url': 'https://player.vgtrk.com/flash2v/container.swf?id=774016&sid=russiatv&fbv=true&isPlay=true&ssl=false&i=560&acc_video_id=episode_id/972098/video_id/977760/brand_id/57638',
'info_dict': {
- 'id': '766048',
+ 'id': '774016',
'ext': 'mp4',
- 'title': 'США заморозило, Британию затопило',
- 'description': 'md5:f0ed0695ec05aed27c56a70a58dc4cc1',
- 'duration': 87,
+ 'title': 'Чужой в семье Сталина',
+ 'description': '',
+ 'duration': 2539,
},
'params': {
# m3u8 download
@@ -58,7 +44,7 @@ class VGTRKIE(InfoExtractor):
},
},
{
- 'url': 'http://hitech.vesti.ru/news/view/id/4000',
+ 'url': 'http://player.rutv.ru/iframe/swf/id/766888/sid/hitech/?acc_video_id=4000',
'info_dict': {
'id': '766888',
'ext': 'mp4',
@@ -72,22 +58,21 @@ class VGTRKIE(InfoExtractor):
},
},
{
- 'url': 'http://sochi2014.vesti.ru/video/index/video_id/766403',
+ 'url': 'http://player.rutv.ru/iframe/video/id/771852/start_zoom/true/showZoomBtn/false/sid/russiatv/?acc_video_id=episode_id/970443/video_id/975648/brand_id/5169',
'info_dict': {
- 'id': '766403',
+ 'id': '771852',
'ext': 'mp4',
- 'title': 'XXII зимние Олимпийские игры. Российские хоккеисты стартовали на Олимпиаде с победы',
- 'description': 'md5:55805dfd35763a890ff50fa9e35e31b3',
- 'duration': 271,
+ 'title': 'Прямой эфир. Жертвы загадочной болезни: смерть от старости в 17 лет',
+ 'description': 'md5:b81c8c55247a4bd996b43ce17395b2d8',
+ 'duration': 3096,
},
'params': {
# m3u8 download
'skip_download': True,
},
- 'skip': 'Blocked outside Russia',
},
{
- 'url': 'http://sochi2014.vesti.ru/live/play/live_id/301',
+ 'url': 'http://player.rutv.ru/iframe/live/id/51499/showZoomBtn/false/isPlay/true/sid/sochi2014',
'info_dict': {
'id': '51499',
'ext': 'flv',
@@ -98,124 +83,44 @@ class VGTRKIE(InfoExtractor):
# rtmp download
'skip_download': True,
},
- 'skip': 'Translation has finished'
- },
- {
- 'url': 'http://russia.tv/video/show/brand_id/5169/episode_id/970443/video_id/975648',
- 'info_dict': {
- 'id': '771852',
- 'ext': 'mp4',
- 'title': 'Прямой эфир. Жертвы загадочной болезни: смерть от старости в 17 лет',
- 'description': 'md5:b81c8c55247a4bd996b43ce17395b2d8',
- 'duration': 3096,
- },
- 'params': {
- # m3u8 download
- 'skip_download': True,
- },
- },
- {
- 'url': 'http://russia.tv/brand/show/brand_id/57638',
- 'info_dict': {
- 'id': '774016',
- 'ext': 'mp4',
- 'title': 'Чужой в семье Сталина',
- 'description': '',
- 'duration': 2539,
- },
- 'params': {
- # m3u8 download
- 'skip_download': True,
- },
- },
- {
- 'url': 'http://2.russia.tv/video/show/brand_id/48863/episode_id/972920/video_id/978667/viewtype/picture',
- 'info_dict': {
- 'id': '775081',
- 'ext': 'mp4',
- 'title': 'XXII зимние Олимпийские игры. Россияне заняли весь пьедестал в лыжных гонках',
- 'description': 'md5:15d3741dd8d04b203fbc031c6a47fb0f',
- 'duration': 101,
- },
- 'params': {
- # m3u8 download
- 'skip_download': True,
- },
- 'skip': 'Blocked outside Russia',
- },
- {
- 'url': 'http://tvkultura.ru/video/show/brand_id/31724/episode_id/972347/video_id/978186',
- 'info_dict': {
- 'id': '774471',
- 'ext': 'mp4',
- 'title': 'Монологи на все времена',
- 'description': 'md5:18d8b5e6a41fb1faa53819471852d5d5',
- 'duration': 2906,
- },
- 'params': {
- # m3u8 download
- 'skip_download': True,
- },
- },
- {
- 'url': 'http://rutv.ru/brand/show/id/6792/channel/75',
- 'info_dict': {
- 'id': '125521',
- 'ext': 'mp4',
- 'title': 'Грустная дама червей. Х/ф',
- 'description': '',
- 'duration': 4882,
- },
- 'params': {
- # m3u8 download
- 'skip_download': True,
- },
+ 'skip': 'Translation has finished',
},
]
- def _real_extract(self, url):
- mobj = re.match(self._VALID_URL, url)
- video_id = mobj.group('id')
-
- page = self._download_webpage(url, video_id, 'Downloading page')
-
+ @classmethod
+ def _extract_url(cls, webpage):
mobj = re.search(
- r'<meta property="og:video" content="http://www\.vesti\.ru/i/flvplayer_videoHost\.swf\?vid=(?P<id>\d+)',
- page)
+ r'<iframe[^>]+?src=(["\'])(?P<url>https?://player\.rutv\.ru/iframe/(?:swf|video|live)/id/.+?)\1', webpage)
if mobj:
- video_id = mobj.group('id')
- page = self._download_webpage('http://www.vesti.ru/only_video.html?vid=%s' % video_id, video_id,
- 'Downloading video page')
+ return mobj.group('url')
mobj = re.search(
- r'<meta property="og:video" content="http://player\.rutv\.ru/flash2v/container\.swf\?id=(?P<id>\d+)', page)
+ r'<meta[^>]+?property=(["\'])og:video\1[^>]+?content=(["\'])(?P<url>http://player\.(?:rutv\.ru|vgtrk\.com)/flash2v/container\.swf\?id=.+?\2)',
+ webpage)
if mobj:
- video_type = 'video'
- video_id = mobj.group('id')
- else:
- mobj = re.search(
- r'<iframe.+?src="http://player\.rutv\.ru/iframe/(?P<type>[^/]+)/id/(?P<id>\d+)[^"]*".*?></iframe>',
- page)
+ return mobj.group('url')
- if not mobj:
- raise ExtractorError('No media found', expected=True)
+ def _real_extract(self, url):
+ mobj = re.match(self._VALID_URL, url)
+ video_id = mobj.group('id')
+ video_type = mobj.group('type')
- video_type = mobj.group('type')
- video_id = mobj.group('id')
+ if not video_type or video_type == 'swf':
+ video_type = 'video'
json_data = self._download_json(
'http://player.rutv.ru/iframe/%splay/id/%s' % ('live-' if video_type == 'live' else '', video_id),
video_id, 'Downloading JSON')
if json_data['errors']:
- raise ExtractorError('vesti returned error: %s' % json_data['errors'], expected=True)
+ raise ExtractorError('%s said: %s' % (self.IE_NAME, json_data['errors']), expected=True)
playlist = json_data['data']['playlist']
medialist = playlist['medialist']
media = medialist[0]
if media['errors']:
- raise ExtractorError('vesti returned error: %s' % media['errors'], expected=True)
+ raise ExtractorError('%s said: %s' % (self.IE_NAME, media['errors']), expected=True)
view_count = playlist.get('count_views')
priority_transport = playlist['priority_transport']