mirror of
https://github.com/l1ving/youtube-dl
synced 2025-03-07 03:37:17 +08:00
Listen to --default-extension for twitch downloads
This commit is contained in:
parent
e942cfd1a7
commit
c6ab2e6fe1
@ -794,7 +794,7 @@ class YoutubeDL(object):
|
|||||||
'and will probably not work.')
|
'and will probably not work.')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
ie_result = ie.extract(url)
|
ie_result = ie.extract(url, self.params['default_extension'])
|
||||||
if ie_result is None: # Finished already (backwards compatibility; listformats and friends should be moved here)
|
if ie_result is None: # Finished already (backwards compatibility; listformats and friends should be moved here)
|
||||||
break
|
break
|
||||||
if isinstance(ie_result, list):
|
if isinstance(ie_result, list):
|
||||||
@ -1320,10 +1320,13 @@ class YoutubeDL(object):
|
|||||||
'Both formats %s and %s are video-only, you must specify "-f video+audio"'
|
'Both formats %s and %s are video-only, you must specify "-f video+audio"'
|
||||||
% (format_1, format_2))
|
% (format_1, format_2))
|
||||||
return
|
return
|
||||||
output_ext = (
|
if self.params.get('merge_output_format') is None:
|
||||||
formats_info[0]['ext']
|
if self.params.get('default_extension') is None:
|
||||||
if self.params.get('merge_output_format') is None
|
output_ext = formats_info[0]['ext']
|
||||||
else self.params['merge_output_format'])
|
else:
|
||||||
|
output_ext = self.params['default_extension']
|
||||||
|
else:
|
||||||
|
output_ext = self.params['merge_output_format']
|
||||||
return {
|
return {
|
||||||
'requested_formats': formats_info,
|
'requested_formats': formats_info,
|
||||||
'format': '%s+%s' % (formats_info[0].get('format'),
|
'format': '%s+%s' % (formats_info[0].get('format'),
|
||||||
|
@ -410,6 +410,7 @@ def _real_main(argv=None):
|
|||||||
'extract_flat': opts.extract_flat,
|
'extract_flat': opts.extract_flat,
|
||||||
'mark_watched': opts.mark_watched,
|
'mark_watched': opts.mark_watched,
|
||||||
'merge_output_format': opts.merge_output_format,
|
'merge_output_format': opts.merge_output_format,
|
||||||
|
'default_extension': opts.default_extension,
|
||||||
'postprocessors': postprocessors,
|
'postprocessors': postprocessors,
|
||||||
'fixup': opts.fixup,
|
'fixup': opts.fixup,
|
||||||
'source_address': opts.source_address,
|
'source_address': opts.source_address,
|
||||||
|
@ -521,13 +521,13 @@ class InfoExtractor(object):
|
|||||||
'[debug] Using fake IP %s (%s) as X-Forwarded-For.'
|
'[debug] Using fake IP %s (%s) as X-Forwarded-For.'
|
||||||
% (self._x_forwarded_for_ip, country.upper()))
|
% (self._x_forwarded_for_ip, country.upper()))
|
||||||
|
|
||||||
def extract(self, url):
|
def extract(self, url, default_ext='mp4'):
|
||||||
"""Extracts URL information and returns it in list of dicts."""
|
"""Extracts URL information and returns it in list of dicts."""
|
||||||
try:
|
try:
|
||||||
for _ in range(2):
|
for _ in range(2):
|
||||||
try:
|
try:
|
||||||
self.initialize()
|
self.initialize()
|
||||||
ie_result = self._real_extract(url)
|
ie_result = self._real_extract(url, default_ext)
|
||||||
if self._x_forwarded_for_ip:
|
if self._x_forwarded_for_ip:
|
||||||
ie_result['__x_forwarded_for_ip'] = self._x_forwarded_for_ip
|
ie_result['__x_forwarded_for_ip'] = self._x_forwarded_for_ip
|
||||||
return ie_result
|
return ie_result
|
||||||
@ -565,7 +565,7 @@ class InfoExtractor(object):
|
|||||||
"""Real initialization process. Redefine in subclasses."""
|
"""Real initialization process. Redefine in subclasses."""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url, default_ext='mp4'):
|
||||||
"""Real extraction process. Redefine in subclasses."""
|
"""Real extraction process. Redefine in subclasses."""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -222,7 +222,7 @@ class TwitchItemBaseIE(TwitchBaseIE):
|
|||||||
'is_live': is_live,
|
'is_live': is_live,
|
||||||
}
|
}
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url, default_ext):
|
||||||
return self._extract_media(self._match_id(url))
|
return self._extract_media(self._match_id(url))
|
||||||
|
|
||||||
|
|
||||||
@ -332,7 +332,7 @@ class TwitchVodIE(TwitchItemBaseIE):
|
|||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
}]
|
}]
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url, default_ext):
|
||||||
item_id = self._match_id(url)
|
item_id = self._match_id(url)
|
||||||
|
|
||||||
info = self._download_info(self._ITEM_SHORTCUT, item_id)
|
info = self._download_info(self._ITEM_SHORTCUT, item_id)
|
||||||
@ -352,7 +352,7 @@ class TwitchVodIE(TwitchItemBaseIE):
|
|||||||
'nauth': access_token['token'],
|
'nauth': access_token['token'],
|
||||||
'nauthsig': access_token['sig'],
|
'nauthsig': access_token['sig'],
|
||||||
})),
|
})),
|
||||||
item_id, 'mp4', entry_protocol='m3u8_native')
|
item_id, default_ext, entry_protocol='m3u8_native')
|
||||||
|
|
||||||
self._prefer_source(formats)
|
self._prefer_source(formats)
|
||||||
info['formats'] = formats
|
info['formats'] = formats
|
||||||
@ -594,7 +594,7 @@ class TwitchStreamIE(TwitchBaseIE):
|
|||||||
TwitchClipsIE))
|
TwitchClipsIE))
|
||||||
else super(TwitchStreamIE, cls).suitable(url))
|
else super(TwitchStreamIE, cls).suitable(url))
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url, default_ext):
|
||||||
channel_name = self._match_id(url)
|
channel_name = self._match_id(url)
|
||||||
|
|
||||||
access_token = self._call_api(
|
access_token = self._call_api(
|
||||||
@ -634,7 +634,7 @@ class TwitchStreamIE(TwitchBaseIE):
|
|||||||
formats = self._extract_m3u8_formats(
|
formats = self._extract_m3u8_formats(
|
||||||
'%s/api/channel/hls/%s.m3u8?%s'
|
'%s/api/channel/hls/%s.m3u8?%s'
|
||||||
% (self._USHER_BASE, channel_name, compat_urllib_parse_urlencode(query)),
|
% (self._USHER_BASE, channel_name, compat_urllib_parse_urlencode(query)),
|
||||||
channel_id, 'mp4')
|
channel_id, default_ext)
|
||||||
self._prefer_source(formats)
|
self._prefer_source(formats)
|
||||||
|
|
||||||
view_count = stream.get('viewers')
|
view_count = stream.get('viewers')
|
||||||
|
@ -414,6 +414,10 @@ def parseOpts(overrideArguments=None):
|
|||||||
'--youtube-skip-dash-manifest',
|
'--youtube-skip-dash-manifest',
|
||||||
action='store_false', dest='youtube_include_dash_manifest',
|
action='store_false', dest='youtube_include_dash_manifest',
|
||||||
help='Do not download the DASH manifests and related data on YouTube videos')
|
help='Do not download the DASH manifests and related data on YouTube videos')
|
||||||
|
video_format.add_option(
|
||||||
|
'--default-extension',
|
||||||
|
action='store', dest='default_extension', default=None,
|
||||||
|
help='Try providing a different extension to the format processor')
|
||||||
video_format.add_option(
|
video_format.add_option(
|
||||||
'--merge-output-format',
|
'--merge-output-format',
|
||||||
action='store', dest='merge_output_format', metavar='FORMAT', default=None,
|
action='store', dest='merge_output_format', metavar='FORMAT', default=None,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user