Skip to content

Commit c1f59ec

Browse files
jbjorgerbren
authored andcommitted
Fix for missing image in itunes:image on item (rbren#22)
* Fixed layout for narro.rss * Added itunes:image for items. Added check to see if href is set on <itunes:image>
1 parent aaae472 commit c1f59ec

File tree

3 files changed

+51
-4
lines changed

3 files changed

+51
-4
lines changed

index.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ var PODCAST_ITEM_FIELDS = [
3737
'subtitle',
3838
'summary',
3939
'explicit',
40-
'duration'
40+
'duration',
41+
'image'
4142
];
4243

4344

@@ -171,7 +172,13 @@ var decorateItunes = function decorateItunes(json, channel) {
171172
entry = json.feed.entries[index];
172173
PODCAST_ITEM_FIELDS.forEach(function(f) {
173174
entry.itunes = entry.itunes || {};
174-
if (item['itunes:' + f]) entry.itunes[f] = item['itunes:' + f][0];
175+
if (item['itunes:' + f]) {
176+
if (f == 'image' && item['itunes:' + f][0].$ && item['itunes:' + f][0].$.href) {
177+
entry.itunes[f] = item['itunes:' + f][0].$.href;
178+
} else {
179+
entry.itunes[f] = item['itunes:' + f][0];
180+
}
181+
}
175182
});
176183
json.feed.entries[index] = entry;
177184
});

test/input/narro.rss

+40-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,40 @@
1-
<?xml version="1.0" encoding="UTF-8"?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0"><channel><title>foobar on Narro</title><link>http://on.narro.co/f</link><description>foobar uses Narro to create a podcast of articles transcribed to audio.</description><language>en</language><copyright>All article content copyright of respective source authors.</copyright><managingEditor>foobar@gmail.com</managingEditor><webMaster>josh@narro.co</webMaster><pubDate>Fri, 08 Jul 2016 13:40:00 UTC</pubDate><generator>gopod - http://github.com/jbckmn/gopod</generator><ttl>20</ttl><itunes:author>foobar@gmail.com</itunes:author><itunes:subtitle>foobar uses Narro to create a podcast of articles transcribed to audio.</itunes:subtitle><itunes:summary>foobar uses Narro to create a podcast of articles transcribed to audio.</itunes:summary><itunes:explicit>no</itunes:explicit><itunes:owner><itunes:name>foobar</itunes:name><itunes:email>foobar@gmail.com</itunes:email></itunes:owner><itunes:image href="https://www.narro.co/images/narro-icon-lg.png"></itunes:image><atom:link href="http://on.narro.co/f" rel="self" type="application/rss+xml"></atom:link><item><link>https://www.narro.co/article/54e703933058540300000069</link><description>Listen to your reading list anywhere. Narro will take your bookmarked articles and read them back to you as a podcast.&lt;br/&gt; http://www.narro.co/faq&lt;br/&gt; &lt;ul class=&#34;linkList&#34;&gt;&lt;/ul&gt;</description><title>FAQ for Narro</title><pubDate>Fri, 20 Feb 2015 09:51:15 UTC</pubDate><author>foobar@gmail.com</author><guid>https://www.narro.co/article/54e703933058540300000069</guid><itunes:author>foobar@gmail.com</itunes:author><itunes:subtitle>FAQ for Narro</itunes:subtitle><itunes:summary>Listen to your reading list anywhere. Narro will take your bookmarked articles and read them back to you as a podcast. ... http://www.narro.co/faq ... &lt;ul class=&#34;linkList&#34;&gt;&lt;/ul&gt;</itunes:summary><itunes:explicit>no</itunes:explicit><itunes:duration>74</itunes:duration><enclosure url="https://s3.amazonaws.com/nareta-articles/audio/54d046c293f79c0300000003/7e2d2b00-a945-441a-f49b-063786a319a4.mp3" length="74" type="audio/mpeg"></enclosure></item></channel></rss>
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
3+
<channel>
4+
<title>foobar on Narro</title>
5+
<link>http://on.narro.co/f</link>
6+
<description>foobar uses Narro to create a podcast of articles transcribed to audio.</description>
7+
<language>en</language>
8+
<copyright>All article content copyright of respective source authors.</copyright>
9+
<managingEditor>foobar@gmail.com</managingEditor>
10+
<webMaster>josh@narro.co</webMaster>
11+
<pubDate>Fri, 08 Jul 2016 13:40:00 UTC</pubDate>
12+
<generator>gopod - http://github.com/jbckmn/gopod</generator>
13+
<ttl>20</ttl>
14+
<itunes:author>foobar@gmail.com</itunes:author>
15+
<itunes:subtitle>foobar uses Narro to create a podcast of articles transcribed to audio.</itunes:subtitle>
16+
<itunes:summary>foobar uses Narro to create a podcast of articles transcribed to audio.</itunes:summary>
17+
<itunes:explicit>no</itunes:explicit>
18+
<itunes:owner>
19+
<itunes:name>foobar</itunes:name>
20+
<itunes:email>foobar@gmail.com</itunes:email>
21+
</itunes:owner>
22+
<itunes:image href="https://www.narro.co/images/narro-icon-lg.png"></itunes:image>
23+
<atom:link href="http://on.narro.co/f" rel="self" type="application/rss+xml"></atom:link>
24+
<item>
25+
<link>https://www.narro.co/article/54e703933058540300000069</link>
26+
<description>Listen to your reading list anywhere. Narro will take your bookmarked articles and read them back to you as a podcast.&lt;br/&gt; http://www.narro.co/faq&lt;br/&gt; &lt;ul class=&#34;linkList&#34;&gt;&lt;/ul&gt;</description>
27+
<title>FAQ for Narro</title>
28+
<pubDate>Fri, 20 Feb 2015 09:51:15 UTC</pubDate>
29+
<author>foobar@gmail.com</author>
30+
<guid>https://www.narro.co/article/54e703933058540300000069</guid>
31+
<itunes:author>foobar@gmail.com</itunes:author>
32+
<itunes:subtitle>FAQ for Narro</itunes:subtitle>
33+
<itunes:summary>Listen to your reading list anywhere. Narro will take your bookmarked articles and read them back to you as a podcast. ... http://www.narro.co/faq ... &lt;ul class=&#34;linkList&#34;&gt;&lt;/ul&gt;</itunes:summary>
34+
<itunes:explicit>no</itunes:explicit>
35+
<itunes:duration>74</itunes:duration>
36+
<itunes:image href="http://example.com/someImage.jpg"/>
37+
<enclosure url="https://s3.amazonaws.com/nareta-articles/audio/54d046c293f79c0300000003/7e2d2b00-a945-441a-f49b-063786a319a4.mp3" length="74" type="audio/mpeg"></enclosure>
38+
</item>
39+
</channel>
40+
</rss>

test/output/narro.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
"subtitle": "FAQ for Narro",
2020
"summary": "Listen to your reading list anywhere. Narro will take your bookmarked articles and read them back to you as a podcast. ... http://www.narro.co/faq ... <ul class=\"linkList\"></ul>",
2121
"explicit": "no",
22-
"duration": "74"
22+
"duration": "74",
23+
"image": "http://example.com/someImage.jpg"
2324
}
2425
}
2526
],

0 commit comments

Comments
 (0)