]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/rutube.py
5 from .common
import InfoExtractor
13 class RutubeIE(InfoExtractor
):
14 _VALID_URL
= r
'https?://rutube\.ru/video/(?P<long_id>\w+)'
17 u
'url': u
'http://rutube.ru/video/3eac3b4561676c17df9132a9a1e62e3e/',
18 u
'file': u
'3eac3b4561676c17df9132a9a1e62e3e.mp4',
20 u
'title': u
'Раненный кенгуру забежал в аптеку',
21 u
'uploader': u
'NTDRussian',
22 u
'uploader_id': u
'29790',
25 # It requires ffmpeg (m3u8 download)
26 u
'skip_download': True,
30 def _get_api_response(self
, short_id
, subpath
):
31 api_url
= 'http://rutube.ru/api/play/%s/%s/?format=json' % (subpath
, short_id
)
32 response_json
= self
._download
_webpage
(api_url
, short_id
,
33 u
'Downloading %s json' % subpath
)
34 return json
.loads(response_json
)
36 def _real_extract(self
, url
):
37 mobj
= re
.match(self
._VALID
_URL
, url
)
38 long_id
= mobj
.group('long_id')
39 webpage
= self
._download
_webpage
(url
, long_id
)
40 og_video
= self
._og
_search
_video
_url
(webpage
)
41 short_id
= compat_urlparse
.urlparse(og_video
).path
[1:]
42 options
= self
._get
_api
_response
(short_id
, 'options')
43 trackinfo
= self
._get
_api
_response
(short_id
, 'trackinfo')
44 # Some videos don't have the author field
45 author
= trackinfo
.get('author') or {}
46 m3u8_url
= trackinfo
['video_balancer'].get('m3u8')
48 raise ExtractorError(u
'Couldn\'t find m3u8 manifest url')
51 'id': trackinfo
['id'],
52 'title': trackinfo
['title'],
55 'thumbnail': options
['thumbnail_url'],
56 'uploader': author
.get('name'),
57 'uploader_id': compat_str(author
['id']) if author
else None,