feat(metadata): ✨ add support for explicit track metadata
* Added `explicit` attribute to the `Metadata` class. * Updated the constructor to initialize `explicit` with a default value of `False`. * Modified the metadata saving process to include explicit rating in tags.
This commit is contained in:
@@ -1252,6 +1252,7 @@ class Download:
|
|||||||
url_share=track.share_url if track.share_url and self.settings.data.metadata_write_url else "",
|
url_share=track.share_url if track.share_url and self.settings.data.metadata_write_url else "",
|
||||||
replay_gain_write=self.settings.data.metadata_replay_gain,
|
replay_gain_write=self.settings.data.metadata_replay_gain,
|
||||||
upc=track.album.upc if track.album and track.album.upc else "",
|
upc=track.album.upc if track.album and track.album.upc else "",
|
||||||
|
explicit=track.explicit if hasattr(track, "explicit") else False,
|
||||||
)
|
)
|
||||||
|
|
||||||
m.save()
|
m.save()
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ class Metadata:
|
|||||||
replay_gain_write: bool
|
replay_gain_write: bool
|
||||||
upc: str
|
upc: str
|
||||||
target_upc: dict[str, str]
|
target_upc: dict[str, str]
|
||||||
|
explicit: bool
|
||||||
m: mutagen.mp4.MP4 | mutagen.mp4.MP4 | mutagen.flac.FLAC
|
m: mutagen.mp4.MP4 | mutagen.mp4.MP4 | mutagen.flac.FLAC
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
@@ -59,6 +60,7 @@ class Metadata:
|
|||||||
url_share: str = "",
|
url_share: str = "",
|
||||||
replay_gain_write: bool = True,
|
replay_gain_write: bool = True,
|
||||||
upc: str = "",
|
upc: str = "",
|
||||||
|
explicit: bool = False,
|
||||||
):
|
):
|
||||||
self.path_file = path_file
|
self.path_file = path_file
|
||||||
self.title = title
|
self.title = title
|
||||||
@@ -84,6 +86,7 @@ class Metadata:
|
|||||||
self.replay_gain_write = replay_gain_write
|
self.replay_gain_write = replay_gain_write
|
||||||
self.upc = upc
|
self.upc = upc
|
||||||
self.target_upc = target_upc
|
self.target_upc = target_upc
|
||||||
|
self.explicit = explicit
|
||||||
self.m: mutagen.FileType = mutagen.File(self.path_file)
|
self.m: mutagen.FileType = mutagen.File(self.path_file)
|
||||||
|
|
||||||
def _cover(self) -> bool:
|
def _cover(self) -> bool:
|
||||||
@@ -189,6 +192,7 @@ class Metadata:
|
|||||||
self.m.tags["isrc"] = self.isrc
|
self.m.tags["isrc"] = self.isrc
|
||||||
self.m.tags["\xa9url"] = self.url_share
|
self.m.tags["\xa9url"] = self.url_share
|
||||||
self.m.tags[f"----:com.apple.iTunes:{self.target_upc['MP4']}"] = self.upc.encode("utf-8")
|
self.m.tags[f"----:com.apple.iTunes:{self.target_upc['MP4']}"] = self.upc.encode("utf-8")
|
||||||
|
self.m.tags["rtng"] = [1 if self.explicit else 0]
|
||||||
|
|
||||||
if self.replay_gain_write:
|
if self.replay_gain_write:
|
||||||
self.m.tags["----:com.apple.iTunes:REPLAYGAIN_ALBUM_GAIN"] = str(self.album_replay_gain).encode("utf-8")
|
self.m.tags["----:com.apple.iTunes:REPLAYGAIN_ALBUM_GAIN"] = str(self.album_replay_gain).encode("utf-8")
|
||||||
|
|||||||
Reference in New Issue
Block a user