projects
/
youtube-dl
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[downloader/f4m] Simply select format when it's the only one
[youtube-dl]
/
youtube_dl
/
utils.py
diff --git
a/youtube_dl/utils.py
b/youtube_dl/utils.py
index 24e74428b03b4a532aeadd0a0292bb8023d17473..cfb2d1bf5c03c59c94d777acbc8729e6b7de6556 100644
(file)
--- a/
youtube_dl/utils.py
+++ b/
youtube_dl/utils.py
@@
-883,12
+883,17
@@
def make_socks_conn_class(base_class, socks_proxy):
elif url_components.scheme.lower() == 'socks4a':
socks_type = ProxyType.SOCKS4A
elif url_components.scheme.lower() == 'socks4a':
socks_type = ProxyType.SOCKS4A
+ def unquote_if_non_empty(s):
+ if not s:
+ return s
+ return compat_urllib_parse_unquote_plus(s)
+
proxy_args = (
socks_type,
url_components.hostname, url_components.port or 1080,
True, # Remote DNS
proxy_args = (
socks_type,
url_components.hostname, url_components.port or 1080,
True, # Remote DNS
-
compat_urllib_parse_unquote_plus
(url_components.username),
-
compat_urllib_parse_unquote_plus
(url_components.password),
+
unquote_if_non_empty
(url_components.username),
+
unquote_if_non_empty
(url_components.password),
)
class SocksConnection(base_class):
)
class SocksConnection(base_class):
@@
-1030,6
+1035,7
@@
def unified_strdate(date_str, day_first=True):
format_expressions.extend([
'%d-%m-%Y',
'%d.%m.%Y',
format_expressions.extend([
'%d-%m-%Y',
'%d.%m.%Y',
+ '%d.%m.%y',
'%d/%m/%Y',
'%d/%m/%y',
'%d/%m/%Y %H:%M:%S',
'%d/%m/%Y',
'%d/%m/%y',
'%d/%m/%Y %H:%M:%S',
@@
-1050,7
+1056,10
@@
def unified_strdate(date_str, day_first=True):
if upload_date is None:
timetuple = email.utils.parsedate_tz(date_str)
if timetuple:
if upload_date is None:
timetuple = email.utils.parsedate_tz(date_str)
if timetuple:
- upload_date = datetime.datetime(*timetuple[:6]).strftime('%Y%m%d')
+ try:
+ upload_date = datetime.datetime(*timetuple[:6]).strftime('%Y%m%d')
+ except ValueError:
+ pass
if upload_date is not None:
return compat_str(upload_date)
if upload_date is not None:
return compat_str(upload_date)
@@
-1544,15
+1553,11
@@
def setproctitle(title):
def remove_start(s, start):
def remove_start(s, start):
- if s.startswith(start):
- return s[len(start):]
- return s
+ return s[len(start):] if s is not None and s.startswith(start) else s
def remove_end(s, end):
def remove_end(s, end):
- if s.endswith(end):
- return s[:-len(end)]
- return s
+ return s[:-len(end)] if s is not None and s.endswith(end) else s
def remove_quotes(s):
def remove_quotes(s):
@@
-1906,7
+1911,7
@@
def parse_age_limit(s):
def strip_jsonp(code):
return re.sub(
def strip_jsonp(code):
return re.sub(
- r'(?s)^[a-zA-Z0-9_.]+\s*\(\s*(.*)\);?\s*?(?://[^\n]*)*$', r'\1', code)
+ r'(?s)^[a-zA-Z0-9_.
$
]+\s*\(\s*(.*)\);?\s*?(?://[^\n]*)*$', r'\1', code)
def js_to_json(code):
def js_to_json(code):