mirror of https://github.com/vitiko98/qobuz-dl
Featured artists tags (#1)
* add featured artists to tags * improve featured artist heuristics --------- Co-authored-by: Frnot <frnot@frnot.com>
This commit is contained in:
parent
4e39e5df74
commit
7140dd6218
|
@ -31,6 +31,10 @@ ID3_LEGEND = {
|
|||
"year": id3.TYER,
|
||||
}
|
||||
|
||||
FEATURED_ARTIST_TITLES = [
|
||||
"FeaturedArtist",
|
||||
"MainArtist",
|
||||
]
|
||||
|
||||
def _get_title(track_dict):
|
||||
title = track_dict["title"]
|
||||
|
@ -44,6 +48,22 @@ def _get_title(track_dict):
|
|||
return title
|
||||
|
||||
|
||||
def _get_featured_artists(track_dict):
|
||||
featured_artists = []
|
||||
primary_artist = True
|
||||
for i in track_dict["performers"].split(" - "):
|
||||
# ignore primary artist
|
||||
if primary_artist and "MainArtist" in i:
|
||||
primary_artist = False
|
||||
continue
|
||||
|
||||
for jobtitle in FEATURED_ARTIST_TITLES:
|
||||
if jobtitle in i:
|
||||
featured_artists.append(i.split(",")[0])
|
||||
break
|
||||
return featured_artists
|
||||
|
||||
|
||||
def _format_copyright(s: str) -> str:
|
||||
if s:
|
||||
s = s.replace("(P)", PHON_COPYRIGHT)
|
||||
|
@ -142,9 +162,7 @@ def tag_flac(
|
|||
else:
|
||||
artists = [artist_ or album["artist"]["name"]]
|
||||
|
||||
for i in d["performers"].split(" - "): # FEATURED ARTISTS
|
||||
if "FeaturedArtist" in i:
|
||||
artists.append(i.replace(", FeaturedArtist", ""))
|
||||
artists.extend(_get_featured_artists(d))
|
||||
audio["ARTIST"] = artists
|
||||
|
||||
audio["LABEL"] = album.get("label", {}).get("name", "n/a")
|
||||
|
@ -202,9 +220,7 @@ def tag_mp3(filename, root_dir, final_name, d, album, istrack=True, em_image=Fal
|
|||
else:
|
||||
artists = [artist_ or album["artist"]["name"]]
|
||||
|
||||
for i in d["performers"].split(" - "): # FEATURED ARTISTS
|
||||
if "FeaturedArtist" in i:
|
||||
artists.append(i.replace(", FeaturedArtist", ""))
|
||||
artists.extend(_get_featured_artists(d))
|
||||
tags["artist"] = artists
|
||||
|
||||
if istrack:
|
||||
|
|
Loading…
Reference in New Issue