]> gitweb @ CieloNegro.org - youtube-dl.git/commitdiff
[generic] Fix URL concatenation
authorPhilipp Hagemeister <phihag@phihag.de>
Wed, 28 Aug 2013 10:04:44 +0000 (12:04 +0200)
committerPhilipp Hagemeister <phihag@phihag.de>
Wed, 28 Aug 2013 10:08:17 +0000 (12:08 +0200)
When the url is something like http://example.org/foo/bar?x=y  and the added is file/video.mp4 , we want http://example.org/foo/file/video.mp4
Fixes #1268.

youtube_dl/extractor/generic.py

index d034a11bbc3c4cf7ad50edf19776b211296e8d60..bfc9bff493af635560469e37ba146f58b29c3c90 100644 (file)
@@ -166,7 +166,12 @@ class GenericIE(InfoExtractor):
         if video_url.startswith('//'):
             video_url = compat_urllib_parse_urlparse(url).scheme + ':' + video_url
         if '://' not in video_url:
-            video_url = url + ('' if url.endswith('/') else '/') + video_url
+            up = compat_urllib_parse_urlparse(url)
+            if video_url.startswith('/'):
+                video_url = up.scheme + '://' + up.netloc + video_url
+            else:  # relative path
+                video_url = (up.scheme + '://' + up.netloc +
+                             up.path.rpartition('/')[0] + '/' + video_url)
         video_id = os.path.basename(video_url)
 
         # here's a fun little line of code for you: