[totem-pl-parser] podcast: Look for item content type in all relevant tags



commit 6751ce434ef5f1858f2a190704d9399f3ed45d9b
Author: crvi <crvisqr gmail com>
Date:   Wed Jul 29 03:21:20 2020 +0530

    podcast: Look for item content type in all relevant tags
    
    We expect that <media:content type='...'> and <enclosure type='...'>
    content-type values to be same for a podcast item. We don't report an
    error if the content-type from the tags differ. The content-type in
    the later occuring tag replaces the previous one.

 plparse/tests/parser.c            | 22 ++++++++++++++++++++++
 plparse/totem-pl-parser-podcast.c |  8 +++++++-
 2 files changed, 29 insertions(+), 1 deletion(-)
---
diff --git a/plparse/tests/parser.c b/plparse/tests/parser.c
index 14a695f..ca97945 100644
--- a/plparse/tests/parser.c
+++ b/plparse/tests/parser.c
@@ -751,9 +751,31 @@ static void
 test_parsing_content_type (void)
 {
        char *uri;
+
+       /* no audio content */
+       uri = get_relative_uri (TEST_SRCDIR "no-url-podcast.xml");
+       g_assert_cmpstr (parser_test_get_entry_field (uri, TOTEM_PL_PARSER_FIELD_CONTENT_TYPE), ==, NULL);
+       g_free (uri);
+
+       /* <enclosure> without <media:content> */
+       uri = get_relative_uri (TEST_SRCDIR "podcast-description.rss");
+       g_assert_cmpstr (parser_test_get_entry_field (uri, TOTEM_PL_PARSER_FIELD_CONTENT_TYPE), ==, 
"audio/mpeg");
+       g_free (uri);
+
+       /* <media:content> followed by <enclosure> */
        uri = get_relative_uri (TEST_SRCDIR "HackerMedley");
        g_assert_cmpstr (parser_test_get_entry_field (uri, TOTEM_PL_PARSER_FIELD_CONTENT_TYPE), ==, 
"audio/mpeg");
        g_free (uri);
+
+       /* <enclosure> followed by <media:content> */
+       uri = get_relative_uri (TEST_SRCDIR "podcast-image-url.2.rss");
+       g_assert_cmpstr (parser_test_get_entry_field (uri, TOTEM_PL_PARSER_FIELD_CONTENT_TYPE), ==, 
"audio/mpeg");
+       g_free (uri);
+
+       /* <enclosure> followed by <media:content> with image */
+       uri = get_relative_uri (TEST_SRCDIR "791154-kqed.rss");
+       g_assert_cmpstr (parser_test_get_entry_field (uri, TOTEM_PL_PARSER_FIELD_CONTENT_TYPE), ==, 
"audio/mpeg");
+       g_free (uri);
 }
 
 static void
diff --git a/plparse/totem-pl-parser-podcast.c b/plparse/totem-pl-parser-podcast.c
index 47c33cc..237795e 100644
--- a/plparse/totem-pl-parser-podcast.c
+++ b/plparse/totem-pl-parser-podcast.c
@@ -196,7 +196,9 @@ parse_rss_item (TotemPlParser *parser, xml_node_t *parent)
                                }
                                continue;
                        }
-                       content_type = tmp;
+
+                       if (tmp != NULL)
+                               content_type = tmp;
 
                        tmp = xml_parser_get_property (node, "url");
                        if (tmp != NULL)
@@ -222,6 +224,10 @@ parse_rss_item (TotemPlParser *parser, xml_node_t *parent)
                        tmp = xml_parser_get_property (node, "length");
                        if (tmp != NULL)
                                filesize = tmp;
+
+                       tmp = xml_parser_get_property (node, "type");
+                       if (tmp != NULL)
+                               content_type = tmp;
                } else if (g_ascii_strcasecmp (node->name, "link") == 0 &&
                           totem_pl_parser_is_videosite (node->data, FALSE) != FALSE) {
                        uri = node->data;


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