mirror of
https://github.com/nathom/streamrip.git
synced 2025-05-14 07:04:51 -04:00
Make Explicit tag optional #216
This commit is contained in:
parent
de0634e1fa
commit
fcc2baeb11
5 changed files with 16 additions and 13 deletions
|
@ -150,7 +150,7 @@ add_singles_to_folder = false
|
||||||
folder_format = "{albumartist} - {title} ({year}) [{container}] [{bit_depth}B-{sampling_rate}kHz]"
|
folder_format = "{albumartist} - {title} ({year}) [{container}] [{bit_depth}B-{sampling_rate}kHz]"
|
||||||
# Available keys: "tracknumber", "artist", "albumartist", "composer", "title",
|
# Available keys: "tracknumber", "artist", "albumartist", "composer", "title",
|
||||||
# and "albumcomposer"
|
# and "albumcomposer"
|
||||||
track_format = "{tracknumber}. {artist} - {title}"
|
track_format = "{tracknumber}. {artist} - {title}{explicit}"
|
||||||
# Only allow printable ASCII characters in filenames.
|
# Only allow printable ASCII characters in filenames.
|
||||||
restrict_characters = false
|
restrict_characters = false
|
||||||
|
|
||||||
|
|
|
@ -128,6 +128,7 @@ TRACK_KEYS = (
|
||||||
"composer",
|
"composer",
|
||||||
"title",
|
"title",
|
||||||
"albumcomposer",
|
"albumcomposer",
|
||||||
|
"explicit",
|
||||||
)
|
)
|
||||||
ALBUM_KEYS = (
|
ALBUM_KEYS = (
|
||||||
"albumartist",
|
"albumartist",
|
||||||
|
|
|
@ -1,9 +1,4 @@
|
||||||
"""Bases that handle parsing and downloading media.
|
"""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.
|
|
||||||
"""
|
|
||||||
|
|
||||||
import abc
|
import abc
|
||||||
import concurrent.futures
|
import concurrent.futures
|
||||||
|
|
|
@ -67,7 +67,7 @@ class TrackMetadata:
|
||||||
disctotal: Optional[int] = None
|
disctotal: Optional[int] = None
|
||||||
|
|
||||||
# not included in tags
|
# not included in tags
|
||||||
explicit: Optional[bool] = False
|
explicit: bool = False
|
||||||
quality: Optional[int] = None
|
quality: Optional[int] = None
|
||||||
sampling_rate: Optional[int] = None
|
sampling_rate: Optional[int] = None
|
||||||
bit_depth: Optional[int] = None
|
bit_depth: Optional[int] = None
|
||||||
|
@ -200,7 +200,7 @@ class TrackMetadata:
|
||||||
self.albumartist = safe_get(resp, "artist", "name")
|
self.albumartist = safe_get(resp, "artist", "name")
|
||||||
self.label = resp.get("label")
|
self.label = resp.get("label")
|
||||||
self.url = resp.get("link")
|
self.url = resp.get("link")
|
||||||
self.explicit = bool(resp.get("parental_warning"))
|
self.explicit = resp.get("parental_warning", False)
|
||||||
|
|
||||||
# not embedded
|
# not embedded
|
||||||
self.quality = 2
|
self.quality = 2
|
||||||
|
@ -290,8 +290,8 @@ class TrackMetadata:
|
||||||
if not hasattr(self, "_title"):
|
if not hasattr(self, "_title"):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if self.explicit:
|
# if self.explicit:
|
||||||
return f"{self._title} (Explicit)"
|
# return f"{self._title} (Explicit)"
|
||||||
|
|
||||||
return self._title
|
return self._title
|
||||||
|
|
||||||
|
|
|
@ -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 = 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)
|
# 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:
|
for key in fmt_keys:
|
||||||
|
logger.debug(repr(key))
|
||||||
|
logger.debug(format_info.get(key))
|
||||||
if isinstance(format_info.get(key), (str, float)):
|
if isinstance(format_info.get(key), (str, float)):
|
||||||
|
logger.debug("1")
|
||||||
clean_dict[key] = clean_filename(str(format_info[key]), restrict=restrict)
|
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
|
elif isinstance(format_info.get(key), int): # track/discnumber
|
||||||
|
logger.debug("2")
|
||||||
clean_dict[key] = f"{format_info[key]:02}"
|
clean_dict[key] = f"{format_info[key]:02}"
|
||||||
else:
|
else:
|
||||||
clean_dict[key] = "Unknown"
|
clean_dict[key] = "Unknown"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue