ns-rss-spider 0.0.26 → 0.0.28

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.
@@ -63,11 +63,13 @@ async function parseContent(item, strategy) {
63
63
  console.log(import_zx.chalk.green("正在解析文章内容"));
64
64
  const rich = await (0, import_parseContent.parseContent)($, element, item, strategy);
65
65
  let extra = {};
66
- if (strategy.getExtraItems) {
67
- console.log(import_zx.chalk.green("正在执行 getExtraItems"));
68
- extra = await strategy.getExtraItems($, rich, item).catch((e) => {
69
- console.error(import_zx.chalk.red("getExtraItems 识别"), e);
70
- }) || {};
66
+ if (rich.type === "rich") {
67
+ if (strategy.getExtraItems) {
68
+ console.log(import_zx.chalk.green("正在执行 getExtraItems"));
69
+ extra = await strategy.getExtraItems($, rich, item).catch((e) => {
70
+ console.error(import_zx.chalk.red("getExtraItems 识别"), e);
71
+ }) || {};
72
+ }
71
73
  }
72
74
  return {
73
75
  ...rich,
@@ -1,3 +1,3 @@
1
- import type { ParseStrategy, RichArticle, RssItem } from "../types";
1
+ import type { Article, ParseStrategy, RssItem } from "../types";
2
2
  import { AnyNode, Cheerio, CheerioAPI } from "cheerio";
3
- export declare function parseContent($: CheerioAPI, $element: Cheerio<AnyNode>, item: RssItem, strategy?: ParseStrategy): Promise<RichArticle>;
3
+ export declare function parseContent($: CheerioAPI, $element: Cheerio<AnyNode>, item: RssItem, strategy?: ParseStrategy): Promise<Article>;
@@ -103,6 +103,13 @@ async function parseContent($, $element, item, strategy) {
103
103
  });
104
104
  const elCont = ((_a = strategy == null ? void 0 : strategy.getContentFromHtml) == null ? void 0 : _a.call(strategy, $, $element)) || $element.html() || "";
105
105
  const content = (0, import_html_entities.decode)(elCont.trim());
106
+ if (!content) {
107
+ return {
108
+ type: "simple",
109
+ content: "",
110
+ ...(0, import_getBasicFromItem.getBasicFromItem)(item)
111
+ };
112
+ }
106
113
  return {
107
114
  type: "rich",
108
115
  ...(0, import_getBasicFromItem.getBasicFromItem)(item),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ns-rss-spider",
3
- "version": "0.0.26",
3
+ "version": "0.0.28",
4
4
  "description": "",
5
5
  "main": "dist/cjs/index.js",
6
6
  "types": "dist/cjs/index.d.ts",