do not strip whitespace characters

This commit is contained in:
ds 2023-09-06 09:55:51 +03:00
parent 46cebee490
commit 1974b2b332
2 changed files with 2 additions and 4 deletions

View File

@ -851,7 +851,7 @@ class TestYoutubeDL(unittest.TestCase):
('1234.1024.info.json', '123.info.json'), ('1234.1024.info.json', '123.info.json'),
info=dict(self.outtmpl_info, ext='info.json'), trim_file_name=3 info=dict(self.outtmpl_info, ext='info.json'), trim_file_name=3
) )
test('12 34.%(filesize)s.%(ext)s', ('12 34.1024.mp4', '12.mp4'), trim_file_name=3) test('12 34.%(filesize)s.%(ext)s', ('12 34.1024.mp4', '12 .mp4'), trim_file_name=3)
# Environment variable expansion for prepare_filename # Environment variable expansion for prepare_filename
os.environ['__yt_dlp_var'] = 'expanded' os.environ['__yt_dlp_var'] = 'expanded'

View File

@ -1383,9 +1383,7 @@ class YoutubeDL:
if trim_file_name: if trim_file_name:
# https://github.com/yt-dlp/yt-dlp/issues/5526#issuecomment-1312783517 # https://github.com/yt-dlp/yt-dlp/issues/5526#issuecomment-1312783517
no_ext, *ext = filename.rsplit('.', info_dict.get('ext', '').count('.') + 1) no_ext, *ext = filename.rsplit('.', info_dict.get('ext', '').count('.') + 1)
# cut filename and remove trailing spaces and extra dots filename = join_nonempty(no_ext[:trim_file_name], *ext, delim='.')
name = no_ext[:trim_file_name].strip().rstrip('.')
filename = join_nonempty(name, *ext, delim='.')
if tmpl_type in ('', 'temp'): if tmpl_type in ('', 'temp'):
final_ext, ext = self.params.get('final_ext'), info_dict.get('ext') final_ext, ext = self.params.get('final_ext'), info_dict.get('ext')