diff options
author | Max Kellermann <max@duempel.org> | 2008-10-15 22:35:00 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-10-15 22:35:00 +0200 |
commit | 961a349f15393f9530343a9b3fe197513a654a82 (patch) | |
tree | e33d3d5b0049e2751a8cc6659651896c5f74d83a /src | |
parent | 6d3488c8b38c07c197e97843a516868bbab7571a (diff) | |
download | mpd-961a349f15393f9530343a9b3fe197513a654a82.tar.gz mpd-961a349f15393f9530343a9b3fe197513a654a82.tar.xz mpd-961a349f15393f9530343a9b3fe197513a654a82.zip |
playlist: moved code to song_by_url()
Replace some complicated checks from addToPlaylist() to the simpler
function song_by_url().
Diffstat (limited to '')
-rw-r--r-- | src/playlist.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/playlist.c b/src/playlist.c index dc098a03f..dfbc31514 100644 --- a/src/playlist.c +++ b/src/playlist.c @@ -521,17 +521,30 @@ static void clearPlayerQueue(void) 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) { struct song *song; DEBUG("add to playlist: %s\n", url); - if ((song = db_get_song(url))) { - } else if (!(isValidRemoteUtf8Url(url) && - (song = song_remote_new(url)))) { + song = song_by_url(url); + if (song == NULL) return PLAYLIST_RESULT_NO_SUCH_SONG; - } return addSongToPlaylist(song, added_id); } |