2 from __future__ import unicode_literals
7 from .common import InfoExtractor
10 class MailRuIE(InfoExtractor):
12 IE_DESC = 'Видео@Mail.Ru'
13 _VALID_URL = r'http://(?:www\.)?my\.mail\.ru/video/.*#video=/?(?P<id>[^/]+/[^/]+/[^/]+/\d+)'
16 'url': 'http://my.mail.ru/video/top#video=/mail/sonypicturesrus/75/76',
17 'md5': 'dea205f03120046894db4ebb6159879a',
21 'title': 'Новый Человек-Паук. Высокое напряжение. Восстание Электро',
22 'upload_date': '20140224',
23 'uploader': 'sonypicturesrus',
24 'uploader_id': 'sonypicturesrus@mail.ru',
29 def _real_extract(self, url):
30 mobj = re.match(self._VALID_URL, url)
31 video_id = mobj.group('id')
33 video_data = self._download_json(
34 'http://videoapi.my.mail.ru/videos/%s.json?new=1' % video_id, video_id, 'Downloading video JSON')
36 author = video_data['author']
37 uploader = author['name']
38 uploader_id = author['id']
40 movie = video_data['movie']
41 content_id = str(movie['contentId'])
42 title = movie['title']
43 thumbnail = movie['poster']
44 duration = movie['duration']
46 upload_date = datetime.datetime.fromtimestamp(video_data['timestamp']).strftime('%Y%m%d')
47 view_count = video_data['views_count']
52 'format_id': video['name'],
53 } for video in video_data['videos']
59 'thumbnail': thumbnail,
60 'upload_date': upload_date,
62 'uploader_id': uploader_id,
64 'view_count': view_count,