diff --git a/youtube_dlc/postprocessor/sponskrub.py b/youtube_dlc/postprocessor/sponskrub.py index a8a6e0691..f039861ac 100644 --- a/youtube_dlc/postprocessor/sponskrub.py +++ b/youtube_dlc/postprocessor/sponskrub.py @@ -7,8 +7,10 @@ from ..utils import ( check_executable, encodeArgument, + encodeFilename, shell_quote, PostProcessingError, + prepend_extension, ) @@ -58,9 +60,9 @@ def run(self, information): self.report_warning('If sponskrub is run multiple times, unintended parts of the video could be cut out.') filename = information['filepath'] - temp_filename = filename + '.' + self._temp_ext + os.path.splitext(filename)[1] - if os.path.exists(temp_filename): - os.remove(temp_filename) + temp_filename = prepend_extension(filename, self._temp_ext) + if os.path.exists(encodeFilename(temp_filename)): + os.remove(encodeFilename(temp_filename)) cmd = [self.path] if self.args: @@ -73,8 +75,8 @@ def run(self, information): stdout, stderr = p.communicate() if p.returncode == 0: - os.remove(filename) - os.rename(temp_filename, filename) + os.remove(encodeFilename(filename)) + os.rename(encodeFilename(temp_filename), encodeFilename(filename)) self.to_screen('Sponsor sections have been %s' % ('removed' if self.cutout else 'marked')) elif p.returncode == 3: self.to_screen('No segments in the SponsorBlock database')