Skip to content

Commit

Permalink
Update output path for new projects
Browse files Browse the repository at this point in the history
  • Loading branch information
machinewrapped committed Feb 17, 2024
1 parent 63a2e40 commit 102b4df
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion PySubtitle/Helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def GetOutputPath(filepath, language="translated"):
basename = basename[0:basename.index("-ChatGPT")]
if basename.endswith("-GPT"):
basename = basename[0:basename.index("-GPT")]
language_suffix = f"-{language}"
language_suffix = f".{language}"
if not basename.endswith(language_suffix):
basename = basename + language_suffix

Expand Down
8 changes: 8 additions & 0 deletions PySubtitle/SubtitleFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,14 @@ def UpdateContext(self, options):

return context

def UpdateOutputPath(self, outputpath : str = None):
"""
Set or generate the output path for the translated subtitles
"""
if not outputpath:
outputpath = GetOutputPath(self.sourcepath, self.target_language)
self.outputpath = outputpath

def AutoBatch(self, options):
"""
Divide subtitles into scenes and batches based on threshold options
Expand Down
1 change: 1 addition & 0 deletions PySubtitle/SubtitleProject.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ def UpdateProjectSettings(self, options: dict):
self.subtitles.UpdateContext(self.options)

if self.subtitles.scenes:
self.subtitles.UpdateOutputPath()
self.WriteProjectFile()

def _start_autosave_thread(self):
Expand Down

0 comments on commit 102b4df

Please sign in to comment.