mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-23 21:26:55 +01:00
Fix for formats=None
Fixes: https://github.com/yt-dlp/yt-dlp/pull/4965#issuecomment-1267682512
This commit is contained in:
parent
bf2e1ec67a
commit
aebb4f4ba7
@ -2525,11 +2525,7 @@ def sanitize_numeric_fields(info):
|
|||||||
info_dict['requested_subtitles'] = self.process_subtitles(
|
info_dict['requested_subtitles'] = self.process_subtitles(
|
||||||
info_dict['id'], subtitles, automatic_captions)
|
info_dict['id'], subtitles, automatic_captions)
|
||||||
|
|
||||||
if info_dict.get('formats') is None:
|
formats = self._get_formats(info_dict)
|
||||||
# There's only one format available
|
|
||||||
formats = [info_dict]
|
|
||||||
else:
|
|
||||||
formats = info_dict['formats']
|
|
||||||
|
|
||||||
# or None ensures --clean-infojson removes it
|
# or None ensures --clean-infojson removes it
|
||||||
info_dict['_has_drm'] = any(f.get('has_drm') for f in formats) or None
|
info_dict['_has_drm'] = any(f.get('has_drm') for f in formats) or None
|
||||||
@ -2644,7 +2640,7 @@ def is_wellformed(f):
|
|||||||
info_dict, _ = self.pre_process(info_dict, 'after_filter')
|
info_dict, _ = self.pre_process(info_dict, 'after_filter')
|
||||||
|
|
||||||
# The pre-processors may have modified the formats
|
# The pre-processors may have modified the formats
|
||||||
formats = info_dict.get('formats', [info_dict])
|
formats = self._get_formats(info_dict)
|
||||||
|
|
||||||
list_only = self.params.get('simulate') is None and (
|
list_only = self.params.get('simulate') is None and (
|
||||||
self.params.get('list_thumbnails') or self.params.get('listformats') or self.params.get('listsubtitles'))
|
self.params.get('list_thumbnails') or self.params.get('listformats') or self.params.get('listsubtitles'))
|
||||||
@ -3571,11 +3567,17 @@ def _format_note(self, fdict):
|
|||||||
res += '~' + format_bytes(fdict['filesize_approx'])
|
res += '~' + format_bytes(fdict['filesize_approx'])
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def render_formats_table(self, info_dict):
|
def _get_formats(self, info_dict):
|
||||||
if not info_dict.get('formats') and not info_dict.get('url'):
|
if info_dict.get('formats') is None:
|
||||||
return None
|
if info_dict.get('url') and info_dict.get('_type', 'video') == 'video':
|
||||||
|
return [info_dict]
|
||||||
|
return []
|
||||||
|
return info_dict['formats']
|
||||||
|
|
||||||
formats = info_dict.get('formats', [info_dict])
|
def render_formats_table(self, info_dict):
|
||||||
|
formats = self._get_formats(info_dict)
|
||||||
|
if not formats:
|
||||||
|
return
|
||||||
if not self.params.get('listformats_table', True) is not False:
|
if not self.params.get('listformats_table', True) is not False:
|
||||||
table = [
|
table = [
|
||||||
[
|
[
|
||||||
|
Loading…
Reference in New Issue
Block a user