summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcrvi <crvisqr@gmail.com>2021-04-11 19:17:06 +0530
committercrvi <crvisqr@gmail.com>2021-09-15 16:07:42 +0530
commit701935b57df2b89dbcbcc1d6021f4939c647f337 (patch)
tree3de407e1563908570d8a39d9b73019002a6cafc8
parentfb6eaaee686a4071532ec9cb62110819c38f170e (diff)
downloadtotem-pl-parser-701935b57df2b89dbcbcc1d6021f4939c647f337.tar.gz
tests: Add itunes genre ( <itunes:category> ) support for podcast rss feeds
-rw-r--r--plparse/tests/content-no-rating.rss10
-rw-r--r--plparse/tests/parser.c49
2 files changed, 59 insertions, 0 deletions
diff --git a/plparse/tests/content-no-rating.rss b/plparse/tests/content-no-rating.rss
index f068d6d..6e01826 100644
--- a/plparse/tests/content-no-rating.rss
+++ b/plparse/tests/content-no-rating.rss
@@ -5,6 +5,7 @@
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
+ xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
>
<channel>
@@ -27,6 +28,15 @@
<width>32</width>
<height>32</height>
</image>
+ <itunes:category text="Health &amp; Fitness">
+ <itunes:category text="Alternative Health"/>
+ </itunes:category>
+ <itunes:category text="Education">
+ <itunes:category text="Self-Improvement"/>
+ </itunes:category>
+ <itunes:category text="Health &amp; Fitness">
+ <itunes:category text="Nutrition"/>
+ </itunes:category>
<item>
<title>Escape Pod 769: Deal</title>
<link>https://escapepod.org/2021/01/28/escape-pod-769-deal/</link>
diff --git a/plparse/tests/parser.c b/plparse/tests/parser.c
index 35f62f2..1a3aa4d 100644
--- a/plparse/tests/parser.c
+++ b/plparse/tests/parser.c
@@ -1085,6 +1085,54 @@ test_parsing_xml_cdata (void)
}
static void
+test_parsing_feed_genres (void)
+{
+ char *uri;
+
+ /* missing genre */
+ uri = get_relative_uri (TEST_SRCDIR "541405.rss");
+ g_assert_cmpstr (parser_test_get_playlist_field (uri, TOTEM_PL_PARSER_FIELD_GENRE), ==, NULL);
+ g_assert_cmpstr (parser_test_get_playlist_field (uri, TOTEM_PL_PARSER_FIELD_GENRES), ==, NULL);
+ g_free (uri);
+
+ /* single genre 1 */
+ uri = get_relative_uri (TEST_SRCDIR "podcast-description.rss");
+ g_assert_cmpstr (parser_test_get_playlist_field (uri, TOTEM_PL_PARSER_FIELD_GENRE), ==, "Society & Culture");
+ g_assert_cmpstr (parser_test_get_playlist_field (uri, TOTEM_PL_PARSER_FIELD_GENRES), ==, "Society & Culture");
+ g_free (uri);
+
+ /* single genre 2 */
+ uri = get_relative_uri (TEST_SRCDIR "791154-kqed.rss");
+ g_assert_cmpstr (parser_test_get_playlist_field (uri, TOTEM_PL_PARSER_FIELD_GENRE), ==, "News & Politics");
+ g_assert_cmpstr (parser_test_get_playlist_field (uri, TOTEM_PL_PARSER_FIELD_GENRES), ==, "News & Politics");
+ g_free (uri);
+
+ /* single genre (with single subgenre) */
+ uri = get_relative_uri (TEST_SRCDIR "HackerMedley");
+ g_assert_cmpstr (parser_test_get_playlist_field (uri, TOTEM_PL_PARSER_FIELD_GENRE), ==, "Technology/Tech News");
+ g_assert_cmpstr (parser_test_get_playlist_field (uri, TOTEM_PL_PARSER_FIELD_GENRES), ==, "Technology/Tech News");
+ g_free (uri);
+
+ /* multiple genre 1 */
+ uri = get_relative_uri (TEST_SRCDIR "560051.xml");
+ g_assert_cmpstr (parser_test_get_playlist_field (uri, TOTEM_PL_PARSER_FIELD_GENRE), ==, "Society & Culture");
+ g_assert_cmpstr (parser_test_get_playlist_field (uri, TOTEM_PL_PARSER_FIELD_GENRES), ==, "Society & Culture,News & Politics,Religion & Spirituality");
+ g_free (uri);
+
+ /* multiple genre (with single subgenre) */
+ uri = get_relative_uri (TEST_SRCDIR "585407.rss");
+ g_assert_cmpstr (parser_test_get_playlist_field (uri, TOTEM_PL_PARSER_FIELD_GENRE), ==, "Business");
+ g_assert_cmpstr (parser_test_get_playlist_field (uri, TOTEM_PL_PARSER_FIELD_GENRES), ==, "Business,Health/Self-Help");
+ g_free (uri);
+
+ /* multiple genre (with subgenres) */
+ uri = get_relative_uri (TEST_SRCDIR "content-no-rating.rss");
+ g_assert_cmpstr (parser_test_get_playlist_field (uri, TOTEM_PL_PARSER_FIELD_GENRE), ==, "Health & Fitness/Alternative Health");
+ g_assert_cmpstr (parser_test_get_playlist_field (uri, TOTEM_PL_PARSER_FIELD_GENRES), ==, "Health & Fitness/Alternative Health,Education/Self-Improvement,Health & Fitness/Nutrition");
+ g_free (uri);
+}
+
+static void
test_parsing_hadess (void)
{
if (g_strcmp0 (g_get_user_name (), "hadess") == 0)
@@ -1897,6 +1945,7 @@ main (int argc, char *argv[])
g_test_add_func ("/parser/parsing/podcast_item_explicit", test_parsing_item_explicit);
g_test_add_func ("/parser/parsing/invalid_characters", test_invalid_characters);
g_test_add_func ("/parser/parsing/invalid_utf8_characters", test_invalid_utf8_characters);
+ g_test_add_func ("/parser/parsing/podcast_feed_genres", test_parsing_feed_genres);
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);