[onetmvp] Add shortcut extractor
authorSergey M․ <dstftw@gmail.com>
Tue, 14 Feb 2017 17:58:18 +0000 (00:58 +0700)
committerSergey M․ <dstftw@gmail.com>
Tue, 14 Feb 2017 17:58:18 +0000 (00:58 +0700)
youtube_dl/extractor/extractors.py
youtube_dl/extractor/onet.py

index 657e45e6ffabdb47c3b7bdb29e09c9dc2c704dd2..b2ee0c1b09a7b712caebbe50b4054e7dc77d2985 100644 (file)
@@ -694,6 +694,7 @@ from .ondemandkorea import OnDemandKoreaIE
 from .onet import (
     OnetIE,
     OnetChannelIE,
+    OnetMVPIE,
 )
 from .onionstudios import OnionStudiosIE
 from .ooyala import (
index 0a501b3e5b9f0c0bd2c6789e4da302b7610ced28..46bad492a9be3636e42ff322b89b0f676f567758 100644 (file)
@@ -23,7 +23,7 @@ class OnetBaseIE(InfoExtractor):
         return self._search_regex(
             r'id=(["\'])mvp:(?P<id>.+?)\1', webpage, 'mvp id', group='id')
 
-    def _extract_from_id(self, video_id, webpage):
+    def _extract_from_id(self, video_id, webpage=None):
         response = self._download_json(
             'http://qi.ckm.onetapi.pl/', video_id,
             query={
@@ -74,8 +74,10 @@ class OnetBaseIE(InfoExtractor):
 
         meta = video.get('meta', {})
 
-        title = self._og_search_title(webpage, default=None) or meta['title']
-        description = self._og_search_description(webpage, default=None) or meta.get('description')
+        title = (self._og_search_title(
+            webpage, default=None) if webpage else None) or meta['title']
+        description = (self._og_search_description(
+            webpage, default=None) if webpage else None) or meta.get('description')
         duration = meta.get('length') or meta.get('lenght')
         timestamp = parse_iso8601(meta.get('addDate'), ' ')
 
@@ -89,6 +91,18 @@ class OnetBaseIE(InfoExtractor):
         }
 
 
+class OnetMVPIE(OnetBaseIE):
+    _VALID_URL = r'onetmvp:(?P<id>\d+\.\d+)'
+
+    _TEST = {
+        'url': 'onetmvp:381027.1509591944',
+        'only_matching': True,
+    }
+
+    def _real_extract(self, url):
+        return self._extract_from_id(self._match_id(url))
+
+
 class OnetIE(OnetBaseIE):
     _VALID_URL = r'https?://(?:www\.)?onet\.tv/[a-z]/[a-z]+/(?P<display_id>[0-9a-z-]+)/(?P<id>[0-9a-z]+)'
     IE_NAME = 'onet.tv'