mirror of
https://github.com/nathom/streamrip.git
synced 2024-09-19 11:18:45 -04:00
Added path string validation (#574)
This commit is contained in:
parent
1704406cdf
commit
669ceee48a
1 changed files with 8 additions and 5 deletions
|
@ -7,6 +7,7 @@ from typing import Optional
|
||||||
|
|
||||||
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"
|
||||||
|
@ -63,20 +64,22 @@ class AlbumMetadata:
|
||||||
|
|
||||||
def format_folder_path(self, formatter: str) -> str:
|
def format_folder_path(self, formatter: str) -> str:
|
||||||
# Available keys: "albumartist", "title", "year", "bit_depth", "sampling_rate",
|
# Available keys: "albumartist", "title", "year", "bit_depth", "sampling_rate",
|
||||||
# "id", and "albumcomposer",
|
# "id", and "albumcomposer",
|
||||||
|
|
||||||
none_str = "Unknown"
|
none_str = "Unknown"
|
||||||
info: dict[str, str | int | float] = {
|
info: dict[str, str | int | float] = {
|
||||||
"albumartist": self.albumartist,
|
"albumartist": clean_filename(self.albumartist),
|
||||||
"albumcomposer": self.albumcomposer or none_str,
|
"albumcomposer": clean_filename(self.albumcomposer) 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,
|
||||||
"title": self.album,
|
"title": clean_filename(self.album),
|
||||||
"year": self.year,
|
"year": self.year,
|
||||||
"container": self.info.container,
|
"container": self.info.container,
|
||||||
}
|
}
|
||||||
|
|
||||||
return formatter.format(**info)
|
return formatter.format(**info)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_qobuz(cls, resp: dict) -> AlbumMetadata:
|
def from_qobuz(cls, resp: dict) -> AlbumMetadata:
|
||||||
album = resp.get("title", "Unknown Album")
|
album = resp.get("title", "Unknown Album")
|
||||||
|
|
Loading…
Reference in a new issue