[sponskrub] Encode filenames correctly

This commit is contained in:
pukkandan 2021-01-18 05:22:47 +05:30
parent f57adf0e59
commit 477cf32f37

View File

@ -7,8 +7,10 @@
from ..utils import ( from ..utils import (
check_executable, check_executable,
encodeArgument, encodeArgument,
encodeFilename,
shell_quote, shell_quote,
PostProcessingError, 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.') self.report_warning('If sponskrub is run multiple times, unintended parts of the video could be cut out.')
filename = information['filepath'] filename = information['filepath']
temp_filename = filename + '.' + self._temp_ext + os.path.splitext(filename)[1] temp_filename = prepend_extension(filename, self._temp_ext)
if os.path.exists(temp_filename): if os.path.exists(encodeFilename(temp_filename)):
os.remove(temp_filename) os.remove(encodeFilename(temp_filename))
cmd = [self.path] cmd = [self.path]
if self.args: if self.args:
@ -73,8 +75,8 @@ def run(self, information):
stdout, stderr = p.communicate() stdout, stderr = p.communicate()
if p.returncode == 0: if p.returncode == 0:
os.remove(filename) os.remove(encodeFilename(filename))
os.rename(temp_filename, filename) os.rename(encodeFilename(temp_filename), encodeFilename(filename))
self.to_screen('Sponsor sections have been %s' % ('removed' if self.cutout else 'marked')) self.to_screen('Sponsor sections have been %s' % ('removed' if self.cutout else 'marked'))
elif p.returncode == 3: elif p.returncode == 3:
self.to_screen('No segments in the SponsorBlock database') self.to_screen('No segments in the SponsorBlock database')