[utils] Remove url_infer_protocol
authorYen Chi Hsuan <yan12125@gmail.com>
Wed, 8 Apr 2015 13:39:34 +0000 (21:39 +0800)
committerYen Chi Hsuan <yan12125@gmail.com>
Wed, 8 Apr 2015 13:39:34 +0000 (21:39 +0800)
test/test_utils.py
youtube_dl/extractor/generic.py
youtube_dl/extractor/udn.py
youtube_dl/utils.py

index 8291edd9a3df875cb1bc6d50b15317daf314a05a..2e3a6480cb15e3c762fa68533d6dad988740a6c4 100644 (file)
@@ -53,7 +53,6 @@ from youtube_dl.utils import (
     uppercase_escape,
     url_basename,
     urlencode_postdata,
-    url_infer_protocol,
     version_tuple,
     xpath_with_ns,
     xpath_text,
@@ -297,10 +296,6 @@ class TestUtil(unittest.TestCase):
             url_basename('http://media.w3.org/2010/05/sintel/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):
         self.assertEqual(parse_duration(None), None)
         self.assertEqual(parse_duration(False), None)
index 9178d2b7b8689976dd156ca1e95ede2068232a6f..6c212efac4b0f5869f93e37a5c34b42dbe2ca88a 100644 (file)
@@ -26,7 +26,6 @@ from ..utils import (
     unsmuggle_url,
     UnsupportedError,
     url_basename,
-    url_infer_protocol,
     xpath_text,
 )
 from .brightcove import BrightcoveIE
@@ -1286,7 +1285,7 @@ class GenericIE(InfoExtractor):
             r'<iframe[^>]+src="(?P<url>%s)"' % UDNEmbedIE._VALID_URL, webpage)
         if mobj is not None:
             return self.url_result(
-                url_infer_protocol(url, mobj.group('url')), 'UDNEmbed')
+                compat_urlparse.urljoin(url, mobj.group('url')), 'UDNEmbed')
 
         def check_video(vurl):
             if YoutubeIE.suitable(vurl):
index 2b9a733e8d95507d15eeefafe151dc14538fb859..bba25bb58041ddca902749d32c72ca3ad3d619a1 100644 (file)
@@ -3,10 +3,8 @@ from __future__ import unicode_literals
 
 import json
 from .common import InfoExtractor
-from ..utils import (
-    url_infer_protocol,
-    js_to_json
-)
+from ..utils import js_to_json
+from ..compat import compat_urlparse
 
 
 class UDNEmbedIE(InfoExtractor):
@@ -45,7 +43,7 @@ class UDNEmbedIE(InfoExtractor):
 
         formats = [{
             '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),
             'format_id': video_type,
             'preference': 0 if video_type == 'mp4' else -1,
index f3b8d9f81f75f77de7e24ad7f4e125bd657adeca..52f0dd09aac2ef0103212086a280fc317b36b82d 100644 (file)
@@ -1711,17 +1711,6 @@ def determine_protocol(info_dict):
     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):
     """ Render a list of rows, each as a list of values """
     table = [header_row] + data