Create track class
This commit is contained in:
parent
572e7d49d3
commit
422e7eb82b
1
src/music/__init__.py
Normal file
1
src/music/__init__.py
Normal file
|
@ -0,0 +1 @@
|
|||
from .track import Track
|
35
src/music/track.py
Normal file
35
src/music/track.py
Normal 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}"
|
Loading…
Reference in New Issue
Block a user