1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2024-11-02 09:12:40 +01:00

[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 (
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')