From 23fbddb055068a8b50a1536ded42295e561664b5 Mon Sep 17 00:00:00 2001 From: Fabian Schlenz Date: Wed, 4 Dec 2019 05:57:58 +0100 Subject: [PATCH] TinyXML is broken, but I couldn't find an alternative nor fix it. So the code now is pretty hack-y to work around the bugs. --- src/playlist.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/playlist.cpp b/src/playlist.cpp index 17f69a2..c09bf6e 100644 --- a/src/playlist.cpp +++ b/src/playlist.cpp @@ -109,35 +109,34 @@ void xmlcb(uint8_t status, char* tagName, uint16_t tagLen, char* data, uint16_t if (tag.equals("/rss/channel/title") && (status & STATUS_TAG_TEXT)) { xml_album_title = data; - } else if (tag.endsWith("/item") && (status & STATUS_START_TAG)) { - xml_title = ""; - xml_url = ""; - xml_guid = ""; - } else if (tag.endsWith("/item/title") && (status & STATUS_TAG_TEXT)) { + } else if (tag.endsWith("/title") && (status & STATUS_TAG_TEXT)) { xml_title = String(data); - } else if (tag.endsWith("/item/guid") && (status & STATUS_TAG_TEXT)) { + } else if (tag.endsWith("/guid") && (status & STATUS_TAG_TEXT)) { xml_guid = data; //} else if (xml_last_tag.endsWith("/item/enclosure") && (status & STATUS_ATTR_TEXT)) { // DEBUG("tag: %s, data: %s\n", tag.c_str(), data); - } else if (xml_last_tag.endsWith("/item/enclosure") && tag.equals("type") && (status & STATUS_ATTR_TEXT) && String(data).indexOf("audio/")>=0) { + } else if (xml_last_tag.endsWith("/enclosure") && tag.equals("type") && (status & STATUS_ATTR_TEXT) && String(data).indexOf("audio/")>=0) { DEBUG("enclosure is audio\n"); xml_enclosure_is_audio = true; - } else if (xml_last_tag.endsWith("/item/enclosure") && tag.equals("url") && (status & STATUS_ATTR_TEXT)) { + } else if (xml_last_tag.endsWith("/enclosure") && tag.equals("url") && (status & STATUS_ATTR_TEXT)) { DEBUG("found url\n"); xml_enclosure_url = String(data); - } else if (tag.endsWith("/item/enclosure") && (status & STATUS_END_TAG)) { + } else if (tag.endsWith("/enclosure") && (status & STATUS_END_TAG)) { DEBUG("end of enclosure. xml_enclosure_is_audio: %d, xml_enclosure_url: %s\n", xml_enclosure_is_audio, xml_enclosure_url.c_str()); if (xml_enclosure_is_audio && xml_enclosure_url.length()>0) { xml_url = xml_enclosure_url; } xml_enclosure_is_audio = false; xml_enclosure_url = ""; - } else if (tag.endsWith("/item") && (status & STATUS_END_TAG)) { + } else if (tag.endsWith("/item") && (status & STATUS_END_TAG || status & STATUS_START_TAG)) { if (xml_title.length()>0 && xml_url.length()>0) { if (xml_files_ptr->size() > 20) return; DEBUG("Adding playlist entry: '%s' => '%s'\n", xml_title.c_str(), xml_url.c_str()); xml_files_ptr->insert(xml_files_ptr->begin(), {.filename=xml_url, .title=xml_title, .id=xml_guid}); } + xml_title = ""; + xml_url = ""; + xml_guid = ""; } }