ns-rss-spider 0.0.16 → 0.0.18
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/dist/cjs/parse.d.ts +3 -0
- package/dist/cjs/parse.js +5 -1
- package/dist/cjs/parseContent/getBasicFromItem.d.ts +2 -0
- package/dist/cjs/parseContent/getBasicFromItem.js +41 -0
- package/dist/cjs/parseContent/index.d.ts +1 -2
- package/dist/cjs/parseContent/index.js +3 -5
- package/dist/cjs/parseContent/parseContent.d.ts +1 -2
- package/dist/cjs/parseContent/parseContent.js +2 -6
- package/dist/cjs/types.d.ts +8 -1
- package/dist/cjs/upload/index.d.ts +3 -0
- package/package.json +1 -2
package/dist/cjs/parse.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { ServerInfo } from "./upload";
|
|
2
2
|
export declare function parseRss(name: string, feed: string, server?: ServerInfo): Promise<import("./types").Article[] | {
|
|
3
3
|
storePath: any;
|
|
4
|
+
source?: string | undefined;
|
|
4
5
|
type: "simple" | "rich";
|
|
5
6
|
guid: string;
|
|
6
7
|
title: string;
|
|
7
8
|
link: string;
|
|
8
9
|
description: string;
|
|
9
10
|
pubDate: Date;
|
|
11
|
+
author?: string | undefined;
|
|
12
|
+
categories?: string | undefined;
|
|
10
13
|
}[]>;
|
package/dist/cjs/parse.js
CHANGED
|
@@ -39,7 +39,11 @@ var import_parseContent = require("./parseContent");
|
|
|
39
39
|
var import_upload = require("./upload");
|
|
40
40
|
var import_axios = __toESM(require("axios"));
|
|
41
41
|
async function parseRss(name, feed, server) {
|
|
42
|
-
const parser = new import_rss_parser.default(
|
|
42
|
+
const parser = new import_rss_parser.default({
|
|
43
|
+
customFields: {
|
|
44
|
+
item: ["source"]
|
|
45
|
+
}
|
|
46
|
+
});
|
|
43
47
|
console.log(import_zx.chalk.green("正在拉取 rss 列表"));
|
|
44
48
|
const result = await parser.parseURL(feed);
|
|
45
49
|
if (!result.items.length) {
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/parseContent/getBasicFromItem.ts
|
|
20
|
+
var getBasicFromItem_exports = {};
|
|
21
|
+
__export(getBasicFromItem_exports, {
|
|
22
|
+
getBasicFromItem: () => getBasicFromItem
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(getBasicFromItem_exports);
|
|
25
|
+
function getBasicFromItem(item) {
|
|
26
|
+
var _a, _b;
|
|
27
|
+
return {
|
|
28
|
+
guid: item.guid,
|
|
29
|
+
title: item.title,
|
|
30
|
+
link: item.link,
|
|
31
|
+
description: item.summary || ((_a = item.contentSnippet) == null ? void 0 : _a.trim()) || "",
|
|
32
|
+
pubDate: new Date(item.pubDate),
|
|
33
|
+
author: item.author || item.creator || "",
|
|
34
|
+
source: item.source || "",
|
|
35
|
+
categories: ((_b = item.categories) == null ? void 0 : _b.join(",")) || ""
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
+
0 && (module.exports = {
|
|
40
|
+
getBasicFromItem
|
|
41
|
+
});
|
|
@@ -37,6 +37,7 @@ var cheerio = __toESM(require("cheerio"));
|
|
|
37
37
|
var import_stripeHtml = require("./stripeHtml");
|
|
38
38
|
var import_parseContent = require("./parseContent");
|
|
39
39
|
var import_zx = require("zx");
|
|
40
|
+
var import_getBasicFromItem = require("./getBasicFromItem");
|
|
40
41
|
async function parseContent(item, strategy) {
|
|
41
42
|
var _a, _b;
|
|
42
43
|
let element;
|
|
@@ -55,11 +56,8 @@ async function parseContent(item, strategy) {
|
|
|
55
56
|
if (!(strategy == null ? void 0 : strategy.parse)) {
|
|
56
57
|
return {
|
|
57
58
|
type: "simple",
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
link: item.link,
|
|
61
|
-
description: ((_b = element.html()) == null ? void 0 : _b.trim()) || "",
|
|
62
|
-
pubDate: new Date(item.pubDate)
|
|
59
|
+
...(0, import_getBasicFromItem.getBasicFromItem)(item),
|
|
60
|
+
content: ((_b = element.html()) == null ? void 0 : _b.trim()) || ""
|
|
63
61
|
};
|
|
64
62
|
}
|
|
65
63
|
console.log(import_zx.chalk.green("正在解析文章内容"));
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { ParseStrategy, RichArticle } from "../types";
|
|
1
|
+
import type { ParseStrategy, RichArticle, RssItem } from "../types";
|
|
3
2
|
import { AnyNode, Cheerio, CheerioAPI } from "cheerio";
|
|
4
3
|
export declare function parseContent($: CheerioAPI, $element: Cheerio<AnyNode>, item: RssItem, strategy?: ParseStrategy): Promise<RichArticle>;
|
|
@@ -37,8 +37,8 @@ var import_probe_image_size = __toESM(require("probe-image-size"));
|
|
|
37
37
|
var import_zx = require("zx");
|
|
38
38
|
var import_html_entities = require("html-entities");
|
|
39
39
|
var import_generateSsrContent = require("./generateSsrContent");
|
|
40
|
+
var import_getBasicFromItem = require("./getBasicFromItem");
|
|
40
41
|
async function parseContent($, $element, item, strategy) {
|
|
41
|
-
var _a;
|
|
42
42
|
const srcs = [];
|
|
43
43
|
const images = [];
|
|
44
44
|
(0, import_utils.walk_the_DOM)($, $element, (node) => {
|
|
@@ -96,13 +96,9 @@ async function parseContent($, $element, item, strategy) {
|
|
|
96
96
|
const content = (0, import_html_entities.decode)($element.html().trim());
|
|
97
97
|
return {
|
|
98
98
|
type: "rich",
|
|
99
|
-
|
|
100
|
-
title: item.title,
|
|
101
|
-
link: item.link,
|
|
102
|
-
description: ((_a = item.contentSnippet) == null ? void 0 : _a.trim()) || "",
|
|
99
|
+
...(0, import_getBasicFromItem.getBasicFromItem)(item),
|
|
103
100
|
content: (0, import_html_entities.decode)($element.html().trim()),
|
|
104
101
|
ssrContent: (0, import_generateSsrContent.generateSsrContent)(content, images),
|
|
105
|
-
pubDate: new Date(item.pubDate),
|
|
106
102
|
images
|
|
107
103
|
};
|
|
108
104
|
}
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import type { AnyNode, Cheerio, CheerioAPI } from 'cheerio';
|
|
2
2
|
import { Item } from 'rss-parser';
|
|
3
|
+
export type RssItem = Item & {
|
|
4
|
+
source?: string;
|
|
5
|
+
author?: string;
|
|
6
|
+
};
|
|
3
7
|
export interface ParseStrategy {
|
|
4
8
|
parse: boolean;
|
|
5
9
|
fetcher?: 'http' | 'playwright';
|
|
@@ -12,7 +16,11 @@ export interface SimpleArticle {
|
|
|
12
16
|
title: string;
|
|
13
17
|
link: string;
|
|
14
18
|
description: string;
|
|
19
|
+
content: string;
|
|
15
20
|
pubDate: Date;
|
|
21
|
+
author?: string;
|
|
22
|
+
source?: string;
|
|
23
|
+
categories?: string;
|
|
16
24
|
}
|
|
17
25
|
export interface RichArticleImage {
|
|
18
26
|
url: string;
|
|
@@ -26,7 +34,6 @@ export interface RichArticleImage {
|
|
|
26
34
|
}
|
|
27
35
|
export interface RichArticle extends Omit<SimpleArticle, 'type'> {
|
|
28
36
|
type: 'rich';
|
|
29
|
-
content: string;
|
|
30
37
|
ssrContent: string;
|
|
31
38
|
images: RichArticleImage[];
|
|
32
39
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ns-rss-spider",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.18",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"types": "dist/cjs/index.d.ts",
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
"build": "father build",
|
|
11
11
|
"build:deps": "father prebundle",
|
|
12
12
|
"check": "father doctor",
|
|
13
|
-
"prepublishOnly": "father doctor && npm run build",
|
|
14
13
|
"sync": "echo '去更新 registry 版本: https://www.npmmirror.com/sync/ns-rss-spider'",
|
|
15
14
|
"pub": "npm run check && npm version patch && npm run build && npm publish --registry=https://registry.npmjs.org && git push origin master --tags && npm run sync"
|
|
16
15
|
},
|