mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-09-03 00:25:08 +00:00
[cleanup] Add more ruff rules (#10149)
Authored by: seproDev Reviewed-by: bashonly <88596187+bashonly@users.noreply.github.com> Reviewed-by: Simon Sawicki <contact@grub4k.xyz>
This commit is contained in:
@ -13,7 +13,6 @@ from ..utils import (
|
||||
check_executable,
|
||||
encodeArgument,
|
||||
encodeFilename,
|
||||
error_to_compat_str,
|
||||
prepend_extension,
|
||||
shell_quote,
|
||||
)
|
||||
@ -48,7 +47,7 @@ class EmbedThumbnailPP(FFmpegPostProcessor):
|
||||
if mobj is None:
|
||||
return guess()
|
||||
except PostProcessingError as err:
|
||||
self.report_warning('unable to find the thumbnail resolution; %s' % error_to_compat_str(err))
|
||||
self.report_warning(f'unable to find the thumbnail resolution; {err}')
|
||||
return guess()
|
||||
return int(mobj.group('w')), int(mobj.group('h'))
|
||||
|
||||
@ -104,12 +103,12 @@ class EmbedThumbnailPP(FFmpegPostProcessor):
|
||||
old_stream, new_stream = self.get_stream_number(
|
||||
filename, ('tags', 'mimetype'), mimetype)
|
||||
if old_stream is not None:
|
||||
options.extend(['-map', '-0:%d' % old_stream])
|
||||
options.extend(['-map', f'-0:{old_stream}'])
|
||||
new_stream -= 1
|
||||
options.extend([
|
||||
'-attach', self._ffmpeg_filename_argument(thumbnail_filename),
|
||||
'-metadata:s:%d' % new_stream, 'mimetype=%s' % mimetype,
|
||||
'-metadata:s:%d' % new_stream, 'filename=cover.%s' % thumbnail_ext])
|
||||
f'-metadata:s:{new_stream}', f'mimetype={mimetype}',
|
||||
f'-metadata:s:{new_stream}', f'filename=cover.{thumbnail_ext}'])
|
||||
|
||||
self._report_run('ffmpeg', filename)
|
||||
self.run_ffmpeg(filename, temp_filename, options)
|
||||
@ -132,7 +131,7 @@ class EmbedThumbnailPP(FFmpegPostProcessor):
|
||||
meta.save()
|
||||
temp_filename = filename
|
||||
except Exception as err:
|
||||
self.report_warning('unable to embed using mutagen; %s' % error_to_compat_str(err))
|
||||
self.report_warning(f'unable to embed using mutagen; {err}')
|
||||
success = False
|
||||
|
||||
# Method 2: Use AtomicParsley
|
||||
@ -157,7 +156,7 @@ class EmbedThumbnailPP(FFmpegPostProcessor):
|
||||
cmd += [encodeArgument(o) for o in self._configuration_args('AtomicParsley')]
|
||||
|
||||
self._report_run('atomicparsley', filename)
|
||||
self.write_debug('AtomicParsley command line: %s' % shell_quote(cmd))
|
||||
self.write_debug(f'AtomicParsley command line: {shell_quote(cmd)}')
|
||||
stdout, stderr, returncode = Popen.run(cmd, text=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
if returncode:
|
||||
self.report_warning(f'Unable to embed thumbnails using AtomicParsley; {stderr.strip()}')
|
||||
@ -178,9 +177,9 @@ class EmbedThumbnailPP(FFmpegPostProcessor):
|
||||
old_stream, new_stream = self.get_stream_number(
|
||||
filename, ('disposition', 'attached_pic'), 1)
|
||||
if old_stream is not None:
|
||||
options.extend(['-map', '-0:%d' % old_stream])
|
||||
options.extend(['-map', f'-0:{old_stream}'])
|
||||
new_stream -= 1
|
||||
options.extend(['-disposition:%s' % new_stream, 'attached_pic'])
|
||||
options.extend([f'-disposition:{new_stream}', 'attached_pic'])
|
||||
|
||||
self._report_run('ffmpeg', filename)
|
||||
self.run_ffmpeg_multiple_files([filename, thumbnail_filename], temp_filename, options)
|
||||
@ -196,7 +195,7 @@ class EmbedThumbnailPP(FFmpegPostProcessor):
|
||||
f = {'opus': OggOpus, 'flac': FLAC, 'ogg': OggVorbis}[info['ext']](filename)
|
||||
|
||||
pic = Picture()
|
||||
pic.mime = 'image/%s' % imghdr.what(thumbnail_filename)
|
||||
pic.mime = f'image/{imghdr.what(thumbnail_filename)}'
|
||||
with open(thumbnail_filename, 'rb') as thumbfile:
|
||||
pic.data = thumbfile.read()
|
||||
pic.type = 3 # front cover
|
||||
|
Reference in New Issue
Block a user