ns-rss-spider 1.2.3 → 1.2.6
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,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: "
|
|
16
|
+
type: "simple" | "rich" | "newsletter";
|
|
16
17
|
guid: string;
|
|
17
18
|
title: string;
|
|
18
19
|
link: string;
|
package/dist/cjs/upload/index.js
CHANGED
|
@@ -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 >= 400 && 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;
|