ns-rss-spider 1.2.2 → 1.2.5

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.
@@ -105,7 +105,12 @@ async function parseContent($, $element, item, strategy) {
105
105
  }
106
106
  }
107
107
  });
108
- const elCont = ((_a = strategy == null ? void 0 : strategy.getContentFromHtml) == null ? void 0 : _a.call(strategy, $, $element)) || $element.html() || "";
108
+ console.log(import_zx.chalk.green("正在生成 html content"));
109
+ const strategyContent = (_a = strategy == null ? void 0 : strategy.getContentFromHtml) == null ? void 0 : _a.call(strategy, $, $element);
110
+ if (!strategyContent) {
111
+ console.log(import_zx.chalk.yellow("未提供 getContentFromHtml,使用默认方案"));
112
+ }
113
+ const elCont = strategyContent || $element.html() || "";
109
114
  const content = (0, import_html_entities.decode)(elCont.trim());
110
115
  if (!content) {
111
116
  console.error(import_zx.chalk.red("解析 html 内容出错, html 如下"));
@@ -26,13 +26,12 @@ var macrumors = {
26
26
  parse: true,
27
27
  fetcher: "http",
28
28
  getContentElementFromArticle: ($) => {
29
- const el = $("#maincontent > article");
29
+ const el = $("#maincontent > article .js-content > div");
30
30
  return el;
31
31
  },
32
32
  getContentFromHtml: ($, $el) => {
33
- const content = $el.find(".js-content > div");
34
- content.find('[id^="AdThrive_Content_"]').remove();
35
- return content.html() || "";
33
+ $el.find('[id^="AdThrive_Content_"]').remove();
34
+ return $el.html() || "";
36
35
  }
37
36
  };
38
37
  // Annotate the CommonJS export names for ESM import in node:
@@ -1,4 +1,4 @@
1
- import { Article } from "../types";
1
+ import { Article, RichArticleImage } from "../types";
2
2
  export interface ServerInfo {
3
3
  getUploadApi?: string;
4
4
  callback?: string;
@@ -11,8 +11,9 @@ export declare function uploadContent({ app, getUploadApi, items, }: {
11
11
  app: string;
12
12
  items: Article[];
13
13
  } & ServerInfo): Promise<Article[] | {
14
+ images?: RichArticleImage[] | undefined;
14
15
  storePath: any;
15
- type: "newsletter" | "simple" | "rich";
16
+ type: "simple" | "rich" | "newsletter";
16
17
  guid: string;
17
18
  title: string;
18
19
  link: string;
@@ -35,6 +35,22 @@ module.exports = __toCommonJS(upload_exports);
35
35
  var import_lodash = require("lodash");
36
36
  var import_axios = __toESM(require("axios"));
37
37
  var import_zx = require("zx");
38
+ function filterImages(images) {
39
+ let filtered = images.filter(
40
+ (img) => img.width && img.width > 600 && img.type !== "image/gif"
41
+ );
42
+ if (filtered.length > 5) {
43
+ const seen = /* @__PURE__ */ new Set();
44
+ filtered = filtered.filter((img) => {
45
+ const key = `${img.width}x${img.height}`;
46
+ if (seen.has(key))
47
+ return false;
48
+ seen.add(key);
49
+ return true;
50
+ });
51
+ }
52
+ return filtered;
53
+ }
38
54
  async function uploadContent({
39
55
  app,
40
56
  getUploadApi,
@@ -75,9 +91,14 @@ async function uploadContent({
75
91
  console.error(import_zx.chalk.red("upload status not 200 or 201"), res);
76
92
  continue;
77
93
  }
94
+ let filteredImages = [];
95
+ if (item.type === "rich") {
96
+ filteredImages = filterImages(item.images);
97
+ }
78
98
  result.push({
79
99
  ...(0, import_lodash.omit)(item, "content", "ssrContent", "images"),
80
- storePath
100
+ storePath,
101
+ ...filteredImages.length > 0 && { images: filteredImages }
81
102
  });
82
103
  }
83
104
  return result;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ns-rss-spider",
3
- "version": "1.2.2",
3
+ "version": "1.2.5",
4
4
  "description": "",
5
5
  "main": "dist/cjs/index.js",
6
6
  "types": "dist/cjs/index.d.ts",