projects
/
youtube-dl
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
b5a5bbf
)
[utils] Extract sanitize_url routine
author
Sergey M․
<dstftw@gmail.com>
Sat, 26 Mar 2016 13:33:57 +0000
(19:33 +0600)
committer
Sergey M․
<dstftw@gmail.com>
Sat, 26 Mar 2016 13:33:57 +0000
(19:33 +0600)
youtube_dl/utils.py
patch
|
blob
|
history
diff --git
a/youtube_dl/utils.py
b/youtube_dl/utils.py
index eacd81bf9ad3c733c578ace81cd7bf03ebff4725..6d27b80c02912b01b7f64ef85f20097f8216abe4 100644
(file)
--- a/
youtube_dl/utils.py
+++ b/
youtube_dl/utils.py
@@
-417,9
+417,12
@@
def sanitize_path(s):
# Prepend protocol-less URLs with `http:` scheme in order to mitigate the number of
# unwanted failures due to missing protocol
# 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
+
+
def sanitized_Request(url, *args, **kwargs):
def sanitized_Request(url, *args, **kwargs):
- return compat_urllib_request.Request(
- 'http:%s' % url if url.startswith('//') else url, *args, **kwargs)
+ return compat_urllib_request.Request(sanitize_url(url), *args, **kwargs)
def orderedSet(iterable):
def orderedSet(iterable):