Use the list.append function, which is safe for strings

This commit is contained in:
tcely 2025-05-18 21:45:24 -04:00 committed by GitHub
parent dafa82d1d1
commit 0e720f9042
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -326,13 +326,10 @@ def download_media(
final_path = Path(output_file).resolve(strict=False) final_path = Path(output_file).resolve(strict=False)
expected_file = shell_quote(str(final_path)) expected_file = shell_quote(str(final_path))
cmds = pp_opts.exec_cmd.get('after_move', list()) cmds = pp_opts.exec_cmd.get('after_move', list())
# It is important that we use a tuple for strings. cmds.append(
# Otherwise, list adds each character instead.
# That last comma is really necessary!
cmds += (
f'test -f {expected_file} || ' f'test -f {expected_file} || '
'mv -T -u -- %(filepath,_filename|)q ' 'mv -T -u -- %(filepath,_filename|)q '
f'{expected_file}', f'{expected_file}'
) )
# assignment is the quickest way to cover both 'get' cases # assignment is the quickest way to cover both 'get' cases
pp_opts.exec_cmd['after_move'] = cmds pp_opts.exec_cmd['after_move'] = cmds
@ -387,7 +384,7 @@ def download_media(
youtube_ea_dict = ytopts['extractor_args'].get('youtube', dict()) youtube_ea_dict = ytopts['extractor_args'].get('youtube', dict())
formats_list = youtube_ea_dict.get('formats', list()) formats_list = youtube_ea_dict.get('formats', list())
if 'missing_pot' not in formats_list: if 'missing_pot' not in formats_list:
formats_list += ('missing_pot',) formats_list.append('missing_pot')
youtube_ea_dict.update({ youtube_ea_dict.update({
'formats': formats_list, 'formats': formats_list,
}) })