[spotify] Respect settings for 'artist_override' and 'album_override' (#340)
when scanning spotify through the web api The goal is to reduce the artist/album cluttering that happens because of the users spotify playlists. If 'artist_override' is true, all tracks not in a saved album are treated as part of a compilation giving them the configured album-artist (e. g. "Various artists"). I 'album_override' is true, tracks not in a saved album will use the playlistname as albumname.
This commit is contained in:
parent
62dd1bb407
commit
e092a9ff3e
|
@ -2241,6 +2241,9 @@ scan_saved_albums()
|
|||
static int
|
||||
scan_playlisttracks(struct spotify_playlist *playlist, int plid)
|
||||
{
|
||||
cfg_t *spotify_cfg;
|
||||
bool artist_override;
|
||||
bool album_override;
|
||||
struct spotify_request request;
|
||||
struct spotify_track track;
|
||||
struct media_file_info mfi;
|
||||
|
@ -2248,6 +2251,10 @@ scan_playlisttracks(struct spotify_playlist *playlist, int plid)
|
|||
|
||||
memset(&request, 0, sizeof(struct spotify_request));
|
||||
|
||||
spotify_cfg = cfg_getsec(cfg, "spotify");
|
||||
artist_override = cfg_getbool(spotify_cfg, "artist_override");
|
||||
album_override = cfg_getbool(spotify_cfg, "album_override");
|
||||
|
||||
while (0 == spotifywebapi_request_next(&request, playlist->tracks_href))
|
||||
{
|
||||
db_transaction_begin();
|
||||
|
@ -2264,6 +2271,13 @@ scan_playlisttracks(struct spotify_playlist *playlist, int plid)
|
|||
memset(&mfi, 0, sizeof(struct media_file_info));
|
||||
map_track_to_mfi(&track, &mfi);
|
||||
|
||||
track.is_compilation = (track.is_compilation || artist_override);
|
||||
if (album_override)
|
||||
{
|
||||
free(mfi.album);
|
||||
mfi.album = strdup(playlist->name);
|
||||
}
|
||||
|
||||
library_process_media(track.uri, 1 /* TODO passing one prevents overwriting existing entries */, 0, DATA_KIND_SPOTIFY, 0, track.is_compilation, &mfi, dir_id);
|
||||
spotify_uri_register(track.uri);
|
||||
|
||||
|
|
Loading…
Reference in New Issue