]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/mailru.py
6b7c5e3e03dc5b2cb6012a6e03d23a71fe359fee
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
13 class MailRuIE(InfoExtractor
):
15 IE_DESC
= 'Видео@Mail.Ru'
18 (?:(?:www|m)\.)?my\.mail\.ru/
20 video/.*\#video=/?(?P<idv1>(?:[^/]+/){3}\d+)|
21 (?:(?P<idv2prefix>(?:[^/]+/){2})video/(?P<idv2suffix>[^/]+/\d+))\.html|
22 (?:video/embed|\+/video/meta)/(?P<metaid>\d+)
27 'url': 'http://my.mail.ru/video/top#video=/mail/sonypicturesrus/75/76',
28 'md5': 'dea205f03120046894db4ebb6159879a',
32 'title': 'Новый Человек-Паук. Высокое напряжение. Восстание Электро',
33 'timestamp': 1393235077,
34 'upload_date': '20140224',
35 'uploader': 'sonypicturesrus',
36 'uploader_id': 'sonypicturesrus@mail.ru',
39 'skip': 'Not accessible from Travis CI server',
42 'url': 'http://my.mail.ru/corp/hitech/video/news_hi-tech_mail_ru/1263.html',
43 'md5': '00a91a58c3402204dcced523777b475f',
45 'id': '46843144_1263',
47 'title': 'Samsung Galaxy S5 Hammer Smash Fail Battery Explosion',
48 'timestamp': 1397039888,
49 'upload_date': '20140409',
51 'uploader_id': 'hitech@corp.mail.ru',
54 'skip': 'Not accessible from Travis CI server',
57 # only available via metaUrl API
58 'url': 'http://my.mail.ru/mail/720pizle/video/_myvideo/502.html',
59 'md5': '3b26d2491c6949d031a32b96bd97c096',
64 'timestamp': 1449094163,
65 'upload_date': '20151202',
66 'uploader': '720pizle@mail.ru',
67 'uploader_id': '720pizle@mail.ru',
70 'skip': 'Not accessible from Travis CI server',
73 'url': 'http://m.my.mail.ru/mail/3sktvtr/video/_myvideo/138.html',
74 'only_matching': True,
77 'url': 'https://my.mail.ru/video/embed/7949340477499637815',
78 'only_matching': True,
81 'url': 'http://my.mail.ru/+/video/meta/7949340477499637815',
82 'only_matching': True,
86 def _real_extract(self
, url
):
87 mobj
= re
.match(self
._VALID
_URL
, url
)
88 meta_id
= mobj
.group('metaid')
92 meta_url
= 'https://my.mail.ru/+/video/meta/%s' % meta_id
94 video_id
= mobj
.group('idv1')
96 video_id
= mobj
.group('idv2prefix') + mobj
.group('idv2suffix')
97 webpage
= self
._download
_webpage
(url
, video_id
)
98 page_config
= self
._parse
_json
(self
._search
_regex
(
99 r
'(?s)<script[^>]+class="sp-video__page-config"[^>]*>(.+?)</script>',
100 webpage
, 'page config', default
='{}'), video_id
, fatal
=False)
102 meta_url
= page_config
.get('metaUrl') or page_config
.get('video', {}).get('metaUrl')
108 video_data
= self
._download
_json
(
109 meta_url
, video_id
or meta_id
, 'Downloading video meta JSON',
112 # Fallback old approach
114 video_data
= self
._download
_json
(
115 'http://api.video.mail.ru/videos/%s.json?new=1' % video_id
,
116 video_id
, 'Downloading video JSON')
119 for f
in video_data
['videos']:
120 video_url
= f
.get('url')
123 format_id
= f
.get('key')
124 height
= int_or_none(self
._search
_regex
(
125 r
'^(\d+)[pP]$', format_id
, 'height', default
=None)) if format_id
else None
128 'format_id': format_id
,
131 self
._sort
_formats
(formats
)
133 meta_data
= video_data
['meta']
134 title
= remove_end(meta_data
['title'], '.mp4')
136 author
= video_data
.get('author')
137 uploader
= author
.get('name')
138 uploader_id
= author
.get('id') or author
.get('email')
139 view_count
= int_or_none(video_data
.get('viewsCount') or video_data
.get('views_count'))
141 acc_id
= meta_data
.get('accId')
142 item_id
= meta_data
.get('itemId')
143 content_id
= '%s_%s' % (acc_id
, item_id
) if acc_id
and item_id
else video_id
145 thumbnail
= meta_data
.get('poster')
146 duration
= int_or_none(meta_data
.get('duration'))
147 timestamp
= int_or_none(meta_data
.get('timestamp'))
152 'thumbnail': thumbnail
,
153 'timestamp': timestamp
,
154 'uploader': uploader
,
155 'uploader_id': uploader_id
,
156 'duration': duration
,
157 'view_count': view_count
,