summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcrvi <crvisqr@gmail.com>2020-10-01 01:39:34 +0530
committerBastien Nocera <hadess@hadess.net>2021-02-23 17:52:33 +0100
commitc2e1a8e32a0c59d555e301c9dbb90db73953a76c (patch)
treed9c7a4cdb3207c9e9a5477edaacb632c17a36c1c
parent779e5b89ca91ba1db3fd94502e0299fa389eabcd (diff)
downloadtotem-pl-parser-c2e1a8e32a0c59d555e301c9dbb90db73953a76c.tar.gz
podcast: Add support for item content rating
-rw-r--r--plparse/tests/parser.c22
-rw-r--r--plparse/totem-pl-parser-podcast.c7
2 files changed, 27 insertions, 2 deletions
diff --git a/plparse/tests/parser.c b/plparse/tests/parser.c
index 635b3f8..6016a49 100644
--- a/plparse/tests/parser.c
+++ b/plparse/tests/parser.c
@@ -963,6 +963,27 @@ test_parsing_feed_explicit (void)
}
static void
+test_parsing_item_explicit (void)
+{
+ char *uri;
+
+ /* clean item */
+ uri = get_relative_uri (TEST_SRCDIR "podcast-image-url.1.rss");
+ g_assert_cmpstr (parser_test_get_entry_field (uri, TOTEM_PL_PARSER_FIELD_CONTENT_RATING), ==, TOTEM_PL_PARSER_CONTENT_RATING_CLEAN);
+ g_free (uri);
+
+ /* explicit item */
+ uri = get_relative_uri (TEST_SRCDIR "podcast-empty-description.rss");
+ g_assert_cmpstr (parser_test_get_entry_field (uri, TOTEM_PL_PARSER_FIELD_CONTENT_RATING), ==, TOTEM_PL_PARSER_CONTENT_RATING_EXPLICIT);
+ g_free (uri);
+
+ /* unrated item */
+ uri = get_relative_uri (TEST_SRCDIR "content-no-rating.rss");
+ g_assert_cmpstr (parser_test_get_entry_field (uri, TOTEM_PL_PARSER_FIELD_CONTENT_RATING), ==, TOTEM_PL_PARSER_CONTENT_RATING_UNRATED);
+ g_free (uri);
+}
+
+static void
test_parsing_hadess (void)
{
if (g_strcmp0 (g_get_user_name (), "hadess") == 0)
@@ -1650,6 +1671,7 @@ main (int argc, char *argv[])
g_test_add_func ("/parser/parsing/podcast_feed_pubdate", test_parsing_feed_pubdate);
g_test_add_func ("/parser/parsing/podcast_feed_author", test_parsing_feed_author);
g_test_add_func ("/parser/parsing/podcast_feed_explicit", test_parsing_feed_explicit);
+ g_test_add_func ("/parser/parsing/podcast_item_explicit", test_parsing_item_explicit);
g_test_add_func ("/parser/parsing/live_streaming", test_parsing_live_streaming);
g_test_add_func ("/parser/parsing/xml_mixed_cdata", test_parsing_xml_mixed_cdata);
g_test_add_func ("/parser/parsing/m3u_streaming", test_parsing_m3u_streaming);
diff --git a/plparse/totem-pl-parser-podcast.c b/plparse/totem-pl-parser-podcast.c
index 1869a68..d1ba4e1 100644
--- a/plparse/totem-pl-parser-podcast.c
+++ b/plparse/totem-pl-parser-podcast.c
@@ -191,12 +191,12 @@ get_content_rating (const char *value)
static TotemPlParserResult
parse_rss_item (TotemPlParser *parser, xml_node_t *parent)
{
- const char *title, *uri, *description, *author, *img;
+ const char *title, *uri, *description, *author, *img, *explicit;
const char *pub_date, *duration, *filesize, *content_type, *id;
xml_node_t *node;
title = uri = description = author = content_type = NULL;
- img = pub_date = duration = filesize = id = NULL;
+ img = pub_date = duration = filesize = id = explicit = NULL;
for (node = parent->child; node != NULL; node = node->next) {
if (node->name == NULL)
@@ -289,6 +289,8 @@ parse_rss_item (TotemPlParser *parser, xml_node_t *parent)
tmp = xml_parser_get_property (node, "href");
if (tmp != NULL)
img = tmp;
+ } else if (g_ascii_strcasecmp (node->name, "itunes:explicit") == 0) {
+ explicit = node->data;
}
}
@@ -309,6 +311,7 @@ parse_rss_item (TotemPlParser *parser, xml_node_t *parent)
TOTEM_PL_PARSER_FIELD_FILESIZE, filesize,
TOTEM_PL_PARSER_FIELD_CONTENT_TYPE, content_type,
TOTEM_PL_PARSER_FIELD_IMAGE_URI, img,
+ TOTEM_PL_PARSER_FIELD_CONTENT_RATING, get_content_rating (explicit),
NULL);
}