Refactor code to use url_result
authorElan Ruusamäe <glen@pld-linux.org>
Tue, 1 Jan 2019 16:56:05 +0000 (18:56 +0200)
committerSergey M <dstftw@gmail.com>
Tue, 1 Jan 2019 16:56:05 +0000 (23:56 +0700)
youtube_dl/extractor/audiomack.py
youtube_dl/extractor/cnn.py
youtube_dl/extractor/freespeech.py
youtube_dl/extractor/generic.py
youtube_dl/extractor/livestream.py
youtube_dl/extractor/savefrom.py
youtube_dl/extractor/ted.py
youtube_dl/extractor/testurl.py
youtube_dl/extractor/wimp.py

index 62049b921089d4a10cc9f71b625540f82ea7e3b6..cc7771354c10b39778f0b2dcad55052db42066b3 100644 (file)
@@ -62,7 +62,7 @@ class AudiomackIE(InfoExtractor):
         # Audiomack wraps a lot of soundcloud tracks in their branded wrapper
         # if so, pass the work off to the soundcloud extractor
         if SoundcloudIE.suitable(api_response['url']):
-            return {'_type': 'url', 'url': api_response['url'], 'ie_key': 'Soundcloud'}
+            return self.url_result(api_response['url'], SoundcloudIE.ie_key())
 
         return {
             'id': compat_str(api_response.get('id', album_url_tag)),
index 5fc311f538eb23b0b16e99f6c5623f0db4290b40..774b7105580f69dedac4318c82aee2ab62c27381 100644 (file)
@@ -119,11 +119,7 @@ class CNNBlogsIE(InfoExtractor):
     def _real_extract(self, url):
         webpage = self._download_webpage(url, url_basename(url))
         cnn_url = self._html_search_regex(r'data-url="(.+?)"', webpage, 'cnn url')
-        return {
-            '_type': 'url',
-            'url': cnn_url,
-            'ie_key': CNNIE.ie_key(),
-        }
+        return self.url_result(cnn_url, CNNIE.ie_key())
 
 
 class CNNArticleIE(InfoExtractor):
@@ -145,8 +141,4 @@ class CNNArticleIE(InfoExtractor):
     def _real_extract(self, url):
         webpage = self._download_webpage(url, url_basename(url))
         cnn_url = self._html_search_regex(r"video:\s*'([^']+)'", webpage, 'cnn url')
-        return {
-            '_type': 'url',
-            'url': 'http://cnn.com/video/?/video/' + cnn_url,
-            'ie_key': CNNIE.ie_key(),
-        }
+        return self.url_result('http://cnn.com/video/?/video/' + cnn_url, CNNIE.ie_key())
index 486a49c05271c37280b059fb3a6c6bb4fd0de3ed..ea9c3e317ce5c162bfb7d46691f65ba3cd38ceb8 100644 (file)
@@ -1,6 +1,7 @@
 from __future__ import unicode_literals
 
 from .common import InfoExtractor
+from .youtube import YoutubeIE
 
 
 class FreespeechIE(InfoExtractor):
@@ -27,8 +28,4 @@ class FreespeechIE(InfoExtractor):
             r'data-video-url="([^"]+)"',
             webpage, 'youtube url')
 
-        return {
-            '_type': 'url',
-            'url': youtube_url,
-            'ie_key': 'Youtube',
-        }
+        return self.url_result(youtube_url, YoutubeIE.ie_key())
index 65b4823338b4f8ad9662f0289a865798acf0bc8b..067de28cd16b83f20717aca02f77e25051ac222d 100644 (file)
@@ -2197,10 +2197,7 @@ class GenericIE(InfoExtractor):
 
     def _real_extract(self, url):
         if url.startswith('//'):
-            return {
-                '_type': 'url',
-                'url': self.http_scheme() + url,
-            }
+            return self.url_result(self.http_scheme() + url)
 
         parsed_url = compat_urlparse.urlparse(url)
         if not parsed_url.scheme:
index c4776bbf3b5aa590e2b014b4d23e55f0de569cc6..e55b1a202426026763375880b549180efbd52a42 100644 (file)
@@ -363,7 +363,4 @@ class LivestreamShortenerIE(InfoExtractor):
         id = mobj.group('id')
         webpage = self._download_webpage(url, id)
 
-        return {
-            '_type': 'url',
-            'url': self._og_search_url(webpage),
-        }
+        return self.url_result(self._og_search_url(webpage))
index 30f9cf8245856398239e88e5e8454c1df4bd8c3f..21e44b69abaf555abbb1faa9195779e80c44fda9 100644 (file)
@@ -30,8 +30,5 @@ class SaveFromIE(InfoExtractor):
     def _real_extract(self, url):
         mobj = re.match(self._VALID_URL, url)
         video_id = os.path.splitext(url.split('/')[-1])[0]
-        return {
-            '_type': 'url',
-            'id': video_id,
-            'url': mobj.group('url'),
-        }
+
+        return self.url_result(mobj.group('url'), video_id=video_id)
index f9b6aa48f03d3b3a8cf49f80573eb9d24d115384..d3e4205f50472d8ea0a485f25a146e97be558aff 100644 (file)
@@ -203,10 +203,8 @@ class TEDIE(InfoExtractor):
                 ext_url = None
                 if service.lower() == 'youtube':
                     ext_url = external.get('code')
-                return {
-                    '_type': 'url',
-                    'url': ext_url or external['uri'],
-                }
+
+                return self.url_result(ext_url or external['uri'])
 
         resources_ = player_talk.get('resources') or talk_info.get('resources')
 
index 46918adb05fc77d45b480b138575afff9d69a086..84a14a0bdead5b96a47784da9c205231292c826b 100644 (file)
@@ -61,8 +61,4 @@ class TestURLIE(InfoExtractor):
 
         self.to_screen('Test URL: %s' % tc['url'])
 
-        return {
-            '_type': 'url',
-            'url': tc['url'],
-            'id': video_id,
-        }
+        return self.url_result(tc['url'], video_id=video_id)
index 3dab9145ba9c57bfd1d78a90a847761c23f0d8a8..ea234e3c5088f7c7c99e049ab95f1e69542dd38f 100644 (file)
@@ -40,11 +40,7 @@ class WimpIE(InfoExtractor):
              r'data-id=["\']([0-9A-Za-z_-]{11})'),
             webpage, 'video URL', default=None)
         if youtube_id:
-            return {
-                '_type': 'url',
-                'url': youtube_id,
-                'ie_key': YoutubeIE.ie_key(),
-            }
+            return self.url_result(youtube_id, YoutubeIE.ie_key())
 
         info_dict = self._extract_jwplayer_data(
             webpage, video_id, require_title=False)