summaryrefslogtreecommitdiff
path: root/src/playlist
diff options
context:
space:
mode:
Diffstat (limited to 'src/playlist')
-rw-r--r--src/playlist/PlaylistSong.cxx26
-rw-r--r--src/playlist/Print.cxx12
-rw-r--r--src/playlist/cue/CueParser.cxx4
-rw-r--r--src/playlist/cue/CueParser.hxx2
-rw-r--r--src/playlist/plugins/AsxPlaylistPlugin.cxx2
-rw-r--r--src/playlist/plugins/EmbeddedCuePlaylistPlugin.cxx2
-rw-r--r--src/playlist/plugins/ExtM3uPlaylistPlugin.cxx4
-rw-r--r--src/playlist/plugins/M3uPlaylistPlugin.cxx2
-rw-r--r--src/playlist/plugins/PlsPlaylistPlugin.cxx4
-rw-r--r--src/playlist/plugins/RssPlaylistPlugin.cxx2
-rw-r--r--src/playlist/plugins/SoundCloudPlaylistPlugin.cxx40
-rw-r--r--src/playlist/plugins/XspfPlaylistPlugin.cxx2
12 files changed, 48 insertions, 54 deletions
diff --git a/src/playlist/PlaylistSong.cxx b/src/playlist/PlaylistSong.cxx
index ed41266e0..12cd4bdb0 100644
--- a/src/playlist/PlaylistSong.cxx
+++ b/src/playlist/PlaylistSong.cxx
@@ -21,7 +21,7 @@
#include "PlaylistSong.hxx"
#include "SongLoader.hxx"
#include "tag/Tag.hxx"
-#include "tag/TagBuilder.hxx"
+#include "tag/Builder.hxx"
#include "fs/Traits.hxx"
#include "util/UriUtil.hxx"
#include "DetachedSong.hxx"
@@ -44,25 +44,17 @@ merge_song_metadata(DetachedSong &add, const DetachedSong &base)
static bool
playlist_check_load_song(DetachedSong &song, const SongLoader &loader)
-{
- DetachedSong *tmp;
-
- try {
- tmp = loader.LoadSong(song.GetURI());
- } catch (const std::runtime_error &) {
- return false;
- }
-
- if (tmp == nullptr)
- return false;
+try {
+ DetachedSong tmp = loader.LoadSong(song.GetURI());
- song.SetURI(tmp->GetURI());
- if (!song.HasRealURI() && tmp->HasRealURI())
- song.SetRealURI(tmp->GetRealURI());
+ song.SetURI(tmp.GetURI());
+ if (!song.HasRealURI() && tmp.HasRealURI())
+ song.SetRealURI(tmp.GetRealURI());
- merge_song_metadata(song, *tmp);
- delete tmp;
+ merge_song_metadata(song, tmp);
return true;
+} catch (const std::runtime_error &) {
+ return false;
}
bool
diff --git a/src/playlist/Print.cxx b/src/playlist/Print.cxx
index 72178a469..6dd0509df 100644
--- a/src/playlist/Print.cxx
+++ b/src/playlist/Print.cxx
@@ -31,7 +31,7 @@
#include "Instance.hxx"
static void
-playlist_provider_print(Response &r, Partition &partition,
+playlist_provider_print(Response &r,
const SongLoader &loader,
const char *uri,
SongEnumerator &e, bool detail)
@@ -45,11 +45,11 @@ playlist_provider_print(Response &r, Partition &partition,
if (playlist_check_translate_song(*song, base_uri.c_str(),
loader) &&
detail)
- song_print_info(r, partition, *song);
+ song_print_info(r, *song);
else
/* fallback if no detail was requested or no
detail was available */
- song_print_uri(r, partition, *song);
+ song_print_uri(r, *song);
}
}
@@ -61,6 +61,10 @@ playlist_file_print(Response &r, Partition &partition,
Mutex mutex;
Cond cond;
+#ifndef ENABLE_DATABASE
+ (void)partition;
+#endif
+
SongEnumerator *playlist = playlist_open_any(uri,
#ifdef ENABLE_DATABASE
partition.instance.storage,
@@ -69,7 +73,7 @@ playlist_file_print(Response &r, Partition &partition,
if (playlist == nullptr)
return false;
- playlist_provider_print(r, partition, loader, uri, *playlist, detail);
+ playlist_provider_print(r, loader, uri, *playlist, detail);
delete playlist;
return true;
}
diff --git a/src/playlist/cue/CueParser.cxx b/src/playlist/cue/CueParser.cxx
index acdd55483..b04eede76 100644
--- a/src/playlist/cue/CueParser.cxx
+++ b/src/playlist/cue/CueParser.cxx
@@ -19,10 +19,10 @@
#include "config.h"
#include "CueParser.hxx"
+#include "tag/ParseName.hxx"
#include "util/Alloc.hxx"
-#include "util/StringUtil.hxx"
+#include "util/StringStrip.hxx"
#include "util/CharUtil.hxx"
-#include "tag/Tag.hxx"
#include <assert.h>
#include <string.h>
diff --git a/src/playlist/cue/CueParser.hxx b/src/playlist/cue/CueParser.hxx
index 6c84ddd4f..be89a543e 100644
--- a/src/playlist/cue/CueParser.hxx
+++ b/src/playlist/cue/CueParser.hxx
@@ -22,7 +22,7 @@
#include "check.h"
#include "DetachedSong.hxx"
-#include "tag/TagBuilder.hxx"
+#include "tag/Builder.hxx"
#include "Compiler.h"
#include <string>
diff --git a/src/playlist/plugins/AsxPlaylistPlugin.cxx b/src/playlist/plugins/AsxPlaylistPlugin.cxx
index 5b5fe114a..9398f6a2e 100644
--- a/src/playlist/plugins/AsxPlaylistPlugin.cxx
+++ b/src/playlist/plugins/AsxPlaylistPlugin.cxx
@@ -21,7 +21,7 @@
#include "AsxPlaylistPlugin.hxx"
#include "../PlaylistPlugin.hxx"
#include "../MemorySongEnumerator.hxx"
-#include "tag/TagBuilder.hxx"
+#include "tag/Builder.hxx"
#include "util/ASCII.hxx"
#include "util/StringView.hxx"
#include "lib/expat/ExpatParser.hxx"
diff --git a/src/playlist/plugins/EmbeddedCuePlaylistPlugin.cxx b/src/playlist/plugins/EmbeddedCuePlaylistPlugin.cxx
index 9046f35da..3be9c0652 100644
--- a/src/playlist/plugins/EmbeddedCuePlaylistPlugin.cxx
+++ b/src/playlist/plugins/EmbeddedCuePlaylistPlugin.cxx
@@ -28,7 +28,7 @@
#include "../PlaylistPlugin.hxx"
#include "../SongEnumerator.hxx"
#include "../cue/CueParser.hxx"
-#include "tag/TagHandler.hxx"
+#include "tag/Handler.hxx"
#include "tag/Generic.hxx"
#include "DetachedSong.hxx"
#include "TagFile.hxx"
diff --git a/src/playlist/plugins/ExtM3uPlaylistPlugin.cxx b/src/playlist/plugins/ExtM3uPlaylistPlugin.cxx
index 9f1faa04f..627597be0 100644
--- a/src/playlist/plugins/ExtM3uPlaylistPlugin.cxx
+++ b/src/playlist/plugins/ExtM3uPlaylistPlugin.cxx
@@ -23,8 +23,8 @@
#include "../SongEnumerator.hxx"
#include "DetachedSong.hxx"
#include "tag/Tag.hxx"
-#include "tag/TagBuilder.hxx"
-#include "util/StringUtil.hxx"
+#include "tag/Builder.hxx"
+#include "util/StringStrip.hxx"
#include "util/StringCompare.hxx"
#include "input/TextInputStream.hxx"
#include "input/InputStream.hxx"
diff --git a/src/playlist/plugins/M3uPlaylistPlugin.cxx b/src/playlist/plugins/M3uPlaylistPlugin.cxx
index b76181805..6980cda21 100644
--- a/src/playlist/plugins/M3uPlaylistPlugin.cxx
+++ b/src/playlist/plugins/M3uPlaylistPlugin.cxx
@@ -22,8 +22,8 @@
#include "../PlaylistPlugin.hxx"
#include "../SongEnumerator.hxx"
#include "DetachedSong.hxx"
-#include "util/StringUtil.hxx"
#include "input/TextInputStream.hxx"
+#include "util/StringStrip.hxx"
class M3uPlaylist final : public SongEnumerator {
TextInputStream tis;
diff --git a/src/playlist/plugins/PlsPlaylistPlugin.cxx b/src/playlist/plugins/PlsPlaylistPlugin.cxx
index 0fe30aa6b..e8cc443cd 100644
--- a/src/playlist/plugins/PlsPlaylistPlugin.cxx
+++ b/src/playlist/plugins/PlsPlaylistPlugin.cxx
@@ -24,9 +24,9 @@
#include "input/TextInputStream.hxx"
#include "input/InputStream.hxx"
#include "DetachedSong.hxx"
-#include "tag/TagBuilder.hxx"
+#include "tag/Builder.hxx"
#include "util/ASCII.hxx"
-#include "util/StringUtil.hxx"
+#include "util/StringStrip.hxx"
#include "util/DivideString.hxx"
#include <string>
diff --git a/src/playlist/plugins/RssPlaylistPlugin.cxx b/src/playlist/plugins/RssPlaylistPlugin.cxx
index 290ad3510..39f34b3a9 100644
--- a/src/playlist/plugins/RssPlaylistPlugin.cxx
+++ b/src/playlist/plugins/RssPlaylistPlugin.cxx
@@ -21,7 +21,7 @@
#include "RssPlaylistPlugin.hxx"
#include "../PlaylistPlugin.hxx"
#include "../MemorySongEnumerator.hxx"
-#include "tag/TagBuilder.hxx"
+#include "tag/Builder.hxx"
#include "util/ASCII.hxx"
#include "util/StringView.hxx"
#include "lib/expat/ExpatParser.hxx"
diff --git a/src/playlist/plugins/SoundCloudPlaylistPlugin.cxx b/src/playlist/plugins/SoundCloudPlaylistPlugin.cxx
index a4dcb1972..573f60281 100644
--- a/src/playlist/plugins/SoundCloudPlaylistPlugin.cxx
+++ b/src/playlist/plugins/SoundCloudPlaylistPlugin.cxx
@@ -23,7 +23,7 @@
#include "../MemorySongEnumerator.hxx"
#include "config/Block.hxx"
#include "input/InputStream.hxx"
-#include "tag/TagBuilder.hxx"
+#include "tag/Builder.hxx"
#include "util/StringCompare.hxx"
#include "util/Alloc.hxx"
#include "util/Domain.hxx"
@@ -87,13 +87,6 @@ soundcloud_resolve(const char* uri)
/* YAJL parser for track data from both /tracks/ and /playlists/ JSON */
-enum key {
- Duration,
- Title,
- Stream_URL,
- Other,
-};
-
static const char *const key_str[] = {
"duration",
"title",
@@ -102,7 +95,14 @@ static const char *const key_str[] = {
};
struct SoundCloudJsonData {
- int key;
+ enum class Key {
+ DURATION,
+ TITLE,
+ STREAM_URL,
+ OTHER,
+ };
+
+ Key key;
std::string stream_url;
long duration;
std::string title;
@@ -117,7 +117,7 @@ handle_integer(void *ctx, long long intval)
auto *data = (SoundCloudJsonData *) ctx;
switch (data->key) {
- case Duration:
+ case SoundCloudJsonData::Key::DURATION:
data->duration = intval;
break;
default:
@@ -134,13 +134,15 @@ handle_string(void *ctx, const unsigned char *stringval, size_t stringlen)
const char *s = (const char *) stringval;
switch (data->key) {
- case Title:
+ case SoundCloudJsonData::Key::TITLE:
data->title.assign(s, stringlen);
break;
- case Stream_URL:
+
+ case SoundCloudJsonData::Key::STREAM_URL:
data->stream_url.assign(s, stringlen);
data->got_url = 1;
break;
+
default:
break;
}
@@ -153,16 +155,12 @@ handle_mapkey(void *ctx, const unsigned char *stringval, size_t stringlen)
{
auto *data = (SoundCloudJsonData *) ctx;
- int i;
- data->key = Other;
-
- for (i = 0; i < Other; ++i) {
- if (memcmp((const char *)stringval, key_str[i], stringlen) == 0) {
- data->key = i;
- break;
- }
- }
+ const auto *i = key_str;
+ while (*i != nullptr &&
+ !StringStartsWith(*i, {(const char *)stringval, stringlen}))
+ ++i;
+ data->key = SoundCloudJsonData::Key(i - key_str);
return 1;
}
diff --git a/src/playlist/plugins/XspfPlaylistPlugin.cxx b/src/playlist/plugins/XspfPlaylistPlugin.cxx
index 6cfd9a783..5ddf901f3 100644
--- a/src/playlist/plugins/XspfPlaylistPlugin.cxx
+++ b/src/playlist/plugins/XspfPlaylistPlugin.cxx
@@ -23,7 +23,7 @@
#include "../MemorySongEnumerator.hxx"
#include "DetachedSong.hxx"
#include "input/InputStream.hxx"
-#include "tag/TagBuilder.hxx"
+#include "tag/Builder.hxx"
#include "util/StringView.hxx"
#include "lib/expat/ExpatParser.hxx"
#include "Log.hxx"