playlist: moved code to song_by_url()
Replace some complicated checks from addToPlaylist() to the simpler function song_by_url().
This commit is contained in:
parent
6d3488c8b3
commit
961a349f15
@ -521,17 +521,30 @@ static void clearPlayerQueue(void)
|
|||||||
pc_cancel();
|
pc_cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct song *
|
||||||
|
song_by_url(const char *url)
|
||||||
|
{
|
||||||
|
struct song *song;
|
||||||
|
|
||||||
|
song = db_get_song(url);
|
||||||
|
if (song != NULL)
|
||||||
|
return song;
|
||||||
|
|
||||||
|
if (isValidRemoteUtf8Url(url))
|
||||||
|
return song_remote_new(url);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
enum playlist_result addToPlaylist(const char *url, int *added_id)
|
enum playlist_result addToPlaylist(const char *url, int *added_id)
|
||||||
{
|
{
|
||||||
struct song *song;
|
struct song *song;
|
||||||
|
|
||||||
DEBUG("add to playlist: %s\n", url);
|
DEBUG("add to playlist: %s\n", url);
|
||||||
|
|
||||||
if ((song = db_get_song(url))) {
|
song = song_by_url(url);
|
||||||
} else if (!(isValidRemoteUtf8Url(url) &&
|
if (song == NULL)
|
||||||
(song = song_remote_new(url)))) {
|
|
||||||
return PLAYLIST_RESULT_NO_SUCH_SONG;
|
return PLAYLIST_RESULT_NO_SUCH_SONG;
|
||||||
}
|
|
||||||
|
|
||||||
return addSongToPlaylist(song, added_id);
|
return addSongToPlaylist(song, added_id);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user