ns-rss-spider 0.0.21 → 0.0.23

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.
@@ -1,15 +1,5 @@
1
1
  import { ServerInfo } from "./upload";
2
- import { Article } from "./types";
3
- export declare function parseRss(name: string, feed: string, server?: ServerInfo): Promise<Article[] | {
4
- storePath: any;
5
- type: "simple" | "rich";
6
- guid: string;
7
- title: string;
8
- link: string;
9
- description: string;
10
- pubDate: Date;
11
- author?: string | undefined;
12
- source?: string | undefined;
13
- categories?: string | undefined;
14
- thumb?: string | undefined;
15
- }[]>;
2
+ export declare function parseRss(name: string, feed: string, server?: ServerInfo): Promise<{
3
+ contents: any[];
4
+ thumbs?: Record<string, string>;
5
+ }>;
package/dist/cjs/parse.js CHANGED
@@ -57,32 +57,33 @@ async function parseRss(name, feed, server) {
57
57
  });
58
58
  console.log("after num", result.items.length);
59
59
  }
60
- if (!result.items.length) {
61
- return [];
62
- }
63
- result.items.forEach((item) => {
64
- if (!item.guid) {
65
- item.guid = item.link;
66
- }
67
- });
68
- const strategy = import_strategy.strategies[name];
69
60
  const contents = [];
70
- for (let item of result.items) {
71
- console.log(import_zx.chalk.green(`正在解析文章 【${item.title}】`));
72
- if (!item.guid) {
73
- console.log(JSON.stringify(item));
74
- throw Error(`item has no guid`);
75
- }
76
- const content = await (0, import_parseContent.parseContent)(item, strategy).catch((e) => console.error(import_zx.chalk.red("文章解析失败"), e));
77
- if (content) {
78
- contents.push(content);
61
+ const strategy = import_strategy.strategies[name];
62
+ if (result.items.length) {
63
+ result.items.forEach((item) => {
64
+ if (!item.guid) {
65
+ item.guid = item.link;
66
+ }
67
+ });
68
+ for (let item of result.items) {
69
+ console.log(import_zx.chalk.green(`正在解析文章 【${item.title}】`));
70
+ if (!item.guid) {
71
+ console.log(JSON.stringify(item));
72
+ throw Error(`item has no guid`);
73
+ }
74
+ const content = await (0, import_parseContent.parseContent)(item, strategy).catch((e) => console.error(import_zx.chalk.red("文章解析失败"), e));
75
+ if (content) {
76
+ contents.push(content);
77
+ }
79
78
  }
80
79
  }
80
+ let thumbs;
81
81
  if (strategy == null ? void 0 : strategy.getThumbs) {
82
82
  console.log(import_zx.chalk.green(`正在获取缩略图数据`));
83
83
  const thumbKv = await (strategy == null ? void 0 : strategy.getThumbs(contents));
84
84
  if (thumbKv && Object.keys(thumbKv).length) {
85
85
  console.log(import_zx.chalk.green(`正在更新缩略图`));
86
+ thumbs = thumbKv;
86
87
  contents.forEach((content) => {
87
88
  if (thumbKv[content.guid]) {
88
89
  content.thumb = thumbKv[content.guid];
@@ -102,9 +103,12 @@ async function parseRss(name, feed, server) {
102
103
  }).catch((e) => {
103
104
  });
104
105
  }
105
- return r;
106
+ return {
107
+ contents: r,
108
+ thumbs
109
+ };
106
110
  } else {
107
- return contents;
111
+ return { contents, thumbs };
108
112
  }
109
113
  }
110
114
  // Annotate the CommonJS export names for ESM import in node:
@@ -68,7 +68,7 @@ var cnbeta = {
68
68
  const html = res.data;
69
69
  const $ = (0, import_cheerio.load)(html, null, false);
70
70
  const kv = {};
71
- $("#it_tech .txt_thumb > a").each((_, $a) => {
71
+ $("#main > section li .txt_thumb > a").each((_, $a) => {
72
72
  var _a, _b;
73
73
  const thumb = $($a).find("img").attr("src");
74
74
  const href = $($a).attr("href") || "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ns-rss-spider",
3
- "version": "0.0.21",
3
+ "version": "0.0.23",
4
4
  "description": "",
5
5
  "main": "dist/cjs/index.js",
6
6
  "types": "dist/cjs/index.d.ts",