From 15ac3125143068d808203a341431db2d7e3f287d Mon Sep 17 00:00:00 2001 From: queeup Date: Fri, 20 Nov 2020 23:17:04 +0300 Subject: [PATCH] Adds support for moving with original filename (#43) --- mnamer/metadata.py | 1 + mnamer/target.py | 1 + tests/e2e/test_moving.py | 12 ++++++++++++ 3 files changed, 14 insertions(+) diff --git a/mnamer/metadata.py b/mnamer/metadata.py index f035da9b..ba9637c6 100644 --- a/mnamer/metadata.py +++ b/mnamer/metadata.py @@ -45,6 +45,7 @@ class Metadata: quality: Optional[str] = None synopsis: Optional[str] = None media: Union[MediaType, str, None] = None + original: Optional[str] = None def __setattr__(self, key: str, value: Any): converter_map: Dict[str, Callable] = { diff --git a/mnamer/target.py b/mnamer/target.py index 9f072892..fb6b64d8 100644 --- a/mnamer/target.py +++ b/mnamer/target.py @@ -143,6 +143,7 @@ def _parse(self, file_path: Path): None: Metadata, }[media_type] self.metadata = meta_cls(language=self._settings.language) + self.metadata.original = self.source.name self.metadata.quality = ( " ".join( path_data[key] diff --git a/tests/e2e/test_moving.py b/tests/e2e/test_moving.py index 51c3658f..6d192913 100644 --- a/tests/e2e/test_moving.py +++ b/tests/e2e/test_moving.py @@ -217,3 +217,15 @@ def test_ambiguous_language_deletction(e2e_run, setup_test_files): ) result = e2e_run("--batch", ".") assert result.code == 0 + + +@pytest.mark.usefixtures("setup_test_dir") +def test_original_filename(e2e_run, setup_test_files): + setup_test_files("archer.2009.s10e07.webrip.x264-lucidtv.mp4") + result = e2e_run( + "--batch", + "--episode-format='{original}'", + ".", + ) + assert result.code == 0 + assert "archer.2009.s10e07.webrip.x264-lucidtv.mp4" in result.out