From 4fa7b60ddca14b57a7c13598787dba3a2404c46d Mon Sep 17 00:00:00 2001 From: Max Date: Mon, 8 Sep 2025 08:03:25 +0200 Subject: [PATCH] Refactor --- src/file_classifier.py | 19 +++++-------- src/structures.py | 61 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 12 deletions(-) create mode 100644 src/structures.py diff --git a/src/file_classifier.py b/src/file_classifier.py index 7ff1da1..872281b 100644 --- a/src/file_classifier.py +++ b/src/file_classifier.py @@ -1,18 +1,13 @@ -from dataclasses import dataclass +from .structures import PathClassification, FileClassification +from pathlib import Path -@dataclass -class FileIdentity: - pass -@dataclass -class PathIdentities: - pass +def classify_files(path: str) -> PathClassification: + return PathClassification(Path(path)) -def identify_files(path: str) -> PathIdentities: - return PathIdentities if __name__ == "__main__": - results = identify_files("/home/max/Media Library/testing/The Mentalist (2008)") - + results = classify_files("/home/max/Media Library/testing/The Mentalist (2008)") + print(results) - print("Done.") \ No newline at end of file + print("Done.") diff --git a/src/structures.py b/src/structures.py new file mode 100644 index 0000000..a348f57 --- /dev/null +++ b/src/structures.py @@ -0,0 +1,61 @@ +from dataclasses import dataclass +from enum import Enum +from pathlib import Path + + +class FileCategory(Enum): + UNCLASSIFIED = "unclassified" + """File has not been classified yet.""" + + UNKNOWN = "unknown" + """File could not be classified successfully.""" + + MAIN_FEATURE = "main_feature" + """Main Feature of a movie.""" + + EPISODE = "episode" + """Episode of a show.""" + + TRAILER = "trailer" + """Trailer.""" + + EXTRA = "extra" + """Extra content like deleted scenes or behind the scenes.""" + + WARNINGS = "warnings" + """Copyright warnings.""" + + POSTER = "poster" + """Poster, background, thumb and other meta image formats often used in Jellyfin and Plex.""" + + +class PathCategory(Enum): + UNCLASSIFIED = "unclassified" + """Not yet classified.""" + + UNKNOWN = "unknown" + """Could not be classified.""" + + MOVIE = "movie" + """Movie with main feature.""" + + SHOW = "show" + """Show with episodes.""" + + +@dataclass +class FileClassification: + original_path: Path + """Original Path to file, before any processing.""" + + category: FileCategory = FileCategory.UNCLASSIFIED + """Category of file content.""" + + +@dataclass +class PathClassification: + path: Path + """Parent directory of analysed content.""" + + category: PathCategory = PathCategory.UNCLASSIFIED + """Category of path media."""