--- a/upmpd/upmpdutils.cxx
+++ b/upmpd/upmpdutils.cxx
@@ -46,11 +46,13 @@
#include "libupnpp/log.hxx" // for LOGERR
#include "libupnpp/soaphelp.hxx" // for xmlQuote
#include "libupnpp/upnpavutils.hxx" // for upnpduration
+#include "libupnpp/control/cdircontent.hxx"
#include "mpdcli.hxx" // for UpSong
using namespace std;
using namespace UPnPP;
+using namespace UPnPClient;
// Append system error string to input string
void catstrerror(string *reason, const char *what, int _errno)
@@ -395,6 +397,30 @@
return ss.str();
}
+bool uMetaToUpSong(const string& metadata, UpSong *ups)
+{
+ if (ups == 0)
+ return false;
+
+ UPnPDirContent dirc;
+ if (!dirc.parse(metadata) && dirc.m_items.size() == 0) {
+ return false;
+ }
+ UPnPDirObject& dobj = *dirc.m_items.begin();
+
+ ups->artist = dobj.f2s("upnp:artist", false);
+ ups->album = dobj.f2s("upnp:album", false);
+ ups->title = dobj.m_title;
+ string stmp = dobj.f2s("duration", true);
+ if (!stmp.empty()) {
+ ups->duration_secs = upnpdurationtos(stmp);
+ } else {
+ ups->duration_secs = 0;
+ }
+ ups->tracknum = dobj.f2s("upnp:originalTrackNumber", false);
+ return true;
+}
+
// Substitute regular expression
// The c++11 regex package does not seem really ready from prime time
// (Tried on gcc + libstdc++ 4.7.2-5 on Debian, with little