--- a/src/mediaserver/cdplugins/plgwithslave.cxx
+++ b/src/mediaserver/cdplugins/plgwithslave.cxx
@@ -40,6 +40,10 @@
#include "netfetch.h"
#include "curlfetch.h"
+#ifdef ENABLE_SPOTIFY
+#include "spotify/spotiproxy.h"
+#endif
+
using namespace std;
using namespace std::placeholders;
//using json = nlohmann::json;
@@ -83,6 +87,14 @@
if (g_config->get("plgproxymethod", val) && !val.compare("proxy")) {
doingproxy = true;
}
+#ifdef ENABLE_SPOTIFY
+ if (!plg->getname().compare("spotify")) {
+ g_config->get("spotifyuser", user);
+ g_config->get("spotifypass", password);
+ string cachedir = path_cat(g_cachedir, "spotify");
+ SpotiProxy::setParams(user, password, cachedir, cachedir);
+ }
+#endif
}
bool doproxy() {
@@ -100,6 +112,12 @@
// path prefix (this is used by upmpdcli that gets it for us).
string pathprefix;
bool doingproxy{false};
+
+ // This is only used by spotify (also needs login in the c++
+ // streamer in addition to python). We could create a derived
+ // class, but seems simpler this way.
+ string user;
+ string password;
// Cached uri translation
StreamHandle laststream;
@@ -145,7 +163,16 @@
StreamProxy::UrlTransReturn method = realplg->doproxy() ?
StreamProxy::Proxy : StreamProxy::Redirect;
if (method == StreamProxy::Proxy) {
- fetcher = std::move(std::unique_ptr<NetFetch>(new CurlFetch(url)));
+ if (!realplg->getname().compare("spotify")) {
+#ifdef ENABLE_SPOTIFY
+ fetcher = std::move(std::unique_ptr<NetFetch>(new SpotiFetch(url)));
+#else
+ LOGERR("Spotify URL but Spotify not supported by build\n");
+ return StreamProxy::Error;
+#endif
+ } else {
+ fetcher = std::move(std::unique_ptr<NetFetch>(new CurlFetch(url)));
+ }
}
return method;
}