aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/utils.py
diff options
context:
space:
mode:
authorSergey M․ <dstftw@gmail.com>2015-11-20 20:33:49 +0600
committerSergey M․ <dstftw@gmail.com>2015-11-23 21:55:15 +0600
commit67dda51722f1ce12b956782d43047b3fff390115 (patch)
treeffa0aa90945651ce8ca8ab102095797d8ada5bc8 /youtube_dl/utils.py
parente4c4bcf36f4e0bb575526701f852152f4fd976c4 (diff)
Rename compat_urllib_request_Request to sanitized_Request and move to utils
Diffstat (limited to 'youtube_dl/utils.py')
-rw-r--r--youtube_dl/utils.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py
index c0325f054..d7b737e21 100644
--- a/youtube_dl/utils.py
+++ b/youtube_dl/utils.py
@@ -373,6 +373,13 @@ 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 sanitized_Request(url, *args, **kwargs):
+ return compat_urllib_request.Request(
+ 'http:%s' % url if url.startswith('//') else url, *args, **kwargs)
+
+
def orderedSet(iterable):
""" Remove all duplicates from the input iterable """
res = []