ns-rss-spider 1.0.15 → 1.1.0
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/parseContent/parseContent.js +3 -1
- package/dist/cjs/parsers/oschina.d.ts +2 -0
- package/dist/cjs/parsers/oschina.js +37 -0
- package/dist/cjs/strategy.js +3 -1
- package/dist/cjs/types.d.ts +1 -0
- package/dist/cjs/upload/index.d.ts +1 -0
- package/dist/cjs/utils/getArticleImage.d.ts +11 -0
- package/dist/cjs/utils/getArticleImage.js +37 -0
- package/package.json +1 -1
|
@@ -38,6 +38,7 @@ var import_zx = require("zx");
|
|
|
38
38
|
var import_html_entities = require("html-entities");
|
|
39
39
|
var import_generateSsrContent = require("./generateSsrContent");
|
|
40
40
|
var import_getBasicFromItem = require("./getBasicFromItem");
|
|
41
|
+
var import_getArticleImage = require("../utils/getArticleImage");
|
|
41
42
|
async function parseContent($, $element, item, strategy) {
|
|
42
43
|
var _a;
|
|
43
44
|
const srcs = [];
|
|
@@ -117,7 +118,8 @@ async function parseContent($, $element, item, strategy) {
|
|
|
117
118
|
...(0, import_getBasicFromItem.getBasicFromItem)(item),
|
|
118
119
|
content,
|
|
119
120
|
ssrContent: (0, import_generateSsrContent.generateSsrContent)(content, images),
|
|
120
|
-
images
|
|
121
|
+
images,
|
|
122
|
+
image: (0, import_getArticleImage.getImage)(images)
|
|
121
123
|
};
|
|
122
124
|
}
|
|
123
125
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -0,0 +1,37 @@
|
|
|
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/parsers/oschina.ts
|
|
20
|
+
var oschina_exports = {};
|
|
21
|
+
__export(oschina_exports, {
|
|
22
|
+
oschina: () => oschina
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(oschina_exports);
|
|
25
|
+
var oschina = {
|
|
26
|
+
parse: true,
|
|
27
|
+
fetcher: "http",
|
|
28
|
+
getContentElementFromArticle: ($) => {
|
|
29
|
+
const el = $(".article-detail > .content");
|
|
30
|
+
$(el).find(".ad-wrap").remove();
|
|
31
|
+
return $(el);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
+
0 && (module.exports = {
|
|
36
|
+
oschina
|
|
37
|
+
});
|
package/dist/cjs/strategy.js
CHANGED
|
@@ -31,6 +31,7 @@ var import_techrunch = require("./parsers/techrunch");
|
|
|
31
31
|
var import_mydrivers = require("./parsers/mydrivers");
|
|
32
32
|
var import_tmtpost = require("./parsers/tmtpost");
|
|
33
33
|
var import_leiphone = require("./parsers/leiphone");
|
|
34
|
+
var import_oschina = require("./parsers/oschina");
|
|
34
35
|
var strategies = {
|
|
35
36
|
cnbeta: import_cnbeta.cnbeta,
|
|
36
37
|
ifanr: import_ifanr.ifanr,
|
|
@@ -40,7 +41,8 @@ var strategies = {
|
|
|
40
41
|
techrunch: import_techrunch.techrunch,
|
|
41
42
|
mydrivers: import_mydrivers.mydrivers,
|
|
42
43
|
tmtpost: import_tmtpost.tmtpost,
|
|
43
|
-
leiphone: import_leiphone.leiphone
|
|
44
|
+
leiphone: import_leiphone.leiphone,
|
|
45
|
+
oschina: import_oschina.oschina
|
|
44
46
|
};
|
|
45
47
|
// Annotate the CommonJS export names for ESM import in node:
|
|
46
48
|
0 && (module.exports = {
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { RichArticleImage } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* 从 article images 中获取 image 数据。目前用作无 thumb 时的降级
|
|
4
|
+
* 若都没有尺寸,选第一张
|
|
5
|
+
对于有尺寸的图片,按如下优先级
|
|
6
|
+
第一个长宽比大于 1.5 且长大于 80 小于 1000 的图片
|
|
7
|
+
若没有,则第一个图片
|
|
8
|
+
* @param images
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
export declare const getImage: (images: RichArticleImage[]) => string | undefined;
|
|
@@ -0,0 +1,37 @@
|
|
|
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/utils/getArticleImage.ts
|
|
20
|
+
var getArticleImage_exports = {};
|
|
21
|
+
__export(getArticleImage_exports, {
|
|
22
|
+
getImage: () => getImage
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(getArticleImage_exports);
|
|
25
|
+
var getImage = (images) => {
|
|
26
|
+
if (!(images == null ? void 0 : images.length)) {
|
|
27
|
+
return void 0;
|
|
28
|
+
}
|
|
29
|
+
const img = images.find((img2) => {
|
|
30
|
+
return img2.width && img2.height && img2.width / img2.height >= 1.5 && img2.width < 2e3;
|
|
31
|
+
});
|
|
32
|
+
return img == null ? void 0 : img.url;
|
|
33
|
+
};
|
|
34
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
+
0 && (module.exports = {
|
|
36
|
+
getImage
|
|
37
|
+
});
|