From 1974b2b332e6cc83c5ad1ea846c90d89d558062e Mon Sep 17 00:00:00 2001 From: ds Date: Wed, 6 Sep 2023 09:55:51 +0300 Subject: [PATCH] do not strip whitespace characters --- test/test_YoutubeDL.py | 2 +- yt_dlp/YoutubeDL.py | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/test/test_YoutubeDL.py b/test/test_YoutubeDL.py index 2f1a94a6b..88d785c00 100644 --- a/test/test_YoutubeDL.py +++ b/test/test_YoutubeDL.py @@ -851,7 +851,7 @@ def gen(): ('1234.1024.info.json', '123.info.json'), 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 os.environ['__yt_dlp_var'] = 'expanded' diff --git a/yt_dlp/YoutubeDL.py b/yt_dlp/YoutubeDL.py index 77008694d..76cbf8f0e 100644 --- a/yt_dlp/YoutubeDL.py +++ b/yt_dlp/YoutubeDL.py @@ -1383,9 +1383,7 @@ def _prepare_filename(self, info_dict, *, outtmpl=None, tmpl_type=None): if trim_file_name: # https://github.com/yt-dlp/yt-dlp/issues/5526#issuecomment-1312783517 no_ext, *ext = filename.rsplit('.', info_dict.get('ext', '').count('.') + 1) - # cut filename and remove trailing spaces and extra dots - name = no_ext[:trim_file_name].strip().rstrip('.') - filename = join_nonempty(name, *ext, delim='.') + filename = join_nonempty(no_ext[:trim_file_name], *ext, delim='.') if tmpl_type in ('', 'temp'): final_ext, ext = self.params.get('final_ext'), info_dict.get('ext')