From 5c22c63da33b73263951153f9533ba28ba08b035 Mon Sep 17 00:00:00 2001 From: pukkandan Date: Tue, 30 Nov 2021 00:08:46 +0530 Subject: [PATCH] Fix `--trim-filename` when filename has `.` Closes #1837 --- yt_dlp/YoutubeDL.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/yt_dlp/YoutubeDL.py b/yt_dlp/YoutubeDL.py index a6e0163af..634169470 100644 --- a/yt_dlp/YoutubeDL.py +++ b/yt_dlp/YoutubeDL.py @@ -1186,12 +1186,8 @@ class YoutubeDL(object): # https://github.com/blackjack4494/youtube-dlc/issues/85 trim_file_name = self.params.get('trim_file_name', False) if trim_file_name: - fn_groups = filename.rsplit('.') - ext = fn_groups[-1] - sub_ext = '' - if len(fn_groups) > 2: - sub_ext = fn_groups[-2] - filename = join_nonempty(fn_groups[0][:trim_file_name], sub_ext, ext, delim='.') + no_ext, *ext = filename.rsplit('.', 2) + filename = join_nonempty(no_ext[:trim_file_name], *ext, delim='.') return filename except ValueError as err: