aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/extractor/myvi.py
diff options
context:
space:
mode:
authorSergey M․ <dstftw@gmail.com>2018-02-08 22:57:33 +0700
committerSergey M․ <dstftw@gmail.com>2018-02-08 22:57:33 +0700
commit51b0557d1e488f99731f6e6a8d7364adf439fbf5 (patch)
tree6c822ea3bddc69a4ea33557806263f43920ecb41 /youtube_dl/extractor/myvi.py
parent5a5860825db709b40462e2e29144f7d2b80757b9 (diff)
[myvi:embed] Add extractor (closes #15521)
Diffstat (limited to 'youtube_dl/extractor/myvi.py')
-rw-r--r--youtube_dl/extractor/myvi.py64
1 files changed, 54 insertions, 10 deletions
diff --git a/youtube_dl/extractor/myvi.py b/youtube_dl/extractor/myvi.py
index 621ae74a7..0cf9dd06a 100644
--- a/youtube_dl/extractor/myvi.py
+++ b/youtube_dl/extractor/myvi.py
@@ -3,22 +3,27 @@ from __future__ import unicode_literals
import re
+from .common import InfoExtractor
from .vimple import SprutoBaseIE
class MyviIE(SprutoBaseIE):
_VALID_URL = r'''(?x)
- https?://
- myvi\.(?:ru/player|tv)/
- (?:
+ (?:
+ https?://
+ (?:www\.)?
+ myvi\.(?:ru/player|tv)/
(?:
- embed/html|
- flash|
- api/Video/Get
- )/|
- content/preloader\.swf\?.*\bid=
- )
- (?P<id>[\da-zA-Z_-]+)
+ (?:
+ embed/html|
+ flash|
+ api/Video/Get
+ )/|
+ content/preloader\.swf\?.*\bid=
+ )|
+ myvi:
+ )
+ (?P<id>[\da-zA-Z_-]+)
'''
_TESTS = [{
'url': 'http://myvi.ru/player/embed/html/oOy4euHA6LVwNNAjhD9_Jq5Ha2Qf0rtVMVFMAZav8wObeRTZaCATzucDQIDph8hQU0',
@@ -42,6 +47,9 @@ class MyviIE(SprutoBaseIE):
}, {
'url': 'http://myvi.ru/player/flash/ocp2qZrHI-eZnHKQBK4cZV60hslH8LALnk0uBfKsB-Q4WnY26SeGoYPi8HWHxu0O30',
'only_matching': True,
+ }, {
+ 'url': 'myvi:YwbqszQynUaHPn_s82sx0Q2',
+ 'only_matching': True,
}]
@classmethod
@@ -58,3 +66,39 @@ class MyviIE(SprutoBaseIE):
'http://myvi.ru/player/api/Video/Get/%s?sig' % video_id, video_id)['sprutoData']
return self._extract_spruto(spruto, video_id)
+
+
+class MyviEmbedIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?myvi\.tv/(?:[^?]+\?.*?\bv=|embed/)(?P<id>[\da-z]+)'
+ _TESTS = [{
+ 'url': 'https://www.myvi.tv/embed/ccdqic3wgkqwpb36x9sxg43t4r',
+ 'info_dict': {
+ 'id': 'b3ea0663-3234-469d-873e-7fecf36b31d1',
+ 'ext': 'mp4',
+ 'title': 'Твоя (original song).mp4',
+ 'thumbnail': r're:^https?://.*\.jpg$',
+ 'duration': 277,
+ },
+ 'params': {
+ 'skip_download': True,
+ },
+ }, {
+ 'url': 'https://www.myvi.tv/idmi6o?v=ccdqic3wgkqwpb36x9sxg43t4r#watch',
+ 'only_matching': True,
+ }]
+
+ @classmethod
+ def suitable(cls, url):
+ return False if MyviIE.suitable(url) else super(MyviEmbedIE, cls).suitable(url)
+
+ def _real_extract(self, url):
+ video_id = self._match_id(url)
+
+ webpage = self._download_webpage(
+ 'https://www.myvi.tv/embed/%s' % video_id, video_id)
+
+ myvi_id = self._search_regex(
+ r'CreatePlayer\s*\(\s*["\'].*?\bv=([\da-zA-Z_]+)',
+ webpage, 'video id')
+
+ return self.url_result('myvi:%s' % myvi_id, ie=MyviIE.ie_key())