@ -983,6 +983,7 @@ class YoutubeDL:
ID = ' green ' ,
ID = ' green ' ,
DELIM = ' blue ' ,
DELIM = ' blue ' ,
ERROR = ' red ' ,
ERROR = ' red ' ,
BAD_FORMAT = ' light red ' ,
WARNING = ' yellow ' ,
WARNING = ' yellow ' ,
SUPPRESS = ' light black ' ,
SUPPRESS = ' light black ' ,
)
)
@ -2085,8 +2086,6 @@ class YoutubeDL:
allow_multiple_streams = { ' audio ' : self . params . get ( ' allow_multiple_audio_streams ' , False ) ,
allow_multiple_streams = { ' audio ' : self . params . get ( ' allow_multiple_audio_streams ' , False ) ,
' video ' : self . params . get ( ' allow_multiple_video_streams ' , False ) }
' video ' : self . params . get ( ' allow_multiple_video_streams ' , False ) }
check_formats = self . params . get ( ' check_formats ' ) == ' selected '
def _parse_filter ( tokens ) :
def _parse_filter ( tokens ) :
filter_parts = [ ]
filter_parts = [ ]
for type , string_ , start , _ , _ in tokens :
for type , string_ , start , _ , _ in tokens :
@ -2259,10 +2258,19 @@ class YoutubeDL:
return new_dict
return new_dict
def _check_formats ( formats ) :
def _check_formats ( formats ) :
if not check_formats :
if ( self . params . get ( ' check_formats ' ) is not None
or self . params . get ( ' allow_unplayable_formats ' ) ) :
yield from formats
yield from formats
return
return
elif self . params . get ( ' check_formats ' ) == ' selected ' :
yield from self . _check_formats ( formats )
yield from self . _check_formats ( formats )
return
for f in formats :
if f . get ( ' has_drm ' ) :
yield from self . _check_formats ( [ f ] )
else :
yield f
def _build_selector_function ( selector ) :
def _build_selector_function ( selector ) :
if isinstance ( selector , list ) : # ,
if isinstance ( selector , list ) : # ,
@ -2614,10 +2622,10 @@ class YoutubeDL:
if field_preference :
if field_preference :
info_dict [ ' _format_sort_fields ' ] = field_preference
info_dict [ ' _format_sort_fields ' ] = field_preference
# or None ensures --clean-infojson removes it
info_dict [ ' _has_drm ' ] = any ( # or None ensures --clean-infojson removes it
info_dict [ ' _has_drm ' ] = any ( f . get ( ' has_drm ' ) for f in formats ) or None
f . get ( ' has_drm ' ) and f [ ' has_drm ' ] != ' maybe ' for f in formats ) or None
if not self . params . get ( ' allow_unplayable_formats ' ) :
if not self . params . get ( ' allow_unplayable_formats ' ) :
formats = [ f for f in formats if not f . get ( ' has_drm ' ) ]
formats = [ f for f in formats if not f . get ( ' has_drm ' ) or f [ ' has_drm ' ] == ' maybe ' ]
if formats and all ( f . get ( ' acodec ' ) == f . get ( ' vcodec ' ) == ' none ' for f in formats ) :
if formats and all ( f . get ( ' acodec ' ) == f . get ( ' vcodec ' ) == ' none ' for f in formats ) :
self . report_warning (
self . report_warning (
@ -3719,14 +3727,13 @@ class YoutubeDL:
simplified_codec ( f , ' acodec ' ) ,
simplified_codec ( f , ' acodec ' ) ,
format_field ( f , ' abr ' , ' \t %d k ' , func = round ) ,
format_field ( f , ' abr ' , ' \t %d k ' , func = round ) ,
format_field ( f , ' asr ' , ' \t %s ' , func = format_decimal_suffix ) ,
format_field ( f , ' asr ' , ' \t %s ' , func = format_decimal_suffix ) ,
join_nonempty (
join_nonempty ( format_field ( f , ' language ' , ' [ %s ] ' ) , join_nonempty (
self . _format_out ( ' UNSUPPORTED ' , ' light red ' ) if f . get ( ' ext ' ) in ( ' f4f ' , ' f4m ' ) else None ,
self . _format_out ( ' UNSUPPORTED ' , self . Styles . BAD_FORMAT ) if f . get ( ' ext ' ) in ( ' f4f ' , ' f4m ' ) else None ,
self . _format_out ( ' DRM' , ' light red ' ) if f . get ( ' has_drm ' ) else None ,
( self . _format_out ( ' Maybe DRM' , self . Styles . WARNING ) if f . get ( ' has_drm ' ) == ' maybe '
format_field ( f , ' language ' , ' [ %s ] ' ) ,
else self . _format_out ( ' DRM ' , self . Styles . BAD_FORMAT ) if f . get ( ' has_drm ' ) else None ) ,
join_nonempty( format_field( f , ' format_note ' ) ,
format_field( f , ' format_note ' ) ,
format_field ( f , ' container ' , ignore = ( None , f . get ( ' ext ' ) ) ) ,
format_field ( f , ' container ' , ignore = ( None , f . get ( ' ext ' ) ) ) ,
delim = ' , ' ) ,
delim = ' , ' ) , delim = ' ' ) ,
delim = ' ' ) ,
] for f in formats if f . get ( ' preference ' ) is None or f [ ' preference ' ] > = - 1000 ]
] for f in formats if f . get ( ' preference ' ) is None or f [ ' preference ' ] > = - 1000 ]
header_line = self . _list_format_headers (
header_line = self . _list_format_headers (
' ID ' , ' EXT ' , ' RESOLUTION ' , ' \t FPS ' , ' HDR ' , ' CH ' , delim , ' \t FILESIZE ' , ' \t TBR ' , ' PROTO ' ,
' ID ' , ' EXT ' , ' RESOLUTION ' , ' \t FPS ' , ' HDR ' , ' CH ' , delim , ' \t FILESIZE ' , ' \t TBR ' , ' PROTO ' ,