| 1230 | |
| 1231 | #ifdef CONTENT_RSS |
| 1232 | bool getRssFeed(String &filename, String URL, String title, tagRecord *&taginfo, imgParam &imageParams) { |
| 1233 | // https://github.com/garretlab/shoddyxml2 |
| 1234 | |
| 1235 | // http://feeds.feedburner.com/tweakers/nieuws |
| 1236 | // https://www.nu.nl/rss/Algemeen |
| 1237 | |
| 1238 | wsLog("get rss feed"); |
| 1239 | |
| 1240 | const char *url = URL.c_str(); |
| 1241 | const int rssTitleSize = 255; |
| 1242 | const int rssDescSize = 1000; |
| 1243 | |
| 1244 | TFT_eSprite spr = TFT_eSprite(&tft); |
| 1245 | |
| 1246 | JsonDocument loc; |
| 1247 | getTemplate(loc, 9, taginfo->hwType); |
| 1248 | initSprite(spr, imageParams.width, imageParams.height, imageParams); |
| 1249 | // stampTime(spr); |
| 1250 | |
| 1251 | if (util::isEmptyOrNull(title)) title = "RSS feed"; |
| 1252 | drawString(spr, title, loc["title"][0], loc["title"][1], loc["title"][2], TL_DATUM, TFT_BLACK, loc["title"][3]); |
| 1253 | int16_t posx = loc["line"][0]; |
| 1254 | int16_t posy = loc["line"][1]; |
| 1255 | int n = reader.getArticles(url, rssTitleSize, rssDescSize, loc["items"]); |
| 1256 | |
| 1257 | float lineheight = loc["desc"][3].as<float>(); |
| 1258 | for (int i = 0; i < n; i++) { |
| 1259 | // if (reader.titleData[i] != NULL && *reader.titleData[i] != NULL) { |
| 1260 | if (reader.titleData[i] != NULL) { |
| 1261 | String title = String(reader.titleData[i]); |
| 1262 | replaceHTMLentities(title); |
| 1263 | removeHTML(title); |
| 1264 | |
| 1265 | if (!util::isEmptyOrNull(title)) { |
| 1266 | drawTextBox(spr, title, posx, posy, imageParams.width - 2 * posx, 100, loc["line"][2], TFT_BLACK); |
| 1267 | } |
| 1268 | } |
| 1269 | // if (reader.descData[i] != NULL && *reader.descData[i] != NULL) { |
| 1270 | if (reader.descData[i] != NULL && loc["desc"][2] != "") { |
| 1271 | String desc = String(reader.descData[i]); |
| 1272 | replaceHTMLentities(desc); |
| 1273 | removeHTML(desc); |
| 1274 | |
| 1275 | if (!util::isEmptyOrNull(desc)) { |
| 1276 | posy += loc["desc"][0].as<int>(); |
| 1277 | drawTextBox(spr, desc, posx, posy, imageParams.width - 2 * posx, 100, loc["desc"][2], TFT_BLACK, TFT_WHITE, lineheight); |
| 1278 | posy += loc["desc"][1].as<int>(); |
| 1279 | } |
| 1280 | } else { |
| 1281 | posy += loc["desc"][1].as<int>(); |
| 1282 | } |
| 1283 | } |
| 1284 | reader.clearItemData(); |
| 1285 | |
| 1286 | spr2buffer(spr, filename, imageParams); |
| 1287 | spr.deleteSprite(); |
| 1288 | |
| 1289 | return true; |
no test coverage detected