From 9eb3124219dd7bbe9c9c15c5479cc5a57587d883 Mon Sep 17 00:00:00 2001 From: 7x11x13 Date: Tue, 7 Jan 2025 00:23:24 -0500 Subject: [PATCH] WIP commit --- yt_dlp/YoutubeDL.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/yt_dlp/YoutubeDL.py b/yt_dlp/YoutubeDL.py index 764baf3a00..5856a9cbd4 100644 --- a/yt_dlp/YoutubeDL.py +++ b/yt_dlp/YoutubeDL.py @@ -1424,8 +1424,20 @@ class YoutubeDL: return EXTERNAL_FORMAT_RE.sub(create_key, outtmpl), TMPL_DICT def evaluate_outtmpl(self, outtmpl, info_dict, *args, **kwargs): + print(outtmpl) outtmpl, info_dict = self.prepare_outtmpl(outtmpl, info_dict, *args, **kwargs) - return self.escape_outtmpl(outtmpl) % info_dict + ext_suffix = '.%(ext\x00s)s' # not sure why this has null char + suffix = '' + if outtmpl.endswith(ext_suffix): + outtmpl = outtmpl[:-len(ext_suffix)] + suffix = ext_suffix % info_dict + outtmpl = self.escape_outtmpl(outtmpl) + filename = outtmpl % info_dict + encoding = sys.getfilesystemencoding() # make option to override + filename = filename.encode(encoding) + filename = filename[:255 - len('.flac.part')] # make option to override + filename = filename.decode(encoding, 'ignore') + return filename + suffix @_catch_unsafe_extension_error def _prepare_filename(self, info_dict, *, outtmpl=None, tmpl_type=None): @@ -1435,6 +1447,7 @@ class YoutubeDL: try: outtmpl = self._outtmpl_expandpath(outtmpl) filename = self.evaluate_outtmpl(outtmpl, info_dict, True) + print(filename) if not filename: return None