]> Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/myvi.py
Register new version in the changelog.
[youtubedl] / youtube_dl / extractor / myvi.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 import re
5
6 from .vimple import SprutoBaseIE
7
8
9 class MyviIE(SprutoBaseIE):
10 _VALID_URL = r'''(?x)
11 https?://
12 myvi\.(?:ru/player|tv)/
13 (?:
14 (?:
15 embed/html|
16 flash|
17 api/Video/Get
18 )/|
19 content/preloader\.swf\?.*\bid=
20 )
21 (?P<id>[\da-zA-Z_-]+)
22 '''
23 _TESTS = [{
24 'url': 'http://myvi.ru/player/embed/html/oOy4euHA6LVwNNAjhD9_Jq5Ha2Qf0rtVMVFMAZav8wObeRTZaCATzucDQIDph8hQU0',
25 'md5': '571bbdfba9f9ed229dc6d34cc0f335bf',
26 'info_dict': {
27 'id': 'f16b2bbd-cde8-481c-a981-7cd48605df43',
28 'ext': 'mp4',
29 'title': 'хозяин жизни',
30 'thumbnail': 're:^https?://.*\.jpg$',
31 'duration': 25,
32 },
33 }, {
34 'url': 'http://myvi.ru/player/content/preloader.swf?id=oOy4euHA6LVwNNAjhD9_Jq5Ha2Qf0rtVMVFMAZav8wOYf1WFpPfc_bWTKGVf_Zafr0',
35 'only_matching': True,
36 }, {
37 'url': 'http://myvi.ru/player/api/Video/Get/oOy4euHA6LVwNNAjhD9_Jq5Ha2Qf0rtVMVFMAZav8wObeRTZaCATzucDQIDph8hQU0',
38 'only_matching': True,
39 }, {
40 'url': 'http://myvi.tv/embed/html/oTGTNWdyz4Zwy_u1nraolwZ1odenTd9WkTnRfIL9y8VOgHYqOHApE575x4_xxS9Vn0?ap=0',
41 'only_matching': True,
42 }, {
43 'url': 'http://myvi.ru/player/flash/ocp2qZrHI-eZnHKQBK4cZV60hslH8LALnk0uBfKsB-Q4WnY26SeGoYPi8HWHxu0O30',
44 'only_matching': True,
45 }]
46
47 @classmethod
48 def _extract_url(cls, webpage):
49 mobj = re.search(
50 r'<iframe[^>]+?src=(["\'])(?P<url>(?:https?:)?//myvi\.(?:ru/player|tv)/(?:embed/html|flash)/[^"]+)\1', webpage)
51 if mobj:
52 return mobj.group('url')
53
54 def _real_extract(self, url):
55 video_id = self._match_id(url)
56
57 spruto = self._download_json(
58 'http://myvi.ru/player/api/Video/Get/%s?sig' % video_id, video_id)['sprutoData']
59
60 return self._extract_spruto(spruto, video_id)