Handle no copyright case for tidal

This commit is contained in:
Nathan Thomas 2024-03-06 18:35:20 -08:00
parent 3443331501
commit aadd7021ad

View file

@ -5,9 +5,9 @@ import re
from dataclasses import dataclass from dataclasses import dataclass
from typing import Optional from typing import Optional
from ..filepath_utils import clean_filename
from .covers import Covers from .covers import Covers
from .util import get_quality_id, safe_get, typed from .util import get_quality_id, safe_get, typed
from ..filepath_utils import clean_filename
PHON_COPYRIGHT = "\u2117" PHON_COPYRIGHT = "\u2117"
COPYRIGHT = "\u00a9" COPYRIGHT = "\u00a9"
@ -69,7 +69,7 @@ class AlbumMetadata:
none_str = "Unknown" none_str = "Unknown"
info: dict[str, str | int | float] = { info: dict[str, str | int | float] = {
"albumartist": clean_filename(self.albumartist), "albumartist": clean_filename(self.albumartist),
"albumcomposer": clean_filename(self.albumcomposer) or none_str, "albumcomposer": clean_filename(self.albumcomposer or "") or none_str,
"bit_depth": self.info.bit_depth or none_str, "bit_depth": self.info.bit_depth or none_str,
"id": self.info.id, "id": self.info.id,
"sampling_rate": self.info.sampling_rate or none_str, "sampling_rate": self.info.sampling_rate or none_str,
@ -284,6 +284,7 @@ class AlbumMetadata:
""" """
Args: Args:
----
resp: API response containing album metadata. resp: API response containing album metadata.
Returns: AlbumMetadata instance if the album is streamable, otherwise None. Returns: AlbumMetadata instance if the album is streamable, otherwise None.
@ -300,7 +301,7 @@ class AlbumMetadata:
# genre not returned by API # genre not returned by API
date = typed(resp.get("releaseDate"), str) date = typed(resp.get("releaseDate"), str)
year = date[:4] year = date[:4]
_copyright = typed(resp.get("copyright"), str) _copyright = typed(resp.get("copyright"), str | None)
artists = typed(resp.get("artists", []), list) artists = typed(resp.get("artists", []), list)
albumartist = ", ".join(a["name"] for a in artists) albumartist = ", ".join(a["name"] for a in artists)
@ -383,7 +384,7 @@ class AlbumMetadata:
else: else:
year = "Unknown Year" year = "Unknown Year"
_copyright = typed(resp.get("copyright"), str) _copyright = typed(resp.get("copyright"), str | None)
artists = typed(resp.get("artists", []), list) artists = typed(resp.get("artists", []), list)
albumartist = ", ".join(a["name"] for a in artists) albumartist = ", ".join(a["name"] for a in artists)
if not albumartist: if not albumartist: