Skip to content

Commit

Permalink
Sanitize paths embedded in --episode-format. Issues jkwill87#127 jkwi…
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Tomlin committed Jun 16, 2021
1 parent 0e288e3 commit a28f18e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
6 changes: 6 additions & 0 deletions mnamer/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ def destination(self) -> PurePath:
)
file_path = self._make_path(file_path)
dir_tail, filename = path.split(file_path)

# Required to sanitize paths that have been inserted into --episode-format
dir_tail = self._make_path(
*[str_sanitize(px) for px in self._make_path(dir_tail).parts]
)

filename = filename_replace(filename, self._settings.replace_after)
if self._settings.scene:
filename = str_scenify(filename)
Expand Down
20 changes: 20 additions & 0 deletions tests/e2e/test_relocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,26 @@ def _run_relocation_operation(e2e_run, setup_test_files):
assert "1 out of 1 files processed successfully" in result.out


@pytest.mark.tvdb
@pytest.mark.usefixtures("setup_test_dir")
def test_sanitize_episode_format_path(e2e_run, setup_test_files):
setup_test_files(
"The.Great.Fire.In.Real.Time.S01E01.1080p.HEVC.x265-MeGusta.mkv"
)
result = e2e_run(
"--batch",
"--episode-api=tvdb",
"--episode-format='{series}/{series}'",
".",
)
print(result.out)
assert result.code == 0
assert (
"The Great Fire in Real Time/The Great Fire in Real Time" in result.out
)
assert "1 out of 1 files processed successfully" in result.out


@pytest.mark.usefixtures("setup_test_dir")
def test_complex_metadata(e2e_run, setup_test_files):
setup_test_files(
Expand Down

0 comments on commit a28f18e

Please sign in to comment.