summaryrefslogtreecommitdiff
path: root/src/actions.cpp
diff options
context:
space:
mode:
authorAndrzej Rybczak <electricityispower@gmail.com>2015-04-18 18:05:53 +0200
committerAndrzej Rybczak <electricityispower@gmail.com>2015-04-18 18:07:51 +0200
commit2082a4a9a3154053bb3c0d9698cd93290eaa0dc9 (patch)
treeca20d8ed61482f390b5e112a65487bead3745c93 /src/actions.cpp
parent081ad033d4d48e662cbf9bf6adbd625cfd7e9b45 (diff)
actions: add: be smarter about adding the item
Diffstat (limited to 'src/actions.cpp')
-rw-r--r--src/actions.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/actions.cpp b/src/actions.cpp
index 3cde6286..32d51af3 100644
--- a/src/actions.cpp
+++ b/src/actions.cpp
@@ -953,16 +953,18 @@ void Add::run()
Mpd.AddToPlaylist(myPlaylistEditor->Playlists.current()->value().path(), path);
else
{
- const char lastfm_url[] = "lastfm://";
- if (path.compare(0, const_strlen(lastfm_url), lastfm_url) == 0
- || path.find(".asx", path.length()-4) != std::string::npos
- || path.find(".cue", path.length()-4) != std::string::npos
- || path.find(".m3u", path.length()-4) != std::string::npos
- || path.find(".pls", path.length()-4) != std::string::npos
- || path.find(".xspf", path.length()-5) != std::string::npos)
- Mpd.LoadPlaylist(path);
- else
+ try
+ {
Mpd.Add(path);
+ }
+ catch (MPD::ServerError &err)
+ {
+ // If a path is not a file or directory, assume it is a playlist.
+ if (err.code() == MPD_SERVER_ERROR_NO_EXIST)
+ Mpd.LoadPlaylist(path);
+ else
+ throw;
+ }
}
}