]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/mailru.py
f7cc3c83289f1101207c385d5bfed2055c7b7f67
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
13 class MailRuIE(InfoExtractor
):
15 IE_DESC
= 'Видео@Mail.Ru'
16 _VALID_URL
= r
'https?://(?:(?:www|m)\.)?my\.mail\.ru/(?:video/.*#video=/?(?P<idv1>(?:[^/]+/){3}\d+)|(?:(?P<idv2prefix>(?:[^/]+/){2})video/(?P<idv2suffix>[^/]+/\d+))\.html)'
20 'url': 'http://my.mail.ru/video/top#video=/mail/sonypicturesrus/75/76',
21 'md5': 'dea205f03120046894db4ebb6159879a',
25 'title': 'Новый Человек-Паук. Высокое напряжение. Восстание Электро',
26 'timestamp': 1393232740,
27 'upload_date': '20140224',
28 'uploader': 'sonypicturesrus',
29 'uploader_id': 'sonypicturesrus@mail.ru',
32 'skip': 'Not accessible from Travis CI server',
35 'url': 'http://my.mail.ru/corp/hitech/video/news_hi-tech_mail_ru/1263.html',
36 'md5': '00a91a58c3402204dcced523777b475f',
38 'id': '46843144_1263',
40 'title': 'Samsung Galaxy S5 Hammer Smash Fail Battery Explosion',
41 'timestamp': 1397039888,
42 'upload_date': '20140409',
43 'uploader': 'hitech@corp.mail.ru',
44 'uploader_id': 'hitech@corp.mail.ru',
47 'skip': 'Not accessible from Travis CI server',
50 # only available via metaUrl API
51 'url': 'http://my.mail.ru/mail/720pizle/video/_myvideo/502.html',
52 'md5': '3b26d2491c6949d031a32b96bd97c096',
57 'timestamp': 1449094163,
58 'upload_date': '20151202',
59 'uploader': '720pizle@mail.ru',
60 'uploader_id': '720pizle@mail.ru',
63 'skip': 'Not accessible from Travis CI server',
66 'url': 'http://m.my.mail.ru/mail/3sktvtr/video/_myvideo/138.html',
67 'only_matching': True,
71 def _real_extract(self
, url
):
72 mobj
= re
.match(self
._VALID
_URL
, url
)
73 video_id
= mobj
.group('idv1')
76 video_id
= mobj
.group('idv2prefix') + mobj
.group('idv2suffix')
78 webpage
= self
._download
_webpage
(url
, video_id
)
82 page_config
= self
._parse
_json
(self
._search
_regex
(
83 r
'(?s)<script[^>]+class="sp-video__page-config"[^>]*>(.+?)</script>',
84 webpage
, 'page config', default
='{}'), video_id
, fatal
=False)
86 meta_url
= page_config
.get('metaUrl') or page_config
.get('video', {}).get('metaUrl')
88 video_data
= self
._download
_json
(
89 meta_url
, video_id
, 'Downloading video meta JSON', fatal
=False)
91 # Fallback old approach
93 video_data
= self
._download
_json
(
94 'http://api.video.mail.ru/videos/%s.json?new=1' % video_id
,
95 video_id
, 'Downloading video JSON')
98 for f
in video_data
['videos']:
99 video_url
= f
.get('url')
102 format_id
= f
.get('key')
103 height
= int_or_none(self
._search
_regex
(
104 r
'^(\d+)[pP]$', format_id
, 'height', default
=None)) if format_id
else None
107 'format_id': format_id
,
110 self
._sort
_formats
(formats
)
112 meta_data
= video_data
['meta']
113 title
= remove_end(meta_data
['title'], '.mp4')
115 author
= video_data
.get('author')
116 uploader
= author
.get('name')
117 uploader_id
= author
.get('id') or author
.get('email')
118 view_count
= int_or_none(video_data
.get('viewsCount') or video_data
.get('views_count'))
120 acc_id
= meta_data
.get('accId')
121 item_id
= meta_data
.get('itemId')
122 content_id
= '%s_%s' % (acc_id
, item_id
) if acc_id
and item_id
else video_id
124 thumbnail
= meta_data
.get('poster')
125 duration
= int_or_none(meta_data
.get('duration'))
126 timestamp
= int_or_none(meta_data
.get('timestamp'))
131 'thumbnail': thumbnail
,
132 'timestamp': timestamp
,
133 'uploader': uploader
,
134 'uploader_id': uploader_id
,
135 'duration': duration
,
136 'view_count': view_count
,