Skip to content

Commit

Permalink
chore: update node version to 22 and enhance content extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
Soontao committed Jan 5, 2025
1 parent ea4cb96 commit c3f98c3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"name": "start-rsshub",
"skipFiles": ["<node_internals>/**"],
"runtimeExecutable": "node",
"runtimeVersion": "20",
"runtimeVersion": "22",
"outputCapture": "std",
"program": "${workspaceFolder}/packages/rss-server/index.js",
"envFile": "${workspaceFolder}/.env",
Expand All @@ -33,7 +33,7 @@
"name": "start-rsshub (without ssl)",
"skipFiles": ["<node_internals>/**"],
"runtimeExecutable": "node",
"runtimeVersion": "20",
"runtimeVersion": "22",
"outputCapture": "std",
"program": "${workspaceFolder}/packages/rss-server/index.js",
"envFile": "${workspaceFolder}/.env",
Expand Down
10 changes: 9 additions & 1 deletion packages/rss-libs/utils/common-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,15 @@ class GenericEndpointBuilder {
* @returns {GenericEndpointBuilder} - 当前构建器实例,以便链式调用。
*/
withContentExtractor(extractor) {
this.options.contentExtractor = extractor;
if (!this.options.contentExtractor) {
this.options.contentExtractor = extractor;
} else {
const e0 = this.options.contentExtractor;
this.options.contentExtractor = async (...args) => {
return Object.assign({}, await e0(...args), await extractor(...args))
}
}

return this;
}

Expand Down
5 changes: 5 additions & 0 deletions packages/rss-server/customize/cmu-pavlo/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
const { GenericEndpointBuilder } = require("rss-libs/utils/common-utils");
const moment = require("moment");

const endpoint = GenericEndpointBuilder.new()
.withEndpointPath("/cmu/pavlo")
.withEntryUrl("https://www.cs.cmu.edu/~pavlo/blog/index.html")
.withDomAEleLinkExtractor("h4 a")
.withAutoContentExtractor()
.withContentExtractor(($) => ({
// 'Posted on October 03, 2016'
pubDate: moment($(".postdate",).text()?.slice('Posted on '.length), "MMMM DD, YYYY").toISOString(),
}))
.build();

module.exports = endpoint;

0 comments on commit c3f98c3

Please sign in to comment.