aboutsummaryrefslogtreecommitdiffstats
path: root/src/db/upnp/Directory.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/db/upnp/Directory.cxx')
-rw-r--r--src/db/upnp/Directory.cxx29
1 files changed, 14 insertions, 15 deletions
diff --git a/src/db/upnp/Directory.cxx b/src/db/upnp/Directory.cxx
index cbe025e7a..8930890f3 100644
--- a/src/db/upnp/Directory.cxx
+++ b/src/db/upnp/Directory.cxx
@@ -36,16 +36,6 @@ static const char *const upnptags[] = {
nullptr,
};
-static const char *const res_attributes[] = {
- "protocolInfo",
- "size",
- "bitrate",
- "duration",
- "sampleFrequency",
- "nrAudioChannels",
- nullptr,
-};
-
gcc_pure
static UPnPDirObject::ItemClass
ParseItemClass(const char *name)
@@ -58,6 +48,16 @@ ParseItemClass(const char *name)
return UPnPDirObject::ItemClass::UNKNOWN;
}
+gcc_pure
+static int
+ParseDuration(const std::string &duration)
+{
+ const auto v = stringToTokens(duration, ":");
+ if (v.size() != 3)
+ return 0;
+ return atoi(v[0].c_str())*3600 + atoi(v[1].c_str())*60 + atoi(v[2].c_str());
+}
+
/**
* An XML parser which builds directory contents from DIDL lite input.
*/
@@ -114,11 +114,10 @@ protected:
// bitrate="24576" duration="00:03:35" sampleFrequency="44100"
// nrAudioChannels="2">
- for (auto i = res_attributes; *i != nullptr; ++i) {
- const char *value = GetAttribute(attrs, *i);
- if (value != nullptr)
- m_tobj.m_props.emplace(*i, value);
- }
+ const char *duration =
+ GetAttribute(attrs, "duration");
+ if (duration != nullptr)
+ m_tobj.duration = ParseDuration(duration);
}
break;