From 07494eddf32aee915d459710b4146048c0d0733f Mon Sep 17 00:00:00 2001 From: Robert Honz Date: Fri, 17 Oct 2025 15:26:48 +0200 Subject: [PATCH] =?UTF-8?q?feat(metadata):=20=E2=9C=A8=20add=20support=20f?= =?UTF-8?q?or=20explicit=20track=20metadata?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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. --- tidal_dl_ng/download.py | 1 + tidal_dl_ng/metadata.py | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/tidal_dl_ng/download.py b/tidal_dl_ng/download.py index 7ad9612..8c51e76 100644 --- a/tidal_dl_ng/download.py +++ b/tidal_dl_ng/download.py @@ -1252,6 +1252,7 @@ class Download: 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, upc=track.album.upc if track.album and track.album.upc else "", + explicit=track.explicit if hasattr(track, "explicit") else False, ) m.save() diff --git a/tidal_dl_ng/metadata.py b/tidal_dl_ng/metadata.py index c8e1728..7d8ccb9 100644 --- a/tidal_dl_ng/metadata.py +++ b/tidal_dl_ng/metadata.py @@ -31,6 +31,7 @@ class Metadata: replay_gain_write: bool upc: str target_upc: dict[str, str] + explicit: bool m: mutagen.mp4.MP4 | mutagen.mp4.MP4 | mutagen.flac.FLAC def __init__( @@ -59,6 +60,7 @@ class Metadata: url_share: str = "", replay_gain_write: bool = True, upc: str = "", + explicit: bool = False, ): self.path_file = path_file self.title = title @@ -84,6 +86,7 @@ class Metadata: self.replay_gain_write = replay_gain_write self.upc = upc self.target_upc = target_upc + self.explicit = explicit self.m: mutagen.FileType = mutagen.File(self.path_file) def _cover(self) -> bool: @@ -189,6 +192,7 @@ class Metadata: self.m.tags["isrc"] = self.isrc 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["rtng"] = [1 if self.explicit else 0] if self.replay_gain_write: self.m.tags["----:com.apple.iTunes:REPLAYGAIN_ALBUM_GAIN"] = str(self.album_replay_gain).encode("utf-8")