Create track class

This commit is contained in:
George Lacey 2025-01-18 10:19:18 +00:00
parent 572e7d49d3
commit 422e7eb82b
2 changed files with 36 additions and 0 deletions

1
src/music/__init__.py Normal file
View File

@ -0,0 +1 @@
from .track import Track

35
src/music/track.py Normal file
View File

@ -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}"