Loading karaokatalog/Song.py +6 −2 Original line number Diff line number Diff line from __future__ import annotations import filecmp from dataclasses import dataclass from dataclasses import dataclass, field from pathlib import Path from typing import Self from uuid import UUID, uuid4 from karaokatalog.parse_song_txt import parse_song_txt Loading @@ -25,6 +26,7 @@ class Song: video: Path | None cover: Path | None song_txt: Path uuid: UUID = field(default=uuid4()) @property def dir(self) -> Path: Loading Loading @@ -52,6 +54,7 @@ class Song: audio_name = tags.get("AUDIO", tags.get("MP3")) video_name = tags.get("VIDEO") cover_name = tags.get("COVER") uuid = tags.get("UUID") if not title or not artist: # Both are mandatory according to the specification Loading @@ -64,11 +67,12 @@ class Song: video=song_txt / video_name if video_name else None, cover=song_txt / cover_name if cover_name else None, song_txt=song_txt, uuid=UUID(uuid) if uuid else uuid4(), ) def as_dict(self) -> dict[str, str]: return { "uuid": str(self.uuid), "title": self.title, "artist": self.artist, # TODO More fields } Loading
karaokatalog/Song.py +6 −2 Original line number Diff line number Diff line from __future__ import annotations import filecmp from dataclasses import dataclass from dataclasses import dataclass, field from pathlib import Path from typing import Self from uuid import UUID, uuid4 from karaokatalog.parse_song_txt import parse_song_txt Loading @@ -25,6 +26,7 @@ class Song: video: Path | None cover: Path | None song_txt: Path uuid: UUID = field(default=uuid4()) @property def dir(self) -> Path: Loading Loading @@ -52,6 +54,7 @@ class Song: audio_name = tags.get("AUDIO", tags.get("MP3")) video_name = tags.get("VIDEO") cover_name = tags.get("COVER") uuid = tags.get("UUID") if not title or not artist: # Both are mandatory according to the specification Loading @@ -64,11 +67,12 @@ class Song: video=song_txt / video_name if video_name else None, cover=song_txt / cover_name if cover_name else None, song_txt=song_txt, uuid=UUID(uuid) if uuid else uuid4(), ) def as_dict(self) -> dict[str, str]: return { "uuid": str(self.uuid), "title": self.title, "artist": self.artist, # TODO More fields }