Skip to content

Commit

Permalink
refactor(Track): Remove swap() method and it's uses
Browse files Browse the repository at this point in the history
Re-using the same track path and file name with a different output file, is not ideal as the files contents are different and the target file name specifies what processing it had done on it, which is useful during debugging when browsing the temp directory.
  • Loading branch information
rlaphoenix committed Mar 1, 2024
1 parent 470e051 commit 96ae4a1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion devine/core/tracks/subtitle.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def convert(self, codec: Subtitle.Codec) -> Path:

output_path.write_text(subtitle_text, encoding="utf8")

self.swap(output_path)
self.path = output_path
self.codec = codec

if callable(self.OnConverted):
Expand Down
3 changes: 1 addition & 2 deletions devine/core/tracks/track.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,7 @@ def _ffmpeg(extra_args: list[str] = None):
else:
raise

self.swap(output_path)
self.move(original_path)
self.path = output_path

def move(self, target: Union[Path, str]) -> bool:
"""
Expand Down
5 changes: 2 additions & 3 deletions devine/core/tracks/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,7 @@ def change_color_range(self, range_: int) -> None:
str(output_path)
], check=True)

self.swap(output_path)
self.move(original_path)
self.path = output_path

def ccextractor(
self, track_id: Any, out_path: Union[Path, str], language: Language, original: bool = False
Expand Down Expand Up @@ -335,7 +334,7 @@ def remove_eia_cc(self) -> bool:

log.info(" + Removed")

self.swap(cleaned_path)
self.path = cleaned_path

return True

Expand Down

0 comments on commit 96ae4a1

Please sign in to comment.