aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/utils.py
diff options
context:
space:
mode:
authorSergey M․ <dstftw@gmail.com>2018-02-19 22:50:23 +0700
committerSergey M․ <dstftw@gmail.com>2018-02-19 22:50:23 +0700
commitbefa4708fd2165b85d04002c3845adf191d34302 (patch)
treebe0eaae66b9f4aa11100d12c6c0c6a1e0d18851b /youtube_dl/utils.py
parent90830004c893e2d5f0643c05af064cfc7a3b579e (diff)
[utils] Fixup some common URL's typos in sanitize_url (closes #15649)
Diffstat (limited to 'youtube_dl/utils.py')
-rw-r--r--youtube_dl/utils.py18
1 files changed, 15 insertions, 3 deletions
diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py
index 7f24cbb04..af639a124 100644
--- a/youtube_dl/utils.py
+++ b/youtube_dl/utils.py
@@ -538,10 +538,22 @@ def sanitize_path(s):
return os.path.join(*sanitized_path)
-# Prepend protocol-less URLs with `http:` scheme in order to mitigate the number of
-# unwanted failures due to missing protocol
def sanitize_url(url):
- return 'http:%s' % url if url.startswith('//') else url
+ # Prepend protocol-less URLs with `http:` scheme in order to mitigate
+ # the number of unwanted failures due to missing protocol
+ if url.startswith('//'):
+ return 'http:%s' % url
+ # Fix some common typos seen so far
+ COMMON_TYPOS = (
+ # https://github.com/rg3/youtube-dl/issues/15649
+ (r'^httpss://', r'https://'),
+ # https://bx1.be/lives/direct-tv/
+ (r'^rmtp([es]?)://', r'rtmp\1://'),
+ )
+ for mistake, fixup in COMMON_TYPOS:
+ if re.match(mistake, url):
+ return re.sub(mistake, fixup, url)
+ return url
def sanitized_Request(url, *args, **kwargs):