@@ -67,6 +67,7 @@ def create_output(
6767 library : Path | str = Path ("./" ),
6868 output : str = "{title}" ,
6969 replace : bool = False ,
70+ format : AudioFormat = AudioFormat .VORBIS ,
7071 ) -> Path :
7172 """
7273 Creates save directory for the output file
@@ -85,7 +86,8 @@ def create_output(
8586 "{" + meta .name + "}" , fix_filename (meta .string )
8687 )
8788 file_path = library .joinpath (output ).expanduser ()
88- if file_path .exists () and not replace :
89+ file_path_for_check = file_path .with_name (file_path .name + "." + format .value .ext )
90+ if file_path_for_check .exists () and not replace :
8991 raise FileExistsError ("File already downloaded" )
9092 else :
9193 file_path .parent .mkdir (parents = True , exist_ok = True )
@@ -151,14 +153,33 @@ def __default_metadata(self) -> list[MetadataEntry]:
151153 self .track .album = self .__api ().get_metadata_4_album (
152154 AlbumId .from_hex (bytes_to_hex (self .album .gid ))
153155 )
156+ artist_name , genres_list = self .__api .get_localized_artist_name (self .artist [0 ])
157+ artists = []
158+ for artist in self .artist :
159+ extra_artist_name , extra_genres = self .__api .get_localized_artist_name (artist )
160+ if extra_artist_name :
161+ artists .append (extra_artist_name )
162+ genres_list .extend (extra_genres )
163+
164+ album_artist_name , extra_genres = self .__api .get_localized_artist_name (self .album .artist [0 ])
165+ genres_list = list (set (genres_list + extra_genres ))
166+
167+ album_artists = []
168+ for artist in self .album .artist :
169+ extra_artist_name , album_extra_genres = self .__api .get_localized_artist_name (artist )
170+ if extra_artist_name :
171+ album_artists .append (extra_artist_name )
172+ genres_list = list (set (genres_list + album_extra_genres ))
173+ genres = "; " .join (str (item ) for item in set (genres_list ))
154174 return [
155175 MetadataEntry ("album" , self .album .name ),
156- MetadataEntry ("album_artist" , self . album . artist [ 0 ]. name ),
157- MetadataEntry ("album_artists" , [ a . name for a in self . album . artist ] ),
158- MetadataEntry ("artist" , self . artist [ 0 ]. name ),
159- MetadataEntry ("artists" , [ a . name for a in self . artist ] ),
176+ MetadataEntry ("album_artist" , album_artist_name ),
177+ MetadataEntry ("album_artists" , album_artists ),
178+ MetadataEntry ("artist" , artist_name ),
179+ MetadataEntry ("artists" , artists ),
160180 MetadataEntry ("date" , f"{ date .year } -{ date .month } -{ date .day } " ),
161181 MetadataEntry ("disc" , self .disc_number ),
182+ MetadataEntry ("discnumber" , self .disc_number ),
162183 MetadataEntry ("duration" , self .duration ),
163184 MetadataEntry ("explicit" , self .explicit , "[E]" if self .explicit else "" ),
164185 MetadataEntry ("isrc" , self .external_id [0 ].id ),
@@ -167,6 +188,7 @@ def __default_metadata(self) -> list[MetadataEntry]:
167188 MetadataEntry ("title" , self .name ),
168189 MetadataEntry ("track" , self .name ),
169190 MetadataEntry ("year" , date .year ),
191+ MetadataEntry ("genre" , genres ),
170192 MetadataEntry (
171193 "replaygain_track_gain" , self .normalization_data .track_gain_db , ""
172194 ),
0 commit comments