add support to pulling explicit tag. fix tags on upc. isrc(mp4 not support, use WM tags), and composor missing(possible bug in mp4box, apple documents uses @wrt which belongs to writer in mp4box doc.)

This commit is contained in:
Xie, Tianshi
2024-05-16 16:18:38 -04:00
parent ad8f567572
commit 117a08ee4f
5 changed files with 14 additions and 4 deletions

View File

@@ -159,7 +159,7 @@ async def get_cover(url: str, cover_format: str, cover_size: str):
async def get_song_info(song_id: str, token: str, storefront: str, lang: str):
async with request_lock:
req = await client.get(f"https://amp-api.music.apple.com/v1/catalog/{storefront}/songs/{song_id}",
params={"extend": "extendedAssetUrls", "include": "albums", "l": lang},
params={"extend": "extendedAssetUrls", "include": "albums,explicit", "l": lang},
headers={"Authorization": f"Bearer {token}", "User-Agent": user_agent_itunes,
"Origin": "https://music.apple.com"})
song_data_obj = SongData.model_validate(req.json())

View File

@@ -41,6 +41,12 @@ class SongMetadata(BaseModel):
lrc = ttml_convent_to_lrc(value)
tags.append(f"{key}={lrc}")
continue
if key.lower() in ('upc', 'isrc'):
tags.append(f"WM/{key.lower()}={value}")
continue
if key == 'composer':
tags.append(f"writer={value}")
continue
tags.append(f"{key}={value}")
return ":".join(tags)
@@ -55,7 +61,8 @@ class SongMetadata(BaseModel):
copyright=song_data.relationships.albums.data[0].attributes.copyright,
record_company=song_data.relationships.albums.data[0].attributes.recordLabel,
upc=song_data.relationships.albums.data[0].attributes.upc,
isrc=song_data.attributes.isrc
isrc=song_data.attributes.isrc,
rtng=1 if song_data.attributes.contentRating and song_data.attributes.contentRating == 'explicit' else 0
)
def set_lyrics(self, lyrics: str):

View File

@@ -58,6 +58,7 @@ class Attributes(BaseModel):
previews: List[Preview]
artistName: Optional[str] = None
extendedAssetUrls: ExtendedAssetUrls
contentRating: Optional[str] = None
class Artwork1(BaseModel):