From 5a872dc436591195cec9c046de3e2c9419cad32b Mon Sep 17 00:00:00 2001 From: whatdoineed2do/Ray Date: Sun, 26 Apr 2020 16:59:01 +0100 Subject: [PATCH] [library] rss pulls channel->image->url if available --- src/library/rssscanner.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/library/rssscanner.c b/src/library/rssscanner.c index 87bbbf3d..150eeb0c 100644 --- a/src/library/rssscanner.c +++ b/src/library/rssscanner.c @@ -281,7 +281,7 @@ rss_xml_get(const char *url) } static int -rss_xml_parse_feed(const char **feed_title, const char **feed_author, mxml_node_t *xml) +rss_xml_parse_feed(const char **feed_title, const char **feed_author, const char **feed_artwork, mxml_node_t *xml) { mxml_node_t *channel; mxml_node_t *node; @@ -304,6 +304,14 @@ rss_xml_parse_feed(const char **feed_title, const char **feed_author, mxml_node_ node = mxmlFindElement(channel, channel, "itunes:author", NULL, NULL, MXML_DESCEND_FIRST); *feed_author = node ? mxmlGetOpaque(node) : NULL; + *feed_artwork = NULL; + node = mxmlFindElement(channel, channel, "image", NULL, NULL, MXML_DESCEND_FIRST); + if (node) + { + node = mxmlFindElement(node, node, "url", NULL, NULL, MXML_DESCEND_FIRST); + *feed_artwork = node ? mxmlGetOpaque(node) : NULL; + } + return 0; } @@ -405,6 +413,7 @@ rss_save(struct playlist_info *pli, int *count, enum rss_scan_type scan_type) mxml_node_t *xml; const char *feed_title; const char *feed_author; + const char *feed_artwork; struct media_file_info mfi = { 0 }; struct rss_item_info ri; uint32_t time_added; @@ -418,7 +427,7 @@ rss_save(struct playlist_info *pli, int *count, enum rss_scan_type scan_type) return -1; } - ret = rss_xml_parse_feed(&feed_title, &feed_author, xml); + ret = rss_xml_parse_feed(&feed_title, &feed_author, &feed_artwork, xml); if (ret < 0) { DPRINTF(E_LOG, L_LIB, "Invalid RSS/xml received from '%s' (id %d)\n", pli->path, pli->id); @@ -429,6 +438,9 @@ rss_save(struct playlist_info *pli, int *count, enum rss_scan_type scan_type) free(pli->title); pli->title = safe_strdup(feed_title); + free(pli->artwork_url); + pli->artwork_url = safe_strdup(feed_artwork); + free(pli->virtual_path); pli->virtual_path = safe_asprintf("/%s", pli->path);