[totem-pl-parser/wip/hadess/atom-podcast-fixes: 4/4] podcast: Add support for the "media:group" Atom node



commit 26214680a5097c56f03b8702d40dc00f00c76936
Author: Bastien Nocera <hadess hadess net>
Date:   Mon Feb 11 03:17:24 2019 +0100

    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

 plparse/totem-pl-parser-podcast.c | 32 ++++++++++++++++++++++++++++++--
 1 file 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);
        }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]