Playlist: Restrict RSS feeds to the newest 20 entries. Keep them in the correct order, starting with the last (newest) one.
This commit is contained in:
parent
0dd5937707
commit
ecc7c46b8d
@ -135,6 +135,7 @@ void xmlcb(uint8_t status, char* tagName, uint16_t tagLen, char* data, uint16_t
|
|||||||
xml_enclosure_url = "";
|
xml_enclosure_url = "";
|
||||||
} else if (tag.endsWith("/item") && (status & STATUS_END_TAG)) {
|
} else if (tag.endsWith("/item") && (status & STATUS_END_TAG)) {
|
||||||
if (xml_title.length()>0 && xml_url.length()>0) {
|
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());
|
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_files_ptr->insert(xml_files_ptr->begin(), {.filename=xml_url, .title=xml_title, .id=xml_guid});
|
||||||
}
|
}
|
||||||
@ -158,6 +159,7 @@ void Playlist::_parse_rss(HTTPClientWrapper* http) {
|
|||||||
while ((i = http->read()) >= 0) {
|
while ((i = http->read()) >= 0) {
|
||||||
xml.processChar(i);
|
xml.processChar(i);
|
||||||
}
|
}
|
||||||
|
_current_track = _files.size()-1;
|
||||||
xml_files_ptr = NULL;
|
xml_files_ptr = NULL;
|
||||||
if (xml_album_title.length()>0) {
|
if (xml_album_title.length()>0) {
|
||||||
_title = xml_album_title;
|
_title = xml_album_title;
|
||||||
@ -382,6 +384,7 @@ void Playlist::json(JsonObject json) {
|
|||||||
JsonObject o = files.createNestedObject();
|
JsonObject o = files.createNestedObject();
|
||||||
o["filename"] = entry.filename;
|
o["filename"] = entry.filename;
|
||||||
o["title"] = entry.title;
|
o["title"] = entry.title;
|
||||||
|
o["id"] = entry.id;
|
||||||
}
|
}
|
||||||
json["current_track"] = _current_track;
|
json["current_track"] = _current_track;
|
||||||
json["has_track_next"] = has_track_next();
|
json["has_track_next"] = has_track_next();
|
||||||
|
Loading…
Reference in New Issue
Block a user