projects
/
youtube-dl
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Using internal opener
[youtube-dl]
/
youtube_dl
/
YoutubeDL.py
diff --git
a/youtube_dl/YoutubeDL.py
b/youtube_dl/YoutubeDL.py
index d65253882feed92b941fe3d791626a9a43e852a4..1783ce01bf683ab0cfa349a1b040362f88cc1a47 100755
(executable)
--- a/
youtube_dl/YoutubeDL.py
+++ b/
youtube_dl/YoutubeDL.py
@@
-37,6
+37,7
@@
from .compat import (
compat_tokenize_tokenize,
compat_urllib_error,
compat_urllib_request,
compat_tokenize_tokenize,
compat_urllib_error,
compat_urllib_request,
+ compat_urllib_request_DataHandler,
)
from .utils import (
ContentTooShortError,
)
from .utils import (
ContentTooShortError,
@@
-571,7
+572,7
@@
class YoutubeDL(object):
if v is not None)
template_dict = collections.defaultdict(lambda: 'NA', template_dict)
if v is not None)
template_dict = collections.defaultdict(lambda: 'NA', template_dict)
- outtmpl = s
anitize_path(self.params.get('outtmpl', DEFAULT_OUTTMPL)
)
+ outtmpl = s
elf.params.get('outtmpl', DEFAULT_OUTTMPL
)
tmpl = compat_expanduser(outtmpl)
filename = tmpl % template_dict
# Temporary fix for #4787
tmpl = compat_expanduser(outtmpl)
filename = tmpl % template_dict
# Temporary fix for #4787
@@
-579,7
+580,7
@@
class YoutubeDL(object):
# to workaround encoding issues with subprocess on python2 @ Windows
if sys.version_info < (3, 0) and sys.platform == 'win32':
filename = encodeFilename(filename, True).decode(preferredencoding())
# to workaround encoding issues with subprocess on python2 @ Windows
if sys.version_info < (3, 0) and sys.platform == 'win32':
filename = encodeFilename(filename, True).decode(preferredencoding())
- return
filename
+ return
sanitize_path(filename)
except ValueError as err:
self.report_error('Error in output template: ' + str(err) + ' (encoding: ' + repr(preferredencoding()) + ')')
return None
except ValueError as err:
self.report_error('Error in output template: ' + str(err) + ' (encoding: ' + repr(preferredencoding()) + ')')
return None
@@
-1232,13
+1233,20
@@
class YoutubeDL(object):
except (ValueError, OverflowError, OSError):
pass
except (ValueError, OverflowError, OSError):
pass
+ subtitles = info_dict.get('subtitles')
+ if subtitles:
+ for _, subtitle in subtitles.items():
+ for subtitle_format in subtitle:
+ if 'ext' not in subtitle_format:
+ subtitle_format['ext'] = determine_ext(subtitle_format['url']).lower()
+
if self.params.get('listsubtitles', False):
if 'automatic_captions' in info_dict:
self.list_subtitles(info_dict['id'], info_dict.get('automatic_captions'), 'automatic captions')
if self.params.get('listsubtitles', False):
if 'automatic_captions' in info_dict:
self.list_subtitles(info_dict['id'], info_dict.get('automatic_captions'), 'automatic captions')
- self.list_subtitles(info_dict['id'],
info_dict.get('subtitles')
, 'subtitles')
+ self.list_subtitles(info_dict['id'],
subtitles
, 'subtitles')
return
info_dict['requested_subtitles'] = self.process_subtitles(
return
info_dict['requested_subtitles'] = self.process_subtitles(
- info_dict['id'],
info_dict.get('subtitles')
,
+ info_dict['id'],
subtitles
,
info_dict.get('automatic_captions'))
# We now pick which formats have to be downloaded
info_dict.get('automatic_captions'))
# We now pick which formats have to be downloaded
@@
-1960,8
+1968,9
@@
class YoutubeDL(object):
debuglevel = 1 if self.params.get('debug_printtraffic') else 0
https_handler = make_HTTPS_handler(self.params, debuglevel=debuglevel)
ydlh = YoutubeDLHandler(self.params, debuglevel=debuglevel)
debuglevel = 1 if self.params.get('debug_printtraffic') else 0
https_handler = make_HTTPS_handler(self.params, debuglevel=debuglevel)
ydlh = YoutubeDLHandler(self.params, debuglevel=debuglevel)
+ data_handler = compat_urllib_request_DataHandler()
opener = compat_urllib_request.build_opener(
opener = compat_urllib_request.build_opener(
- proxy_handler, https_handler, cookie_processor, ydlh)
+ proxy_handler, https_handler, cookie_processor, ydlh
, data_handler
)
# Delete the default user-agent header, which would otherwise apply in
# cases where our custom HTTP handler doesn't come into play
# Delete the default user-agent header, which would otherwise apply in
# cases where our custom HTTP handler doesn't come into play