]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/vesti.py
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
13 class VestiIE(InfoExtractor
):
16 _VALID_URL
= r
'http://(?:.+?\.)?vesti\.ru/(?P<id>.+)'
20 'url': 'http://www.vesti.ru/videos?vid=575582&cid=1',
24 'title': 'Вести.net: биткоины в России не являются законными',
25 'description': 'md5:d4bb3859dc1177b28a94c5014c35a36b',
30 'skip_download': True,
34 'url': 'http://www.vesti.ru/only_video.html?vid=576180',
38 'title': 'США заморозило, Британию затопило',
39 'description': 'md5:f0ed0695ec05aed27c56a70a58dc4cc1',
44 'skip_download': True,
48 'url': 'http://sochi2014.vesti.ru/video/index/video_id/766403',
52 'title': 'XXII зимние Олимпийские игры. Российские хоккеисты стартовали на Олимпиаде с победы',
53 'description': 'md5:55805dfd35763a890ff50fa9e35e31b3',
58 'skip_download': True,
60 'skip': 'Blocked outside Russia'
63 'url': 'http://sochi2014.vesti.ru/live/play/live_id/301',
67 'title': 'Сочи-2014. Биатлон. Индивидуальная гонка. Мужчины ',
68 'description': 'md5:9e0ed5c9d2fa1efbfdfed90c9a6d179c',
72 'skip_download': True,
74 'skip': 'Translation has finished'
78 def _real_extract(self
, url
):
79 mobj
= re
.match(self
._VALID
_URL
, url
)
80 video_id
= mobj
.group('id')
82 page
= self
._download
_webpage
(url
, video_id
, 'Downloading page')
84 mobj
= re
.search(r
'<meta property="og:video" content=".+?\.swf\?v?id=(?P<id>\d+).*?" />', page
)
87 video_id
= mobj
.group('id')
90 r
'<iframe.+?src="http://player\.rutv\.ru/iframe/(?P<type>[^/]+)/id/(?P<id>\d+)[^"]*".*?></iframe>', page
)
93 raise ExtractorError('No media found')
95 video_type
= mobj
.group('type')
96 video_id
= mobj
.group('id')
98 json_data
= self
._download
_json
(
99 'http://player.rutv.ru/iframe/%splay/id/%s' % ('live-' if video_type
== 'live' else '', video_id
),
100 video_id
, 'Downloading JSON')
102 if json_data
['errors']:
103 raise ExtractorError('vesti returned error: %s' % json_data
['errors'], expected
=True)
105 playlist
= json_data
['data']['playlist']
106 medialist
= playlist
['medialist']
110 raise ExtractorError('vesti returned error: %s' % media
['errors'], expected
=True)
112 view_count
= playlist
.get('count_views')
113 priority_transport
= playlist
['priority_transport']
115 thumbnail
= media
['picture']
116 width
= media
['width']
117 height
= media
['height']
118 description
= media
['anons']
119 title
= media
['title']
120 duration
= int_or_none(media
.get('duration'))
124 for transport
, links
in media
['sources'].items():
125 for quality
, url
in links
.items():
126 if transport
== 'rtmp':
127 mobj
= re
.search(r
'^(?P<url>rtmp://[^/]+/(?P<app>.+))/(?P<playpath>.+)$', url
)
131 'url': mobj
.group('url'),
132 'play_path': mobj
.group('playpath'),
133 'app': mobj
.group('app'),
134 'page_url': 'http://player.rutv.ru',
135 'player_url': 'http://player.rutv.ru/flash2v/osmf.swf?i=22',
140 elif transport
== 'm3u8':
152 'format_id': '%s-%s' % (transport
, quality
),
153 'preference': -1 if priority_transport
== transport
else -2,
158 raise ExtractorError('No media links available for %s' % video_id
)
160 self
._sort
_formats
(formats
)
165 'description': description
,
166 'thumbnail': thumbnail
,
167 'view_count': view_count
,
168 'duration': duration
,