Make Explicit tag optional #216

This commit is contained in:
Nathan Thomas 2021-11-09 17:04:29 -08:00
parent de0634e1fa
commit fcc2baeb11
5 changed files with 16 additions and 13 deletions

View file

@ -150,7 +150,7 @@ add_singles_to_folder = false
folder_format = "{albumartist} - {title} ({year}) [{container}] [{bit_depth}B-{sampling_rate}kHz]"
# Available keys: "tracknumber", "artist", "albumartist", "composer", "title",
# and "albumcomposer"
track_format = "{tracknumber}. {artist} - {title}"
track_format = "{tracknumber}. {artist} - {title}{explicit}"
# Only allow printable ASCII characters in filenames.
restrict_characters = false

View file

@ -128,6 +128,7 @@ TRACK_KEYS = (
"composer",
"title",
"albumcomposer",
"explicit",
)
ALBUM_KEYS = (
"albumartist",

View file

@ -1,9 +1,4 @@
"""Bases that handle parsing and downloading media.
These are the lower level classes that are handled by Album, Playlist,
and the other objects. They can also be downloaded individually, for example,
as a single track.
"""
"""Bases that handle parsing and downloading media. """
import abc
import concurrent.futures

View file

@ -67,7 +67,7 @@ class TrackMetadata:
disctotal: Optional[int] = None
# not included in tags
explicit: Optional[bool] = False
explicit: bool = False
quality: Optional[int] = None
sampling_rate: Optional[int] = None
bit_depth: Optional[int] = None
@ -200,7 +200,7 @@ class TrackMetadata:
self.albumartist = safe_get(resp, "artist", "name")
self.label = resp.get("label")
self.url = resp.get("link")
self.explicit = bool(resp.get("parental_warning"))
self.explicit = resp.get("parental_warning", False)
# not embedded
self.quality = 2
@ -290,8 +290,8 @@ class TrackMetadata:
if not hasattr(self, "_title"):
return None
if self.explicit:
return f"{self._title} (Explicit)"
# if self.explicit:
# return f"{self._title} (Explicit)"
return self._title

View file

@ -149,13 +149,20 @@ def clean_format(formatter: str, format_info, restrict: bool = False):
fmt_keys = filter(None, (i[1] for i in Formatter().parse(formatter)))
# fmt_keys = (i[1] for i in Formatter().parse(formatter) if i[1] is not None)
logger.debug("Formatter keys: %s", fmt_keys)
logger.debug("Formatter keys: %s", formatter)
clean_dict = dict()
clean_dict = {}
for key in fmt_keys:
logger.debug(repr(key))
logger.debug(format_info.get(key))
if isinstance(format_info.get(key), (str, float)):
logger.debug("1")
clean_dict[key] = clean_filename(str(format_info[key]), restrict=restrict)
elif key == "explicit":
logger.debug("3")
clean_dict[key] = " (Explicit) " if format_info.get(key, False) else ""
elif isinstance(format_info.get(key), int): # track/discnumber
logger.debug("2")
clean_dict[key] = f"{format_info[key]:02}"
else:
clean_dict[key] = "Unknown"