[spotify] Added config options to use the compilation artist for spotify
tracks
This commit is contained in:
parent
563195b8a7
commit
7cc3659d42
|
@ -163,6 +163,22 @@ spotify {
|
|||
# Set preferred bitrate for music streaming
|
||||
# 0: No preference (default), 1: 96kbps, 2: 160kbps, 3: 320kbps
|
||||
# bitrate = 0
|
||||
|
||||
# Compilations usually have many artists, and if you don't want every
|
||||
# artist to be listed when artist browsing in Remote, you can set
|
||||
# a single name which will be used for all music in the compilation dir
|
||||
# (changing this setting only takes effect after rescan, see the README)
|
||||
|
||||
# Spotify playlists usually have many artist, and if you don't want every
|
||||
# artist to be listed when artist browsing in Remote, you can set the
|
||||
# artist_override flag to true. This will use the compilation_artist as
|
||||
# album artist for spotify items that are not in the starred playlist.
|
||||
# artist_override = false
|
||||
|
||||
# Like artist_override, the starre_artist_override flag can be set to true,
|
||||
# in order to use the compilation_artist for items in the spotify starred
|
||||
# playlist.
|
||||
# starred_artist_override = false
|
||||
}
|
||||
|
||||
# SQLite configuration (allows to modify the operation of the SQLite databases)
|
||||
|
|
|
@ -113,6 +113,8 @@ static cfg_opt_t sec_spotify[] =
|
|||
CFG_STR("settings_dir", STATEDIR "/cache/" PACKAGE "/libspotify", CFGF_NONE),
|
||||
CFG_STR("cache_dir", "/tmp", CFGF_NONE),
|
||||
CFG_INT("bitrate", 0, CFGF_NONE),
|
||||
CFG_BOOL("artist_override", cfg_false, CFGF_NONE),
|
||||
CFG_BOOL("starred_artist_override", cfg_false, CFGF_NONE),
|
||||
CFG_END()
|
||||
};
|
||||
|
||||
|
|
|
@ -467,10 +467,18 @@ thread_exit(void)
|
|||
static int
|
||||
spotify_metadata_get(sp_track *track, struct media_file_info *mfi)
|
||||
{
|
||||
cfg_t *spotify_cfg;
|
||||
bool artist_override;
|
||||
bool starred_artist_override;
|
||||
sp_album *album;
|
||||
sp_artist *artist;
|
||||
sp_albumtype albumtype;
|
||||
bool starred;
|
||||
char compilation;
|
||||
|
||||
spotify_cfg = cfg_getsec(cfg, "spotify");
|
||||
artist_override = cfg_getbool(spotify_cfg, "artist_override");
|
||||
starred_artist_override = cfg_getbool(spotify_cfg, "starred_artist_override");
|
||||
|
||||
album = fptr_sp_track_album(track);
|
||||
if (!album)
|
||||
|
@ -481,9 +489,18 @@ spotify_metadata_get(sp_track *track, struct media_file_info *mfi)
|
|||
return -1;
|
||||
|
||||
albumtype = fptr_sp_album_type(album);
|
||||
|
||||
starred = fptr_sp_track_is_starred(g_sess, track);
|
||||
|
||||
/*
|
||||
* Treat album as compilation if one of the following conditions is true:
|
||||
* - spotfy album type is compilation
|
||||
* - artist_override in config is set to true and track is not part of the starred playlist
|
||||
* - starred_artist_override in config is set to true and track is part of the starred playlist
|
||||
*/
|
||||
compilation = ((albumtype == SP_ALBUMTYPE_COMPILATION)
|
||||
|| (starred && starred_artist_override)
|
||||
|| (!starred && artist_override));
|
||||
|
||||
mfi->title = strdup(fptr_sp_track_name(track));
|
||||
mfi->album = strdup(fptr_sp_album_name(album));
|
||||
mfi->artist = strdup(fptr_sp_artist_name(artist));
|
||||
|
@ -491,7 +508,7 @@ spotify_metadata_get(sp_track *track, struct media_file_info *mfi)
|
|||
mfi->song_length = fptr_sp_track_duration(track);
|
||||
mfi->track = fptr_sp_track_index(track);
|
||||
mfi->disc = fptr_sp_track_disc(track);
|
||||
mfi->compilation = (albumtype == SP_ALBUMTYPE_COMPILATION);
|
||||
mfi->compilation = compilation;
|
||||
mfi->artwork = ARTWORK_SPOTIFY;
|
||||
mfi->type = strdup("spotify");
|
||||
mfi->codectype = strdup("wav");
|
||||
|
|
Loading…
Reference in New Issue