@peertube/feed 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierrc.yml +1 -0
- package/.vscode/settings.json +6 -0
- package/LICENSE +7 -0
- package/README.md +10 -0
- package/jest.config.js +14 -0
- package/lib/atom1.d.ts +3 -0
- package/lib/atom1.js +121 -0
- package/lib/atom1.js.map +1 -0
- package/lib/config/index.d.ts +1 -0
- package/lib/config/index.js +5 -0
- package/lib/config/index.js.map +1 -0
- package/lib/feed.d.ts +17 -0
- package/lib/feed.js +26 -0
- package/lib/feed.js.map +1 -0
- package/lib/json.d.ts +3 -0
- package/lib/json.js +102 -0
- package/lib/json.js.map +1 -0
- package/lib/rss2.d.ts +3 -0
- package/lib/rss2.js +299 -0
- package/lib/rss2.js.map +1 -0
- package/lib/typings/index.d.ts +101 -0
- package/lib/typings/index.js +3 -0
- package/lib/typings/index.js.map +1 -0
- package/lib/utils.d.ts +1 -0
- package/lib/utils.js +11 -0
- package/lib/utils.js.map +1 -0
- package/package.json +38 -0
- package/src/__tests__/__snapshots__/atom1.spec.ts.snap +63 -0
- package/src/__tests__/__snapshots__/json.spec.ts.snap +48 -0
- package/src/__tests__/__snapshots__/rss2.spec.ts.snap +267 -0
- package/src/__tests__/atom1.spec.ts +8 -0
- package/src/__tests__/json.spec.ts +8 -0
- package/src/__tests__/rss2.spec.ts +366 -0
- package/src/__tests__/setup.ts +108 -0
- package/src/__tests__/utils.spec.ts +15 -0
- package/src/atom1.ts +202 -0
- package/src/config/index.ts +1 -0
- package/src/feed.ts +60 -0
- package/src/json.ts +119 -0
- package/src/rss2.ts +392 -0
- package/src/typings/index.ts +124 -0
- package/src/utils.ts +6 -0
- package/tsconfig.json +23 -0
package/.prettierrc.yml
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
printWidth: 120
|
package/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright (C) 2013, Jean-Philippe Monette <contact@jpmonette.net>
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# PeerTube feed
|
|
2
|
+
|
|
3
|
+
Fork of https://github.com/jpmonette/feed and https://github.com/rigelk/feed to implement Media RSS and custom properties needed by PeerTube.
|
|
4
|
+
|
|
5
|
+
## Initial contributors
|
|
6
|
+
|
|
7
|
+
Ben McCormick <ben.mccormick@windsorcircle.com>
|
|
8
|
+
Jean-Philippe Monette <contact@jpmonette.net>
|
|
9
|
+
Pierre Galvez <contact@pierre-galvez.fr>
|
|
10
|
+
rigelk
|
package/jest.config.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
verbose: true,
|
|
3
|
+
collectCoverage: true,
|
|
4
|
+
transform: {
|
|
5
|
+
"^.+\\.tsx?$": "ts-jest",
|
|
6
|
+
},
|
|
7
|
+
testEnvironment: "node",
|
|
8
|
+
testPathIgnorePatterns: ["/node_modules/", "__tests__/util/"],
|
|
9
|
+
testRegex: "(/__tests__/.*\\.spec)\\.(jsx?|tsx?)$",
|
|
10
|
+
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"],
|
|
11
|
+
moduleNameMapper: {
|
|
12
|
+
"@app/(.*)": "<rootDir>/src/$1",
|
|
13
|
+
},
|
|
14
|
+
};
|
package/lib/atom1.d.ts
ADDED
package/lib/atom1.js
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var convert = require("xml-js");
|
|
4
|
+
var config_1 = require("./config");
|
|
5
|
+
var utils_1 = require("./utils");
|
|
6
|
+
exports.default = (function (ins) {
|
|
7
|
+
var options = ins.options;
|
|
8
|
+
var base = {
|
|
9
|
+
_declaration: { _attributes: { version: "1.0", encoding: "utf-8" } },
|
|
10
|
+
feed: {
|
|
11
|
+
_attributes: { xmlns: "http://www.w3.org/2005/Atom" },
|
|
12
|
+
id: options.id,
|
|
13
|
+
title: options.title,
|
|
14
|
+
updated: options.updated ? options.updated.toISOString() : new Date().toISOString(),
|
|
15
|
+
generator: (0, utils_1.sanitize)(options.generator || config_1.generator)
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
if (options.author) {
|
|
19
|
+
base.feed.author = formatAuthor(options.author);
|
|
20
|
+
}
|
|
21
|
+
base.feed.link = [];
|
|
22
|
+
if (options.link) {
|
|
23
|
+
base.feed.link.push({ _attributes: { rel: "alternate", href: (0, utils_1.sanitize)(options.link) } });
|
|
24
|
+
}
|
|
25
|
+
var atomLink = (0, utils_1.sanitize)(options.feed || (options.feedLinks && options.feedLinks.atom));
|
|
26
|
+
if (atomLink) {
|
|
27
|
+
base.feed.link.push({ _attributes: { rel: "self", href: (0, utils_1.sanitize)(atomLink) } });
|
|
28
|
+
}
|
|
29
|
+
if (options.hub) {
|
|
30
|
+
base.feed.link.push({ _attributes: { rel: "hub", href: (0, utils_1.sanitize)(options.hub) } });
|
|
31
|
+
}
|
|
32
|
+
if (options.description) {
|
|
33
|
+
base.feed.subtitle = options.description;
|
|
34
|
+
}
|
|
35
|
+
if (options.image) {
|
|
36
|
+
base.feed.logo = options.image;
|
|
37
|
+
}
|
|
38
|
+
if (options.favicon) {
|
|
39
|
+
base.feed.icon = options.favicon;
|
|
40
|
+
}
|
|
41
|
+
if (options.copyright) {
|
|
42
|
+
base.feed.rights = options.copyright;
|
|
43
|
+
}
|
|
44
|
+
base.feed.category = [];
|
|
45
|
+
ins.categories.map(function (category) {
|
|
46
|
+
base.feed.category.push({ _attributes: { term: category } });
|
|
47
|
+
});
|
|
48
|
+
base.feed.contributor = [];
|
|
49
|
+
ins.contributors.map(function (contributor) {
|
|
50
|
+
base.feed.contributor.push(formatAuthor(contributor));
|
|
51
|
+
});
|
|
52
|
+
base.feed.entry = [];
|
|
53
|
+
ins.items.map(function (item) {
|
|
54
|
+
var entry = {
|
|
55
|
+
title: { _attributes: { type: "html" }, _cdata: item.title },
|
|
56
|
+
id: (0, utils_1.sanitize)(item.id || item.link),
|
|
57
|
+
link: [{ _attributes: { href: (0, utils_1.sanitize)(item.link) } }],
|
|
58
|
+
updated: item.date.toISOString()
|
|
59
|
+
};
|
|
60
|
+
if (item.description) {
|
|
61
|
+
entry.summary = {
|
|
62
|
+
_attributes: { type: "html" },
|
|
63
|
+
_cdata: item.description,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
if (item.content) {
|
|
67
|
+
entry.content = {
|
|
68
|
+
_attributes: { type: "html" },
|
|
69
|
+
_cdata: item.content,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
if (Array.isArray(item.author)) {
|
|
73
|
+
entry.author = [];
|
|
74
|
+
item.author.map(function (author) {
|
|
75
|
+
entry.author.push(formatAuthor(author));
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
if (Array.isArray(item.category)) {
|
|
79
|
+
entry.category = [];
|
|
80
|
+
item.category.map(function (category) {
|
|
81
|
+
entry.category.push(formatCategory(category));
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
if (item.contributor && Array.isArray(item.contributor)) {
|
|
85
|
+
entry.contributor = [];
|
|
86
|
+
item.contributor.map(function (contributor) {
|
|
87
|
+
entry.contributor.push(formatAuthor(contributor));
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
if (item.published) {
|
|
91
|
+
entry.published = item.published.toISOString();
|
|
92
|
+
}
|
|
93
|
+
if (item.copyright) {
|
|
94
|
+
entry.rights = item.copyright;
|
|
95
|
+
}
|
|
96
|
+
base.feed.entry.push(entry);
|
|
97
|
+
});
|
|
98
|
+
return convert.js2xml(base, { compact: true, ignoreComment: true, spaces: 4 });
|
|
99
|
+
});
|
|
100
|
+
var formatAuthor = function (author) {
|
|
101
|
+
var name = author.name, email = author.email, link = author.link;
|
|
102
|
+
var out = { name: name };
|
|
103
|
+
if (email) {
|
|
104
|
+
out.email = email;
|
|
105
|
+
}
|
|
106
|
+
if (link) {
|
|
107
|
+
out.uri = (0, utils_1.sanitize)(link);
|
|
108
|
+
}
|
|
109
|
+
return out;
|
|
110
|
+
};
|
|
111
|
+
var formatCategory = function (category) {
|
|
112
|
+
var name = category.name, scheme = category.scheme, term = category.term;
|
|
113
|
+
return {
|
|
114
|
+
_attributes: {
|
|
115
|
+
label: name,
|
|
116
|
+
scheme: scheme,
|
|
117
|
+
term: term,
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
//# sourceMappingURL=atom1.js.map
|
package/lib/atom1.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"atom1.js","sourceRoot":"","sources":["../src/atom1.ts"],"names":[],"mappings":";;AAAA,gCAAkC;AAClC,mCAAqC;AAGrC,iCAAmC;AAMnC,mBAAe,UAAC,GAAS;IACf,IAAA,OAAO,GAAK,GAAG,QAAR,CAAS;IAExB,IAAM,IAAI,GAAQ;QAChB,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AAC;AACb,CAAC,CAAC;AAMF,IAAM,cAAc,GAAG,UAAC,QAAkB;IAChC,IAAA,IAAI,GAAmB,QAAQ,KAA3B,EAAE,MAAM,GAAW,QAAQ,OAAnB,EAAE,IAAI,GAAK,QAAQ,KAAb,CAAc;IAExC,OAAO;QACL,WAAW,EAAE;YACX,KAAK,EAAE,IAAI;YACX,MAAM,QAAA;YACN,IAAI,MAAA;SACL;KACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const generator = "https://github.com/jpmonette/feed";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":";;;AAAa,QAAA,SAAS,GAAG,mCAAmC,CAAC"}
|
package/lib/feed.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Author, Extension, FeedOptions, Item } from "./typings";
|
|
2
|
+
export { Author, Extension, FeedOptions, Item };
|
|
3
|
+
export declare class Feed {
|
|
4
|
+
options: FeedOptions;
|
|
5
|
+
items: Item[];
|
|
6
|
+
categories: string[];
|
|
7
|
+
contributors: Author[];
|
|
8
|
+
extensions: Extension[];
|
|
9
|
+
constructor(options: FeedOptions);
|
|
10
|
+
addItem: (item: Item) => number;
|
|
11
|
+
addCategory: (category: string) => number;
|
|
12
|
+
addContributor: (contributor: Author) => number;
|
|
13
|
+
addExtension: (extension: Extension) => number;
|
|
14
|
+
atom1: () => string;
|
|
15
|
+
rss2: () => string;
|
|
16
|
+
json1: () => string;
|
|
17
|
+
}
|
package/lib/feed.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Feed = void 0;
|
|
4
|
+
var atom1_1 = require("./atom1");
|
|
5
|
+
var json_1 = require("./json");
|
|
6
|
+
var rss2_1 = require("./rss2");
|
|
7
|
+
var Feed = (function () {
|
|
8
|
+
function Feed(options) {
|
|
9
|
+
var _this = this;
|
|
10
|
+
this.items = [];
|
|
11
|
+
this.categories = [];
|
|
12
|
+
this.contributors = [];
|
|
13
|
+
this.extensions = [];
|
|
14
|
+
this.addItem = function (item) { return _this.items.push(item); };
|
|
15
|
+
this.addCategory = function (category) { return _this.categories.push(category); };
|
|
16
|
+
this.addContributor = function (contributor) { return _this.contributors.push(contributor); };
|
|
17
|
+
this.addExtension = function (extension) { return _this.extensions.push(extension); };
|
|
18
|
+
this.atom1 = function () { return (0, atom1_1.default)(_this); };
|
|
19
|
+
this.rss2 = function () { return (0, rss2_1.default)(_this); };
|
|
20
|
+
this.json1 = function () { return (0, json_1.default)(_this); };
|
|
21
|
+
this.options = options;
|
|
22
|
+
}
|
|
23
|
+
return Feed;
|
|
24
|
+
}());
|
|
25
|
+
exports.Feed = Feed;
|
|
26
|
+
//# sourceMappingURL=feed.js.map
|
package/lib/feed.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"feed.js","sourceRoot":"","sources":["../src/feed.ts"],"names":[],"mappings":";;;AAAA,iCAAiC;AACjC,+BAAgC;AAChC,+BAA+B;AAQ/B;IAOE,cAAY,OAAoB;QAAhC,iBAEC;QAPD,UAAK,GAAW,EAAE,CAAC;QACnB,eAAU,GAAa,EAAE,CAAC;QAC1B,iBAAY,GAAa,EAAE,CAAC;QAC5B,eAAU,GAAgB,EAAE,CAAC;QAUtB,YAAO,GAAG,UAAC,IAAU,IAAK,OAAA,KAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAArB,CAAqB,CAAC;QAMhD,gBAAW,GAAG,UAAC,QAAgB,IAAK,OAAA,KAAI,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,EAA9B,CAA8B,CAAC;QAMnE,mBAAc,GAAG,UAAC,WAAmB,IAAK,OAAA,KAAI,CAAC,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,EAAnC,CAAmC,CAAC;QAM9E,iBAAY,GAAG,UAAC,SAAoB,IAAK,OAAA,KAAI,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,EAA/B,CAA+B,CAAC;QAKzE,UAAK,GAAG,cAAc,OAAA,IAAA,eAAU,EAAC,KAAI,CAAC,EAAhB,CAAgB,CAAC;QAKvC,SAAI,GAAG,cAAc,OAAA,IAAA,cAAS,EAAC,KAAI,CAAC,EAAf,CAAe,CAAC;QAKrC,UAAK,GAAG,cAAc,OAAA,IAAA,cAAU,EAAC,KAAI,CAAC,EAAhB,CAAgB,CAAC;QAxC5C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAwCH,WAAC;AAAD,CAAC,AAjDD,IAiDC;AAjDY,oBAAI"}
|
package/lib/json.d.ts
ADDED
package/lib/json.js
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.default = (function (ins) {
|
|
15
|
+
var options = ins.options, items = ins.items, extensions = ins.extensions;
|
|
16
|
+
var feed = {
|
|
17
|
+
version: "https://jsonfeed.org/version/1",
|
|
18
|
+
title: options.title,
|
|
19
|
+
};
|
|
20
|
+
if (options.link) {
|
|
21
|
+
feed.home_page_url = options.link;
|
|
22
|
+
}
|
|
23
|
+
if (options.feedLinks && options.feedLinks.json) {
|
|
24
|
+
feed.feed_url = options.feedLinks.json;
|
|
25
|
+
}
|
|
26
|
+
if (options.description) {
|
|
27
|
+
feed.description = options.description;
|
|
28
|
+
}
|
|
29
|
+
if (options.image) {
|
|
30
|
+
feed.icon = options.image;
|
|
31
|
+
}
|
|
32
|
+
if (options.author) {
|
|
33
|
+
feed.author = {};
|
|
34
|
+
if (options.author.name) {
|
|
35
|
+
feed.author.name = options.author.name;
|
|
36
|
+
}
|
|
37
|
+
if (options.author.link) {
|
|
38
|
+
feed.author.url = options.author.link;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
extensions.map(function (e) {
|
|
42
|
+
feed[e.name] = e.objects;
|
|
43
|
+
});
|
|
44
|
+
feed.items = items.map(function (item) {
|
|
45
|
+
var feedItem = {
|
|
46
|
+
id: item.id,
|
|
47
|
+
content_html: item.content,
|
|
48
|
+
};
|
|
49
|
+
if (item.link) {
|
|
50
|
+
feedItem.url = item.link;
|
|
51
|
+
}
|
|
52
|
+
if (item.title) {
|
|
53
|
+
feedItem.title = item.title;
|
|
54
|
+
}
|
|
55
|
+
if (item.description) {
|
|
56
|
+
feedItem.summary = item.description;
|
|
57
|
+
}
|
|
58
|
+
if (item.torrents) {
|
|
59
|
+
if (!feedItem.attachments)
|
|
60
|
+
feedItem.attachments = [];
|
|
61
|
+
feedItem.attachments = feedItem.attachments.concat(item.torrents.map(function (t) { return (__assign(__assign({}, t), { mime_type: "application/x-bittorrent" })); }));
|
|
62
|
+
}
|
|
63
|
+
if (item.image) {
|
|
64
|
+
feedItem.image = item.image;
|
|
65
|
+
}
|
|
66
|
+
if (item.date) {
|
|
67
|
+
feedItem.date_modified = item.date.toISOString();
|
|
68
|
+
}
|
|
69
|
+
if (item.published) {
|
|
70
|
+
feedItem.date_published = item.published.toISOString();
|
|
71
|
+
}
|
|
72
|
+
if (item.author) {
|
|
73
|
+
var author = item.author;
|
|
74
|
+
if (author instanceof Array) {
|
|
75
|
+
author = author[0];
|
|
76
|
+
}
|
|
77
|
+
feedItem.author = {};
|
|
78
|
+
if (author.name) {
|
|
79
|
+
feedItem.author.name = author.name;
|
|
80
|
+
}
|
|
81
|
+
if (author.link) {
|
|
82
|
+
feedItem.author.url = author.link;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (Array.isArray(item.category)) {
|
|
86
|
+
feedItem.tags = [];
|
|
87
|
+
item.category.map(function (category) {
|
|
88
|
+
if (category.name) {
|
|
89
|
+
feedItem.tags.push(category.name);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
if (item.extensions) {
|
|
94
|
+
item.extensions.map(function (e) {
|
|
95
|
+
feedItem[e.name] = e.objects;
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
return feedItem;
|
|
99
|
+
});
|
|
100
|
+
return JSON.stringify(feed, null, 4);
|
|
101
|
+
});
|
|
102
|
+
//# sourceMappingURL=json.js.map
|
package/lib/json.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.js","sourceRoot":"","sources":["../src/json.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAOA,mBAAe,UAAC,GAAS;IACf,IAAA,OAAO,GAAwB,GAAG,QAA3B,EAAE,KAAK,GAAiB,GAAG,MAApB,EAAE,UAAU,GAAK,GAAG,WAAR,CAAQ;IAE1C,IAAI,IAAI,GAAQ;QACd,OAAO,EAAE,gCAAgC;QACzC,KAAK,EAAE,OAAO,CAAC,KAAK;KACrB,CAAA;IAED,IAAI,OAAO,CAAC,IAAI,EAAE;QAChB,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,IAAI,CAAA;KAClC;IAED,IAAI,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC,SAAS,CAAC,IAAI,EAAE;QAC/C,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC,IAAI,CAAA;KACvC;IAED,IAAI,OAAO,CAAC,WAAW,EAAE;QACvB,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAA;KACvC;IAED,IAAI,OAAO,CAAC,KAAK,E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YACnB,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,UAAC,CAAY;gBAC/B,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAA;YAC9B,CAAC,CAAC,CAAA;SACH;QAED,OAAO,QAAQ,CAAA;IACjB,CAAC,CAAC,CAAA;IAEF,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;AACtC,CAAC,EAAA"}
|
package/lib/rss2.d.ts
ADDED
package/lib/rss2.js
ADDED
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
var convert = require("xml-js");
|
|
15
|
+
var config_1 = require("./config");
|
|
16
|
+
var utils_1 = require("./utils");
|
|
17
|
+
exports.default = (function (ins) {
|
|
18
|
+
var options = ins.options;
|
|
19
|
+
var isAtom = false;
|
|
20
|
+
var isContent = false;
|
|
21
|
+
var base = {
|
|
22
|
+
_declaration: { _attributes: { version: "1.0", encoding: "utf-8" } },
|
|
23
|
+
rss: {
|
|
24
|
+
_attributes: { version: "2.0" },
|
|
25
|
+
channel: {
|
|
26
|
+
title: { _text: options.title },
|
|
27
|
+
link: { _text: (0, utils_1.sanitize)(options.link) },
|
|
28
|
+
description: { _text: options.description },
|
|
29
|
+
lastBuildDate: { _text: options.updated ? options.updated.toUTCString() : new Date().toUTCString() },
|
|
30
|
+
docs: { _text: options.docs ? options.docs : "https://validator.w3.org/feed/docs/rss2.html" },
|
|
31
|
+
generator: { _text: options.generator || config_1.generator },
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
if (options.language) {
|
|
36
|
+
base.rss.channel.language = { _text: options.language };
|
|
37
|
+
}
|
|
38
|
+
if (options.ttl) {
|
|
39
|
+
base.rss.channel.ttl = { _text: options.ttl };
|
|
40
|
+
}
|
|
41
|
+
if (options.image) {
|
|
42
|
+
base.rss.channel.image = {
|
|
43
|
+
title: { _text: options.title },
|
|
44
|
+
url: { _text: options.image },
|
|
45
|
+
link: { _text: (0, utils_1.sanitize)(options.link) }
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
if (options.copyright) {
|
|
49
|
+
base.rss.channel.copyright = { _text: options.copyright };
|
|
50
|
+
}
|
|
51
|
+
ins.categories.map(function (category) {
|
|
52
|
+
if (!base.rss.channel.category) {
|
|
53
|
+
base.rss.channel.category = [];
|
|
54
|
+
}
|
|
55
|
+
base.rss.channel.category.push({ _text: category });
|
|
56
|
+
});
|
|
57
|
+
var atomLink = options.feed || (options.feedLinks && options.feedLinks.rss);
|
|
58
|
+
if (atomLink) {
|
|
59
|
+
isAtom = true;
|
|
60
|
+
base.rss.channel["atom:link"] = [
|
|
61
|
+
{
|
|
62
|
+
_attributes: {
|
|
63
|
+
href: (0, utils_1.sanitize)(atomLink),
|
|
64
|
+
rel: "self",
|
|
65
|
+
type: "application/rss+xml",
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
];
|
|
69
|
+
}
|
|
70
|
+
if (options.hub) {
|
|
71
|
+
isAtom = true;
|
|
72
|
+
if (!base.rss.channel["atom:link"]) {
|
|
73
|
+
base.rss.channel["atom:link"] = [];
|
|
74
|
+
}
|
|
75
|
+
base.rss.channel["atom:link"] = {
|
|
76
|
+
_attributes: {
|
|
77
|
+
href: (0, utils_1.sanitize)(options.hub),
|
|
78
|
+
rel: "hub"
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
base.rss.channel.item = [];
|
|
83
|
+
ins.items.map(function (entry) {
|
|
84
|
+
var item = {};
|
|
85
|
+
if (entry.title) {
|
|
86
|
+
item.title = { _cdata: entry.title };
|
|
87
|
+
}
|
|
88
|
+
if (entry.link) {
|
|
89
|
+
item.link = { _text: (0, utils_1.sanitize)(entry.link) };
|
|
90
|
+
}
|
|
91
|
+
if (entry.guid) {
|
|
92
|
+
item.guid = { _text: entry.guid };
|
|
93
|
+
}
|
|
94
|
+
else if (entry.id) {
|
|
95
|
+
item.guid = { _text: entry.id };
|
|
96
|
+
}
|
|
97
|
+
else if (entry.link) {
|
|
98
|
+
item.guid = { _text: (0, utils_1.sanitize)(entry.link) };
|
|
99
|
+
}
|
|
100
|
+
if (entry.date) {
|
|
101
|
+
item.pubDate = { _text: entry.date.toUTCString() };
|
|
102
|
+
}
|
|
103
|
+
if (entry.published) {
|
|
104
|
+
item.pubDate = { _text: entry.published.toUTCString() };
|
|
105
|
+
}
|
|
106
|
+
if (entry.description) {
|
|
107
|
+
item.description = { _cdata: entry.description };
|
|
108
|
+
}
|
|
109
|
+
if (entry.content) {
|
|
110
|
+
isContent = true;
|
|
111
|
+
item["content:encoded"] = { _cdata: entry.content };
|
|
112
|
+
}
|
|
113
|
+
if (Array.isArray(entry.author)) {
|
|
114
|
+
item.author = [];
|
|
115
|
+
entry.author.map(function (author) {
|
|
116
|
+
if (author.email && author.name) {
|
|
117
|
+
item.author.push({ _text: author.email + " (" + author.name + ")" });
|
|
118
|
+
}
|
|
119
|
+
else if (author.name) {
|
|
120
|
+
base.rss._attributes["xmlns:dc"] = "http://purl.org/dc/elements/1.1/";
|
|
121
|
+
item["dc:creator"] = {
|
|
122
|
+
_text: author.name
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
if (Array.isArray(entry.category)) {
|
|
128
|
+
item.category = [];
|
|
129
|
+
entry.category.map(function (category) {
|
|
130
|
+
item.category.push(formatCategory(category));
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
if (entry.enclosure) {
|
|
134
|
+
item.enclosure = formatEnclosure(entry.enclosure);
|
|
135
|
+
}
|
|
136
|
+
if (entry.image) {
|
|
137
|
+
item.enclosure = formatEnclosure(entry.image, "image");
|
|
138
|
+
}
|
|
139
|
+
if (entry.audio) {
|
|
140
|
+
item.enclosure = formatEnclosure(entry.audio, "audio");
|
|
141
|
+
}
|
|
142
|
+
if (entry.video) {
|
|
143
|
+
item.enclosure = formatEnclosure(entry.video, "video");
|
|
144
|
+
}
|
|
145
|
+
processMRSS(base.rss._attributes, entry, item);
|
|
146
|
+
base.rss.channel.item.push(item);
|
|
147
|
+
});
|
|
148
|
+
if (isContent) {
|
|
149
|
+
base.rss._attributes["xmlns:dc"] = "http://purl.org/dc/elements/1.1/";
|
|
150
|
+
base.rss._attributes["xmlns:content"] = "http://purl.org/rss/1.0/modules/content/";
|
|
151
|
+
}
|
|
152
|
+
if (isAtom) {
|
|
153
|
+
base.rss._attributes["xmlns:atom"] = "http://www.w3.org/2005/Atom";
|
|
154
|
+
}
|
|
155
|
+
return convert.js2xml(base, { compact: true, ignoreComment: true, spaces: 4 });
|
|
156
|
+
});
|
|
157
|
+
var formatEnclosure = function (enclosure, mimeCategory) {
|
|
158
|
+
if (mimeCategory === void 0) { mimeCategory = "image"; }
|
|
159
|
+
if (typeof enclosure === "string") {
|
|
160
|
+
var type_1 = new URL(enclosure).pathname.split(".").slice(-1)[0];
|
|
161
|
+
return { _attributes: { url: enclosure, length: 0, type: "".concat(mimeCategory, "/").concat(type_1) } };
|
|
162
|
+
}
|
|
163
|
+
var type = new URL(enclosure.url).pathname.split(".").slice(-1)[0];
|
|
164
|
+
return { _attributes: __assign({ length: 0, type: "".concat(mimeCategory, "/").concat(type) }, enclosure) };
|
|
165
|
+
};
|
|
166
|
+
var formatCategory = function (category) {
|
|
167
|
+
var name = category.name, domain = category.domain;
|
|
168
|
+
return {
|
|
169
|
+
_text: name,
|
|
170
|
+
_attributes: {
|
|
171
|
+
domain: domain,
|
|
172
|
+
},
|
|
173
|
+
};
|
|
174
|
+
};
|
|
175
|
+
var processMRSS = function (rssAttributes, entry, target) {
|
|
176
|
+
var _a, _b;
|
|
177
|
+
var hasMediaRSS = false;
|
|
178
|
+
if (entry.categories) {
|
|
179
|
+
hasMediaRSS = true;
|
|
180
|
+
target["media:category"] = entry.categories.map(function (c) { return ({
|
|
181
|
+
_text: c.value,
|
|
182
|
+
_attributes: {
|
|
183
|
+
scheme: "http://search.yahoo.com/mrss/category_schema",
|
|
184
|
+
label: c.label
|
|
185
|
+
}
|
|
186
|
+
}); });
|
|
187
|
+
}
|
|
188
|
+
if (((_b = (_a = entry.community) === null || _a === void 0 ? void 0 : _a.statistics) === null || _b === void 0 ? void 0 : _b.views) !== undefined) {
|
|
189
|
+
hasMediaRSS = true;
|
|
190
|
+
target["media:community"] = {
|
|
191
|
+
"media:statistics": {
|
|
192
|
+
_attributes: {
|
|
193
|
+
views: entry.community.statistics.views
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
if (entry.embed) {
|
|
199
|
+
hasMediaRSS = true;
|
|
200
|
+
target["media:embed"] = {
|
|
201
|
+
_attributes: {
|
|
202
|
+
url: entry.embed.url
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
if (entry.keywords) {
|
|
207
|
+
hasMediaRSS = true;
|
|
208
|
+
target["media:keywords"] = {
|
|
209
|
+
_text: [entry.keywords.join(", ")]
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
if (entry.subTitle) {
|
|
213
|
+
for (var _i = 0, _c = entry.subTitle; _i < _c.length; _i++) {
|
|
214
|
+
var sub = _c[_i];
|
|
215
|
+
if (!sub.href || !sub.type || !sub.lang)
|
|
216
|
+
continue;
|
|
217
|
+
hasMediaRSS = true;
|
|
218
|
+
target["media:subTitle"] = {
|
|
219
|
+
_attributes: {
|
|
220
|
+
href: sub.href,
|
|
221
|
+
type: sub.type,
|
|
222
|
+
lang: sub.lang
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
if (entry.player) {
|
|
228
|
+
hasMediaRSS = true;
|
|
229
|
+
target["media:player"] = {
|
|
230
|
+
_attributes: {
|
|
231
|
+
url: entry.player.url
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
var mediagroup = {};
|
|
236
|
+
if (Array.isArray(entry.torrents)) {
|
|
237
|
+
mediagroup["media:peerLink"] = entry.torrents.map(function (t, i) {
|
|
238
|
+
var _a;
|
|
239
|
+
return ({
|
|
240
|
+
_attributes: {
|
|
241
|
+
type: "application/x-bittorrent",
|
|
242
|
+
href: t.url,
|
|
243
|
+
isDefault: (Array.isArray(entry.videos) === false || ((_a = entry.videos) === null || _a === void 0 ? void 0 : _a.length) === 0) && i === 0
|
|
244
|
+
? "true"
|
|
245
|
+
: "false"
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
if (Array.isArray(entry.videos)) {
|
|
251
|
+
mediagroup["media:content"] = entry.videos.map(function (v, i) { return ({
|
|
252
|
+
_attributes: {
|
|
253
|
+
type: v.type,
|
|
254
|
+
medium: v.medium,
|
|
255
|
+
height: v.height,
|
|
256
|
+
fileSize: v.fileSize,
|
|
257
|
+
url: v.url,
|
|
258
|
+
framerate: v.framerate,
|
|
259
|
+
duration: v.duration,
|
|
260
|
+
isDefault: i === 0
|
|
261
|
+
? "true"
|
|
262
|
+
: "false"
|
|
263
|
+
}
|
|
264
|
+
}); });
|
|
265
|
+
}
|
|
266
|
+
if (Object.keys(mediagroup).length !== 0) {
|
|
267
|
+
hasMediaRSS = true;
|
|
268
|
+
target["media:group"] = mediagroup;
|
|
269
|
+
}
|
|
270
|
+
if (entry.thumbnails) {
|
|
271
|
+
hasMediaRSS = true;
|
|
272
|
+
target["media:thumbnail"] = entry.thumbnails.map(function (t) { return ({
|
|
273
|
+
_attributes: {
|
|
274
|
+
url: t.url,
|
|
275
|
+
height: t.height,
|
|
276
|
+
width: t.width
|
|
277
|
+
}
|
|
278
|
+
}); });
|
|
279
|
+
}
|
|
280
|
+
if (hasMediaRSS) {
|
|
281
|
+
rssAttributes["xmlns:media"] = "http://search.yahoo.com/mrss/";
|
|
282
|
+
target["media:rating"] = {
|
|
283
|
+
_text: entry.nsfw ? "adult" : "nonadult"
|
|
284
|
+
};
|
|
285
|
+
if (entry.title) {
|
|
286
|
+
target["media:title"] = {
|
|
287
|
+
_text: entry.title,
|
|
288
|
+
_attributes: { type: "plain" }
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
if (entry.description) {
|
|
292
|
+
target["media:description"] = {
|
|
293
|
+
_text: entry.description,
|
|
294
|
+
_attributes: { type: "plain" }
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
//# sourceMappingURL=rss2.js.map
|