mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-14 08:15:02 -05:00
[spotify] Added config options to use the playlist name as album name
This commit is contained in:
parent
7cc3659d42
commit
988283c25d
@ -175,10 +175,22 @@ spotify {
|
|||||||
# album artist for spotify items that are not in the starred playlist.
|
# album artist for spotify items that are not in the starred playlist.
|
||||||
# artist_override = false
|
# artist_override = false
|
||||||
|
|
||||||
# Like artist_override, the starre_artist_override flag can be set to true,
|
# Like artist_override, the starred_artist_override flag can be set to true,
|
||||||
# in order to use the compilation_artist for items in the spotify starred
|
# in order to use the compilation_artist for items in the spotify starred
|
||||||
# playlist.
|
# playlist.
|
||||||
# starred_artist_override = false
|
# starred_artist_override = false
|
||||||
|
|
||||||
|
# Similar to the different artists in spotify playlists, the playlist items
|
||||||
|
# belong to different albums, and if you do not want every album to be listed
|
||||||
|
# when browsing in Remote, you can set the album_override flag to true. This
|
||||||
|
# will use the playlist name as album name for spotify items that are not in
|
||||||
|
# the starred playlist. Notice that if an item is in more than one playlist,
|
||||||
|
# it will only appear in one album when browsing (in which album is random).
|
||||||
|
# album_override = false
|
||||||
|
|
||||||
|
# Like album_override, the starred_album_override flag can be set to true,
|
||||||
|
# in order to use the playlist name as album name.
|
||||||
|
# starred_album_override = false
|
||||||
}
|
}
|
||||||
|
|
||||||
# SQLite configuration (allows to modify the operation of the SQLite databases)
|
# SQLite configuration (allows to modify the operation of the SQLite databases)
|
||||||
|
@ -115,6 +115,8 @@ static cfg_opt_t sec_spotify[] =
|
|||||||
CFG_INT("bitrate", 0, CFGF_NONE),
|
CFG_INT("bitrate", 0, CFGF_NONE),
|
||||||
CFG_BOOL("artist_override", cfg_false, CFGF_NONE),
|
CFG_BOOL("artist_override", cfg_false, CFGF_NONE),
|
||||||
CFG_BOOL("starred_artist_override", cfg_false, CFGF_NONE),
|
CFG_BOOL("starred_artist_override", cfg_false, CFGF_NONE),
|
||||||
|
CFG_BOOL("album_override", cfg_false, CFGF_NONE),
|
||||||
|
CFG_BOOL("starred_album_override", cfg_false, CFGF_NONE),
|
||||||
CFG_END()
|
CFG_END()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -465,20 +465,25 @@ thread_exit(void)
|
|||||||
/* Should only be called from within the spotify thread */
|
/* Should only be called from within the spotify thread */
|
||||||
|
|
||||||
static int
|
static int
|
||||||
spotify_metadata_get(sp_track *track, struct media_file_info *mfi)
|
spotify_metadata_get(sp_track *track, struct media_file_info *mfi, char *pltitle)
|
||||||
{
|
{
|
||||||
cfg_t *spotify_cfg;
|
cfg_t *spotify_cfg;
|
||||||
bool artist_override;
|
bool artist_override;
|
||||||
bool starred_artist_override;
|
bool starred_artist_override;
|
||||||
|
bool album_override;
|
||||||
|
bool starred_album_override;
|
||||||
sp_album *album;
|
sp_album *album;
|
||||||
sp_artist *artist;
|
sp_artist *artist;
|
||||||
sp_albumtype albumtype;
|
sp_albumtype albumtype;
|
||||||
bool starred;
|
bool starred;
|
||||||
char compilation;
|
char compilation;
|
||||||
|
char *albumname;
|
||||||
|
|
||||||
spotify_cfg = cfg_getsec(cfg, "spotify");
|
spotify_cfg = cfg_getsec(cfg, "spotify");
|
||||||
artist_override = cfg_getbool(spotify_cfg, "artist_override");
|
artist_override = cfg_getbool(spotify_cfg, "artist_override");
|
||||||
starred_artist_override = cfg_getbool(spotify_cfg, "starred_artist_override");
|
starred_artist_override = cfg_getbool(spotify_cfg, "starred_artist_override");
|
||||||
|
album_override = cfg_getbool(spotify_cfg, "album_override");
|
||||||
|
starred_album_override = cfg_getbool(spotify_cfg, "starred_album_override");
|
||||||
|
|
||||||
album = fptr_sp_track_album(track);
|
album = fptr_sp_track_album(track);
|
||||||
if (!album)
|
if (!album)
|
||||||
@ -501,8 +506,14 @@ spotify_metadata_get(sp_track *track, struct media_file_info *mfi)
|
|||||||
|| (starred && starred_artist_override)
|
|| (starred && starred_artist_override)
|
||||||
|| (!starred && artist_override));
|
|| (!starred && artist_override));
|
||||||
|
|
||||||
|
if ((starred && starred_album_override)
|
||||||
|
|| (!starred && album_override))
|
||||||
|
albumname = strdup(pltitle);
|
||||||
|
else
|
||||||
|
albumname = strdup(fptr_sp_album_name(album));
|
||||||
|
|
||||||
mfi->title = strdup(fptr_sp_track_name(track));
|
mfi->title = strdup(fptr_sp_track_name(track));
|
||||||
mfi->album = strdup(fptr_sp_album_name(album));
|
mfi->album = albumname;
|
||||||
mfi->artist = strdup(fptr_sp_artist_name(artist));
|
mfi->artist = strdup(fptr_sp_artist_name(artist));
|
||||||
mfi->year = fptr_sp_album_year(album);
|
mfi->year = fptr_sp_album_year(album);
|
||||||
mfi->song_length = fptr_sp_track_duration(track);
|
mfi->song_length = fptr_sp_track_duration(track);
|
||||||
@ -536,7 +547,7 @@ spotify_metadata_get(sp_track *track, struct media_file_info *mfi)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
spotify_track_save(int plid, sp_track *track)
|
spotify_track_save(int plid, sp_track *track, char *pltitle)
|
||||||
{
|
{
|
||||||
struct media_file_info mfi;
|
struct media_file_info mfi;
|
||||||
sp_link *link;
|
sp_link *link;
|
||||||
@ -579,7 +590,7 @@ spotify_track_save(int plid, sp_track *track)
|
|||||||
|
|
||||||
memset(&mfi, 0, sizeof(struct media_file_info));
|
memset(&mfi, 0, sizeof(struct media_file_info));
|
||||||
|
|
||||||
ret = spotify_metadata_get(track, &mfi);
|
ret = spotify_metadata_get(track, &mfi, pltitle);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
DPRINTF(E_LOG, L_SPOTIFY, "Metadata missing (but track should be loaded?): '%s'\n", fptr_sp_track_name(track));
|
DPRINTF(E_LOG, L_SPOTIFY, "Metadata missing (but track should be loaded?): '%s'\n", fptr_sp_track_name(track));
|
||||||
@ -687,7 +698,7 @@ spotify_playlist_save(sp_playlist *pl)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = spotify_track_save(plid, track);
|
ret = spotify_track_save(plid, track, title);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
DPRINTF(E_LOG, L_SPOTIFY, "Error saving track %d to playlist '%s' (id %d)\n", i, name, plid);
|
DPRINTF(E_LOG, L_SPOTIFY, "Error saving track %d to playlist '%s' (id %d)\n", i, name, plid);
|
||||||
|
Loading…
Reference in New Issue
Block a user