From 422e7eb82b6a53ec0c4e4091f55702e6747f6a6e Mon Sep 17 00:00:00 2001 From: grglcy Date: Sat, 18 Jan 2025 10:19:18 +0000 Subject: [PATCH] Create track class --- src/music/__init__.py | 1 + src/music/track.py | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 src/music/__init__.py create mode 100644 src/music/track.py diff --git a/src/music/__init__.py b/src/music/__init__.py new file mode 100644 index 0000000..519ddea --- /dev/null +++ b/src/music/__init__.py @@ -0,0 +1 @@ +from .track import Track \ No newline at end of file diff --git a/src/music/track.py b/src/music/track.py new file mode 100644 index 0000000..6a5472b --- /dev/null +++ b/src/music/track.py @@ -0,0 +1,35 @@ +from pathlib import Path + + +class Track: + def __init__(self, location: Path): + self.path = location + + @property + def filename(self) -> str: + return self.path.name + + @property + def stem(self) -> str: + return self.path.stem + + @property + def extension(self) -> str: + return self.path.suffix + + @property + def artist(self) -> Path: + return self.path.parent.parent + + @property + def album(self) -> Path: + return self.path.parent + + def artist_output(self, root: Path) -> Path: + return root / self.artist.parts[-1] + + def album_output(self, root: Path) -> Path: + return root / self.artist.parts[-1] / self.album.parts[-1] + + def output_file(self, root: Path, extension: str) -> Path: + return root / self.artist.parts[-1] / self.album.parts[-1] / f"{self.stem}.{extension}"