From 21b860740632e64db8721384ba372439d1d11269 Mon Sep 17 00:00:00 2001 From: WorldObservationLog Date: Thu, 6 Jun 2024 00:34:31 +0800 Subject: [PATCH] feat: support clean rating --- src/metadata.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/metadata.py b/src/metadata.py index 0b7db34..67c0455 100644 --- a/src/metadata.py +++ b/src/metadata.py @@ -68,10 +68,19 @@ class SongMetadata(BaseModel): record_company=song_data.relationships.albums.data[0].attributes.recordLabel, upc=song_data.relationships.albums.data[0].attributes.upc, isrc=song_data.attributes.isrc, - rtng=1 if song_data.attributes.contentRating and song_data.attributes.contentRating == 'explicit' else 0, + rtng=cls._rating(song_data.attributes.contentRating), song_id=song_data.id, album_id=song_data.relationships.albums.data[0].id ) + @staticmethod + def _rating(content_rating: Optional[str]) -> int: + if not content_rating: + return 0 + if content_rating == "explicit": + return 1 + if content_rating == "clean": + return 2 + def set_lyrics(self, lyrics: str): self.lyrics = lyrics