[totem-pl-parser] podcast: Add support for "medium" property



commit 686b64f9eba5e80ef8d53ca3041ae48c88b96b5a
Author: Bastien Nocera <hadess hadess net>
Date:   Mon Dec 4 15:55:39 2017 +0100

    podcast: Add support for "medium" property
    
    The medium property, similarly to the "type" property allows to define
    the type of additional resources, such as whether they are images or
    audio.
    
    This caused problems with KQED podcast feeds as we did not handle that
    property, and tried to use the image as the audio source.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=791154

 plparse/tests/791154-kqed.rss     |   69 +++++++++++++++++++++++++++++++++++++
 plparse/tests/parser.c            |   10 +++++
 plparse/totem-pl-parser-podcast.c |    6 +++
 3 files changed, 85 insertions(+), 0 deletions(-)
---
diff --git a/plparse/tests/791154-kqed.rss b/plparse/tests/791154-kqed.rss
new file mode 100644
index 0000000..0787e32
--- /dev/null
+++ b/plparse/tests/791154-kqed.rss
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<rss version="2.0"
+       xmlns:content="http://purl.org/rss/1.0/modules/content/";
+       xmlns:wfw="http://wellformedweb.org/CommentAPI/";
+       xmlns:dc="http://purl.org/dc/elements/1.1/";
+       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";
+xmlns:rawvoice="http://www.rawvoice.com/rawvoiceRssModule/";
+xmlns:googleplay="http://www.google.com/schemas/play-podcasts/1.0";
+xmlns:ev="http://purl.org/rss/2.0/modules/event/";
+xmlns:nprml="https://api.npr.org/nprml";
+       xmlns:media="http://search.yahoo.com/mrss/";
+       >
+<channel>
+       <title>KQED&#8217;s The California Report</title>
+       <atom:link href="https://ww2.kqed.org/news/tag/tcrarchive/feed/podcast"; rel="self" 
type="application/rss+xml" />
+       <link>https://ww2.kqed.org/news/programs/the-california-report</link>
+       <description>KQED&#8217;s statewide radio news program, providing daily coverage of issues, trends, 
and public policy decisions affecting California and its diverse population.</description>
+       <lastBuildDate>Mon, 04 Dec 2017 08:01:09 +0000</lastBuildDate>
+       <language>en-US</language>
+       <sy:updatePeriod>hourly</sy:updatePeriod>
+       <sy:updateFrequency>1</sy:updateFrequency>
+               <generator>https://wordpress.org/?v=4.2.2</generator>
+<!-- podcast_generator="Blubrry PowerPress/7.1.1" mode="advanced" ttid="21285" -->
+       <itunes:new-feed-url>https://ww2.kqed.org/news/tag/tcram/feed/podcast</itunes:new-feed-url>
+       <itunes:summary>KQED&#039;s statewide half-hour radio news program, providing daily coverage of 
issues, trends, and public policy decisions affecting California and its diverse population.</itunes:summary>
+       <itunes:author>KQED</itunes:author>
+       <itunes:explicit>clean</itunes:explicit>
+       <itunes:image 
href="https://ww2.kqed.org/news/wp-content/uploads/sites/10/2017/07/The_California_Report_iTunes_Badge-06.png";
 />
+       <itunes:owner>
+               <itunes:name>KQED</itunes:name>
+               <itunes:email>carlosgonzalez kqed org</itunes:email>
+       </itunes:owner>
+       <managingEditor>carlosgonzalez kqed org (KQED)</managingEditor>
+       <copyright>Copyright &#xA9; 2017 KQED Inc. All Rights Reserved.</copyright>
+       <itunes:subtitle>KQED Public Media for Northern CA</itunes:subtitle>
+       <image>
+               <title>KQED&#8217;s The California Report</title>
+               
<url>https://ww2.kqed.org/news/wp-content/uploads/sites/10/2017/07/The_California_Report_iTunes_Badge-06.png</url>
+               <link>https://ww2.kqed.org/news/programs/the-california-report</link>
+       </image>
+       <itunes:category text="News &amp; Politics">
+       </itunes:category>
+       <googleplay:email>carlosgonzalez kqed org</googleplay:email>
+       <googleplay:category text="News &amp; Politics" />
+       <googleplay:image 
href="https://ww2.kqed.org/news/wp-content/uploads/sites/10/2017/07/The_California_Report_iTunes_Badge-06.png";
 />
+       <rawvoice:subscribe feed="https://ww2.kqed.org/news/tag/tcrarchive/feed/podcast"; 
itunes="https://itunes.apple.com/us/podcast/id79681292";></rawvoice:subscribe>
+<atom:link rel="hub" href="https://pubsubhubbub.appspot.com"/><atom:link rel="hub" 
href="https://pubsubhubbub.superfeedr.com"/><site xmlns="com-wordpress:feed-additions:1">76140667</site>    
<item>
+               <title>The California Report Magazine: Homeless Housemates and Gold Rush Opera</title>
+               
<link>https://ww2.kqed.org/news/2017/12/01/the-california-report-magazine-homeless-housemates-and-gold-rush-opera/</link>
+               <pubDate>Sat, 02 Dec 2017 01:59:12 +0000</pubDate>
+               <guid isPermaLink="false">https://ww2.kqed.org/news/?p=11634383</guid>
+               
<comments>https://ww2.kqed.org/news/2017/12/01/the-california-report-magazine-homeless-housemates-and-gold-rush-opera/#comments</comments>
+               
<wfw:commentRss>https://ww2.kqed.org/news/2017/12/01/the-california-report-magazine-homeless-housemates-and-gold-rush-opera/feed/</wfw:commentRss>
+               <slash:comments>1</slash:comments>
+               <description>Helping the Homeless, By Living With them, A Reporter and A Politician Share 
Loss, Giant Tree Stump Takes the Opera Stage, Bumpass Hell</description>
+               <enclosure 
url="https://www.podtrac.com/pts/redirect.mp3/www.kqed.org/.stream/anon/radio/tcrmag/2017/12/TCRPodcastDec1.mp3";
 length="13906776" type="audio/mpeg" />
+               <itunes:subtitle>Helping the Homeless, By Living With them, A Reporter and A Politician Share 
Loss, Giant Tree Stump Takes the Opera Stage, Bumpass Hell</itunes:subtitle>
+               <itunes:summary>Helping the Homeless, By Living With them, A Reporter and A Politician Share 
Loss, Giant Tree Stump Takes the Opera Stage, Bumpass Hell</itunes:summary>
+               <itunes:author>KQED</itunes:author>
+               <itunes:image 
href="https://ww2.kqed.org/news/wp-content/uploads/sites/10/2017/07/The_California_Report_iTunes_Badge-06.png";
 />
+               <itunes:duration>28:58</itunes:duration>
+<post-id xmlns="com-wordpress:feed-additions:1">11634383</post-id><media:content 
url="https://ww2.kqed.org/news/wp-content/uploads/sites/10/2017/11/TCRMag_iTunes_3000x3000-800x800.jpg"; 
medium="image" height="1920" width="1920"><media:thumbnail 
url="https://ww2.kqed.org/news/wp-content/uploads/sites/10/2017/11/TCRMag_iTunes_3000x3000-160x160.jpg"; 
height="60" width="60" /></media:content>
+<nprml:parent id="319418027" type="collection"/>Helping the Homeless, By Living With them, A Reporter and A 
Politician Share Loss, Giant Tree Stump Takes the Opera Stage, Bumpass Hell
+               </item>
+</channel>
+</rss>
diff --git a/plparse/tests/parser.c b/plparse/tests/parser.c
index e44c271..87a1f64 100644
--- a/plparse/tests/parser.c
+++ b/plparse/tests/parser.c
@@ -719,6 +719,15 @@ test_parsing_content_type (void)
 }
 
 static void
+test_parsing_medium (void)
+{
+       char *uri;
+       uri = get_relative_uri (TEST_SRCDIR "791154-kqed.rss");
+       g_assert_cmpstr (parser_test_get_entry_field (uri, TOTEM_PL_PARSER_FIELD_URI), ==, 
"https://www.podtrac.com/pts/redirect.mp3/www.kqed.org/.stream/anon/radio/tcrmag/2017/12/TCRPodcastDec1.mp3";);
+       g_free (uri);
+}
+
+static void
 test_parsing_hadess (void)
 {
        if (g_strcmp0 (g_get_user_name (), "hadess") == 0)
@@ -1299,6 +1308,7 @@ main (int argc, char *argv[])
                g_test_add_func ("/parser/parsing/multi_line_rtsptext", test_parsing_rtsp_text_multi);
                g_test_add_func ("/parser/parsing/single_line_rtsptext", test_parsing_rtsp_text);
                g_test_add_func ("/parser/parsing/podcast_content_type", test_parsing_content_type);
+               g_test_add_func ("/parser/parsing/podcast_medium", test_parsing_medium);
                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 263dccd..9ecaae0 100644
--- a/plparse/totem-pl-parser-podcast.c
+++ b/plparse/totem-pl-parser-podcast.c
@@ -149,6 +149,12 @@ parse_rss_item (TotemPlParser *parser, xml_node_t *parent)
                } else if (g_ascii_strcasecmp (node->name, "media:content") == 0) {
                        const char *tmp;
 
+                       tmp = xml_parser_get_property (node, "medium");
+                       if (tmp != NULL && g_str_equal (tmp, "image")) {
+                               img = xml_parser_get_property (node, "url");
+                               continue;
+                       }
+
                        tmp = xml_parser_get_property (node, "type");
                        if (tmp != NULL &&
                            g_str_has_prefix (tmp, "audio/") == FALSE) {


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