-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFeed.js
88 lines (84 loc) · 2.52 KB
/
Feed.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
'use strict'
let RSS = require('rss');
let config = require('./config');
exports.playlistToFeed = function(playlist) {
var feed = new RSS({
title: playlist.title,
description: playlist.description,
feed_url: config.host + '/youtube/' + playlist.id,
site_url: config.host,
// image_url: 'http://example.com/icon.png',
// docs: 'http://example.com/rss/docs.html',
pubDate: "",
language: "",
image_url: playlist.image_url,
author: playlist.author.name,
managingEditor: playlist.author.name,
webMaster: 'Sneaker15',
copyright: '©2017',
ttl: '60',
custom_namespaces: {
'itunes': 'http://www.itunes.com/dtds/podcast-1.0.dtd'
},
custom_elements: [
// { 'itunes:subtitle': 'A show about everything' },
// { 'itunes:author': 'John Doe' },
// { 'itunes:summary': 'All About Everything is a show about everything. Each week we dive into any subject known to man and talk about it as much as we can. Look for our podcast in the Podcasts app or in the iTunes Store' },
// {
// 'itunes:owner': [
// { 'itunes:name': 'John Doe' },
// { 'itunes:email': '[email protected]' }
// ]
// },
{
'itunes:image': {
_attr: {
href: playlist.image_url
}
}
},
{
'itunes:category': [
{
_attr: {
text: 'Youtube'
}
},
{
'itunes:category': {
_attr: {
text: 'Playlist'
}
}
}
]
}
]
});
playlist.items.map((item) => {
feed.item({
title: item.title,
description: item.description,
url: config.host + '/video/' + item.id, // link to the item
// guid: item.id, // optional - defaults to url
// categories: ['Category 1', 'Category 2', 'Category 3', 'Category 4'], // optional - array of item categories
author: item.author.name, // optional - defaults to feed author property
date: 'May 27, 2012', // any format that js Date can parse.
// lat: 33.417974, //optional latitude field for GeoRSS
// long: -111.933231, //optional longitude field for GeoRSS
// enclosure: { url: '...', file: 'path-to-file' }, // optional enclosure
enclosure: {
'url': config.host + '/video/' + item.id,
// 'size': 1668, //
'type': 'video/mp4'
}
// itunesAuthor: 'John Doe',
// itunesExplicit: false,
// itunesSubtitle: 'I am a sub title',
// itunesSummary: 'I am a summary',
// itunesDuration: 12345,
// itunesKeywords: ['javascript', 'podcast']
});
});
return feed;
}