diff options
author | Bastien Nocera <hadess@hadess.net> | 2019-02-11 03:17:24 +0100 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2019-02-11 03:17:24 +0100 |
commit | 26214680a5097c56f03b8702d40dc00f00c76936 (patch) | |
tree | 4833aa035fa83e4ab9cbd401e639644e66868054 | |
parent | c2435b7f8ffb2fa3af51d2c021976eb6e5282679 (diff) | |
download | totem-pl-parser-26214680a5097c56f03b8702d40dc00f00c76936.tar.gz |
podcast: Add support for the "media:group" Atom node
As used in YouTube feeds, such as:
https://www.youtube.com/feeds/videos.xml?channel_id=UCLEoyoOKZK0idGqSc6Pi23w
-rw-r--r-- | plparse/totem-pl-parser-podcast.c | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/plparse/totem-pl-parser-podcast.c b/plparse/totem-pl-parser-podcast.c index ef968fe..9e2249e 100644 --- a/plparse/totem-pl-parser-podcast.c +++ b/plparse/totem-pl-parser-podcast.c @@ -406,11 +406,11 @@ static TotemPlParserResult parse_atom_entry (TotemPlParser *parser, xml_node_t *parent) { const char *title, *author, *uri, *filesize; - const char *copyright, *pub_date, *description; + const char *copyright, *pub_date, *description, *img; xml_node_t *node; title = author = uri = filesize = NULL; - copyright = pub_date = description = NULL; + copyright = pub_date = description = img = NULL; for (node = parent->child; node != NULL; node = node->next) { if (node->name == NULL) @@ -472,6 +472,33 @@ parse_atom_entry (TotemPlParser *parser, xml_node_t *parent) type = xml_parser_get_property (node, "content"); if (type != NULL && g_ascii_strcasecmp (type, "text/plain") == 0) description = node->data; + } else if (g_ascii_strcasecmp (node->name, "media:group") == 0) { + xml_node_t *child; + + for (child = node->child; child != NULL; child = child->next) { + if (child->name == NULL) + continue; + + if (g_ascii_strcasecmp (child->name, "media:title") == 0 && + title == NULL) { + title = child->data; + } else if (g_ascii_strcasecmp (child->name, "media:description") == 0 && + description == NULL) { + description = child->data; + } else if (g_ascii_strcasecmp (child->name, "media:content") == 0 && + uri == NULL) { + const char *prop; + + prop = xml_parser_get_property (child, "url"); + if (prop == NULL) + continue; + if (!totem_pl_parser_is_videosite (prop, FALSE)) + continue; + uri = prop; + } else if (g_ascii_strcasecmp (child->name, "media:thumbnail") == 0) { + img = xml_parser_get_property (child, "url"); + } + } } //FIXME handle category } @@ -485,6 +512,7 @@ parse_atom_entry (TotemPlParser *parser, xml_node_t *parent) TOTEM_PL_PARSER_FIELD_COPYRIGHT, copyright, TOTEM_PL_PARSER_FIELD_PUB_DATE, pub_date, TOTEM_PL_PARSER_FIELD_DESCRIPTION, description, + TOTEM_PL_PARSER_FIELD_IMAGE_URI, img, NULL); } |