mirror of
https://codeberg.org/polarisfm/youtube-dl
synced 2024-11-23 00:54:31 +01:00
Refactor code to use url_result
This commit is contained in:
parent
8437f5089f
commit
d226c560a6
@ -62,7 +62,7 @@ class AudiomackIE(InfoExtractor):
|
|||||||
# Audiomack wraps a lot of soundcloud tracks in their branded wrapper
|
# Audiomack wraps a lot of soundcloud tracks in their branded wrapper
|
||||||
# if so, pass the work off to the soundcloud extractor
|
# if so, pass the work off to the soundcloud extractor
|
||||||
if SoundcloudIE.suitable(api_response['url']):
|
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 {
|
return {
|
||||||
'id': compat_str(api_response.get('id', album_url_tag)),
|
'id': compat_str(api_response.get('id', album_url_tag)),
|
||||||
|
@ -119,11 +119,7 @@ class CNNBlogsIE(InfoExtractor):
|
|||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
webpage = self._download_webpage(url, url_basename(url))
|
webpage = self._download_webpage(url, url_basename(url))
|
||||||
cnn_url = self._html_search_regex(r'data-url="(.+?)"', webpage, 'cnn url')
|
cnn_url = self._html_search_regex(r'data-url="(.+?)"', webpage, 'cnn url')
|
||||||
return {
|
return self.url_result(cnn_url, CNNIE.ie_key())
|
||||||
'_type': 'url',
|
|
||||||
'url': cnn_url,
|
|
||||||
'ie_key': CNNIE.ie_key(),
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class CNNArticleIE(InfoExtractor):
|
class CNNArticleIE(InfoExtractor):
|
||||||
@ -145,8 +141,4 @@ class CNNArticleIE(InfoExtractor):
|
|||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
webpage = self._download_webpage(url, url_basename(url))
|
webpage = self._download_webpage(url, url_basename(url))
|
||||||
cnn_url = self._html_search_regex(r"video:\s*'([^']+)'", webpage, 'cnn url')
|
cnn_url = self._html_search_regex(r"video:\s*'([^']+)'", webpage, 'cnn url')
|
||||||
return {
|
return self.url_result('http://cnn.com/video/?/video/' + cnn_url, CNNIE.ie_key())
|
||||||
'_type': 'url',
|
|
||||||
'url': 'http://cnn.com/video/?/video/' + cnn_url,
|
|
||||||
'ie_key': CNNIE.ie_key(),
|
|
||||||
}
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
|
from .youtube import YoutubeIE
|
||||||
|
|
||||||
|
|
||||||
class FreespeechIE(InfoExtractor):
|
class FreespeechIE(InfoExtractor):
|
||||||
@ -27,8 +28,4 @@ class FreespeechIE(InfoExtractor):
|
|||||||
r'data-video-url="([^"]+)"',
|
r'data-video-url="([^"]+)"',
|
||||||
webpage, 'youtube url')
|
webpage, 'youtube url')
|
||||||
|
|
||||||
return {
|
return self.url_result(youtube_url, YoutubeIE.ie_key())
|
||||||
'_type': 'url',
|
|
||||||
'url': youtube_url,
|
|
||||||
'ie_key': 'Youtube',
|
|
||||||
}
|
|
||||||
|
@ -2197,10 +2197,7 @@ class GenericIE(InfoExtractor):
|
|||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
if url.startswith('//'):
|
if url.startswith('//'):
|
||||||
return {
|
return self.url_result(self.http_scheme() + url)
|
||||||
'_type': 'url',
|
|
||||||
'url': self.http_scheme() + url,
|
|
||||||
}
|
|
||||||
|
|
||||||
parsed_url = compat_urlparse.urlparse(url)
|
parsed_url = compat_urlparse.urlparse(url)
|
||||||
if not parsed_url.scheme:
|
if not parsed_url.scheme:
|
||||||
|
@ -363,7 +363,4 @@ class LivestreamShortenerIE(InfoExtractor):
|
|||||||
id = mobj.group('id')
|
id = mobj.group('id')
|
||||||
webpage = self._download_webpage(url, id)
|
webpage = self._download_webpage(url, id)
|
||||||
|
|
||||||
return {
|
return self.url_result(self._og_search_url(webpage))
|
||||||
'_type': 'url',
|
|
||||||
'url': self._og_search_url(webpage),
|
|
||||||
}
|
|
||||||
|
@ -30,8 +30,5 @@ class SaveFromIE(InfoExtractor):
|
|||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
mobj = re.match(self._VALID_URL, url)
|
mobj = re.match(self._VALID_URL, url)
|
||||||
video_id = os.path.splitext(url.split('/')[-1])[0]
|
video_id = os.path.splitext(url.split('/')[-1])[0]
|
||||||
return {
|
|
||||||
'_type': 'url',
|
return self.url_result(mobj.group('url'), video_id=video_id)
|
||||||
'id': video_id,
|
|
||||||
'url': mobj.group('url'),
|
|
||||||
}
|
|
||||||
|
@ -203,10 +203,8 @@ class TEDIE(InfoExtractor):
|
|||||||
ext_url = None
|
ext_url = None
|
||||||
if service.lower() == 'youtube':
|
if service.lower() == 'youtube':
|
||||||
ext_url = external.get('code')
|
ext_url = external.get('code')
|
||||||
return {
|
|
||||||
'_type': 'url',
|
return self.url_result(ext_url or external['uri'])
|
||||||
'url': ext_url or external['uri'],
|
|
||||||
}
|
|
||||||
|
|
||||||
resources_ = player_talk.get('resources') or talk_info.get('resources')
|
resources_ = player_talk.get('resources') or talk_info.get('resources')
|
||||||
|
|
||||||
|
@ -61,8 +61,4 @@ class TestURLIE(InfoExtractor):
|
|||||||
|
|
||||||
self.to_screen('Test URL: %s' % tc['url'])
|
self.to_screen('Test URL: %s' % tc['url'])
|
||||||
|
|
||||||
return {
|
return self.url_result(tc['url'], video_id=video_id)
|
||||||
'_type': 'url',
|
|
||||||
'url': tc['url'],
|
|
||||||
'id': video_id,
|
|
||||||
}
|
|
||||||
|
@ -40,11 +40,7 @@ class WimpIE(InfoExtractor):
|
|||||||
r'data-id=["\']([0-9A-Za-z_-]{11})'),
|
r'data-id=["\']([0-9A-Za-z_-]{11})'),
|
||||||
webpage, 'video URL', default=None)
|
webpage, 'video URL', default=None)
|
||||||
if youtube_id:
|
if youtube_id:
|
||||||
return {
|
return self.url_result(youtube_id, YoutubeIE.ie_key())
|
||||||
'_type': 'url',
|
|
||||||
'url': youtube_id,
|
|
||||||
'ie_key': YoutubeIE.ie_key(),
|
|
||||||
}
|
|
||||||
|
|
||||||
info_dict = self._extract_jwplayer_data(
|
info_dict = self._extract_jwplayer_data(
|
||||||
webpage, video_id, require_title=False)
|
webpage, video_id, require_title=False)
|
||||||
|
Loading…
Reference in New Issue
Block a user