mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-11-26 04:02:11 +00:00
[utils] Remove url_infer_protocol
This commit is contained in:
parent
a662163fd5
commit
0a1603634b
4 changed files with 4 additions and 23 deletions
|
@ -53,7 +53,6 @@ from youtube_dl.utils import (
|
||||||
uppercase_escape,
|
uppercase_escape,
|
||||||
url_basename,
|
url_basename,
|
||||||
urlencode_postdata,
|
urlencode_postdata,
|
||||||
url_infer_protocol,
|
|
||||||
version_tuple,
|
version_tuple,
|
||||||
xpath_with_ns,
|
xpath_with_ns,
|
||||||
xpath_text,
|
xpath_text,
|
||||||
|
@ -297,10 +296,6 @@ class TestUtil(unittest.TestCase):
|
||||||
url_basename('http://media.w3.org/2010/05/sintel/trailer.mp4'),
|
url_basename('http://media.w3.org/2010/05/sintel/trailer.mp4'),
|
||||||
'trailer.mp4')
|
'trailer.mp4')
|
||||||
|
|
||||||
def test_url_infer_protocol(self):
|
|
||||||
self.assertEqual(url_infer_protocol('http://foo.com/', '//bar.com/'), 'http://bar.com/')
|
|
||||||
self.assertEqual(url_infer_protocol('http://foo.com/', 'https://bar.com/'), 'https://bar.com/')
|
|
||||||
|
|
||||||
def test_parse_duration(self):
|
def test_parse_duration(self):
|
||||||
self.assertEqual(parse_duration(None), None)
|
self.assertEqual(parse_duration(None), None)
|
||||||
self.assertEqual(parse_duration(False), None)
|
self.assertEqual(parse_duration(False), None)
|
||||||
|
|
|
@ -26,7 +26,6 @@ from ..utils import (
|
||||||
unsmuggle_url,
|
unsmuggle_url,
|
||||||
UnsupportedError,
|
UnsupportedError,
|
||||||
url_basename,
|
url_basename,
|
||||||
url_infer_protocol,
|
|
||||||
xpath_text,
|
xpath_text,
|
||||||
)
|
)
|
||||||
from .brightcove import BrightcoveIE
|
from .brightcove import BrightcoveIE
|
||||||
|
@ -1286,7 +1285,7 @@ class GenericIE(InfoExtractor):
|
||||||
r'<iframe[^>]+src="(?P<url>%s)"' % UDNEmbedIE._VALID_URL, webpage)
|
r'<iframe[^>]+src="(?P<url>%s)"' % UDNEmbedIE._VALID_URL, webpage)
|
||||||
if mobj is not None:
|
if mobj is not None:
|
||||||
return self.url_result(
|
return self.url_result(
|
||||||
url_infer_protocol(url, mobj.group('url')), 'UDNEmbed')
|
compat_urlparse.urljoin(url, mobj.group('url')), 'UDNEmbed')
|
||||||
|
|
||||||
def check_video(vurl):
|
def check_video(vurl):
|
||||||
if YoutubeIE.suitable(vurl):
|
if YoutubeIE.suitable(vurl):
|
||||||
|
|
|
@ -3,10 +3,8 @@ from __future__ import unicode_literals
|
||||||
|
|
||||||
import json
|
import json
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import (
|
from ..utils import js_to_json
|
||||||
url_infer_protocol,
|
from ..compat import compat_urlparse
|
||||||
js_to_json
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class UDNEmbedIE(InfoExtractor):
|
class UDNEmbedIE(InfoExtractor):
|
||||||
|
@ -45,7 +43,7 @@ class UDNEmbedIE(InfoExtractor):
|
||||||
|
|
||||||
formats = [{
|
formats = [{
|
||||||
'url': self._download_webpage(
|
'url': self._download_webpage(
|
||||||
url_infer_protocol(url, api_url), video_id,
|
compat_urlparse.urljoin(url, api_url), video_id,
|
||||||
'retrieve url for %s video' % video_type),
|
'retrieve url for %s video' % video_type),
|
||||||
'format_id': video_type,
|
'format_id': video_type,
|
||||||
'preference': 0 if video_type == 'mp4' else -1,
|
'preference': 0 if video_type == 'mp4' else -1,
|
||||||
|
|
|
@ -1711,17 +1711,6 @@ def determine_protocol(info_dict):
|
||||||
return compat_urllib_parse_urlparse(url).scheme
|
return compat_urllib_parse_urlparse(url).scheme
|
||||||
|
|
||||||
|
|
||||||
def url_infer_protocol(ref_url, target_url):
|
|
||||||
""" Infer protocol for protocol independent target urls """
|
|
||||||
parsed_target_url = list(compat_urllib_parse_urlparse(target_url))
|
|
||||||
if parsed_target_url[0]:
|
|
||||||
return target_url
|
|
||||||
|
|
||||||
parsed_target_url[0] = compat_urllib_parse_urlparse(ref_url).scheme
|
|
||||||
|
|
||||||
return compat_urlparse.urlunparse(parsed_target_url)
|
|
||||||
|
|
||||||
|
|
||||||
def render_table(header_row, data):
|
def render_table(header_row, data):
|
||||||
""" Render a list of rows, each as a list of values """
|
""" Render a list of rows, each as a list of values """
|
||||||
table = [header_row] + data
|
table = [header_row] + data
|
||||||
|
|
Loading…
Reference in a new issue