Implemented caching of title, artist and album of a track as WOBUZZM3U parameters.

This commit is contained in:
The Wobbler 2025-03-04 19:29:24 +01:00
parent 072f5c7691
commit 971ead90c1
2 changed files with 59 additions and 14 deletions

View file

@ -9,11 +9,33 @@ from dataclasses import dataclass
@dataclass
class TrackMetadata:
title: str
artist: str
album: str
path: str | None=None
title: str | None=None
artist: str | None=None
album: str | None=None
images: TTImages | None=None # tinytag images
def add_missing(self):
# Make the album be an empty string instead of "None"
if self.title == "None":
self.title = ""
if self.artist == "None":
self.artist = ""
if self.album == "None":
self.album = ""
if self.path is None: # can't add missing information without a path
return
if self.title is None or self.artist is None or self.album is None:
tags = TinyTag.get(self.path, ignore_errors=True, duration=False)
self.title = tags.title
self.artist = tags.artist
self.album = tags.album
class Track:
"""
@ -26,9 +48,9 @@ class Track:
if metadata is None:
# load metadata from audio file
tags = TinyTag.get(self.path, ignore_errors=True, duration=False)
tags = TinyTag.get(path, ignore_errors=True, duration=False)
self.metadata = TrackMetadata(tags.title, tags.artist, tags.album)
self.metadata = TrackMetadata(path, tags.title, tags.artist, tags.album)
else:
self.metadata = metadata