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.)

pull/8/head
Xie, Tianshi 4 months ago
parent ad8f567572
commit 117a08ee4f
  1. 2
      .gitignore
  2. 4
      config.example.toml
  3. 2
      src/api.py
  4. 9
      src/metadata.py
  5. 1
      src/models/song_data.py

2
.gitignore vendored

@ -161,3 +161,5 @@ cython_debug/
#.idea/
config.toml
.python-version
.vscode/*

@ -73,10 +73,10 @@ afterDownloaded = ""
# title, artist, album, album_artist, composer,
# genre, created, track, tracknum, disk,
# record_company, upc, isrc, copyright,
# lyrics, cover
# lyrics, cover, ratings(rtng)
embedMetadata = ["title", "artist", "album", "album_artist", "composer",
"genre", "created", "track", "tracknum", "disk", "lyrics", "cover", "copyright",
"record_company", "upc", "isrc"]
"record_company", "upc", "isrc","rtng"]
[mitm]
# The host proxy server listens on

@ -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())

@ -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):

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

Loading…
Cancel
Save