-
Notifications
You must be signed in to change notification settings - Fork 1
/
iTunesRSSFeed.js
42 lines (36 loc) · 1.85 KB
/
iTunesRSSFeed.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
const builder = require('xmlbuilder');
const createiTunesPodcastItem = require('./iTunesPodcastItem').createiTunesPodcastItem;
exports.createiTunesRSSFeed = (podcastMetadata, items) => {
const transfromedItems = items.map(item => createiTunesPodcastItem(item));
let rssFeedXML = {
'rss': {
'@version': '2.0',
'@xmlns:itunes': 'http://www.itunes.com/dtds/podcast-1.0.dtd',
'@xmlns:content': 'http://purl.org/rss/1.0/modules/content/',
'channel': {
'title': podcastMetadata.title,
'link': podcastMetadata.link,
'language': podcastMetadata.language,
'copyright': podcastMetadata.copyright,
'itunes:subtitle': podcastMetadata.itunes_subtitle,
'itunes:author': podcastMetadata.itunes_author,
'itunes:summary': podcastMetadata.itunes_summary,
'description': podcastMetadata.description,
'itunes:type': podcastMetadata.itunes_type,
'itunes:owner': {
'itunes:name': podcastMetadata.itunes_owner_name,
'itunes:email': podcastMetadata.itunes_owner_email
},
'itunes:image': { '@href': podcastMetadata.itunes_image },
'itunes:keywords': podcastMetadata.itunes_keywords,
'itunes:category': podcastMetadata.itunes_categories.split(',').map(category => { return { '@text': category } }),
'itunes:explicit': podcastMetadata.itunes_explicit ? 'yes' : 'no',
'itunes:new-feed-url': podcastMetadata.itunes_new_feed_url
}
}
};
rssFeedXML.rss.channel.item = transfromedItems;
let xmlBuilder = builder.create(rssFeedXML, { encoding: 'utf-8' });
let resultXML = xmlBuilder.end({ pretty: true });
return resultXML;
}