podverse-parser 5.0.1 → 5.0.2
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,5 +1,5 @@
|
|
|
1
1
|
import { FeedObject } from "podcast-partytime";
|
|
2
2
|
import { Feed } from "podverse-orm";
|
|
3
3
|
export declare const handleGetRSSFeed: (feed: Feed) => Promise<FeedObject>;
|
|
4
|
-
export declare const handleParsedFeed: (parsedFeed: FeedObject,
|
|
4
|
+
export declare const handleParsedFeed: (parsedFeed: FeedObject, feed: Feed) => Promise<Feed>;
|
|
5
5
|
//# sourceMappingURL=feed.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feed.d.ts","sourceRoot":"","sources":["../../../../src/lib/rss/feed/feed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,OAAO,EAAoC,IAAI,EAA+B,MAAM,cAAc,CAAC;AAInG,eAAO,MAAM,gBAAgB,SAAgB,IAAI,KAAG,OAAO,CAAC,UAAU,CAmCrE,CAAC;AAEF,eAAO,MAAM,gBAAgB,eAAsB,UAAU,
|
|
1
|
+
{"version":3,"file":"feed.d.ts","sourceRoot":"","sources":["../../../../src/lib/rss/feed/feed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,OAAO,EAAoC,IAAI,EAA+B,MAAM,cAAc,CAAC;AAInG,eAAO,MAAM,gBAAgB,SAAgB,IAAI,KAAG,OAAO,CAAC,UAAU,CAmCrE,CAAC;AAEF,eAAO,MAAM,gBAAgB,eAAsB,UAAU,QAAQ,IAAI,KAAG,OAAO,CAAC,IAAI,CAgBvF,CAAC"}
|
|
@@ -49,18 +49,17 @@ const handleGetRSSFeed = (feed) => __awaiter(void 0, void 0, void 0, function* (
|
|
|
49
49
|
return parsedFeed;
|
|
50
50
|
});
|
|
51
51
|
exports.handleGetRSSFeed = handleGetRSSFeed;
|
|
52
|
-
const handleParsedFeed = (parsedFeed,
|
|
53
|
-
const feedService = new podverse_orm_1.FeedService();
|
|
54
|
-
const feed = yield feedService.getOrCreate({ url, podcast_index_id });
|
|
52
|
+
const handleParsedFeed = (parsedFeed, feed) => __awaiter(void 0, void 0, void 0, function* () {
|
|
55
53
|
// TODO: move before partytime parsing
|
|
56
54
|
if (!(0, podverse_orm_1.checkIfFeedFlagStatusShouldParse)(feed.feed_flag_status.id)) {
|
|
57
|
-
throw new Error(`parseRSSFeedAndSaveToDatabase: feed_flag_status.status is not None or AlwaysAllow for ${url}`);
|
|
55
|
+
throw new Error(`parseRSSFeedAndSaveToDatabase: feed_flag_status.status is not None or AlwaysAllow for ${feed.id} ${feed.channel.podcast_index_id} ${feed.url}`);
|
|
58
56
|
}
|
|
59
57
|
checkIfFeedIsParsing(feed);
|
|
60
58
|
const currentFeedFileHash = (0, parsedFeed_1.getParsedFeedMd5Hash)(parsedFeed);
|
|
61
59
|
if (feed.last_parsed_file_hash === currentFeedFileHash) {
|
|
62
60
|
throw new Error(`Feed ${feed.id} has no changes since last parsed.`);
|
|
63
61
|
}
|
|
62
|
+
const feedService = new podverse_orm_1.FeedService();
|
|
64
63
|
return feedService.update(feed.id, { last_parsed_file_hash: currentFeedFileHash });
|
|
65
64
|
});
|
|
66
65
|
exports.handleParsedFeed = handleParsedFeed;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../../src/lib/rss/parser.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,gBAAgB,oBAM5B,CAAC;AAEF,eAAO,MAAM,kBAAkB,QAAe,MAAM,oDASnD,CAAC;AAQF,eAAO,MAAM,6BAA6B,QAAe,MAAM,oBAAoB,MAAM,
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../../src/lib/rss/parser.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,gBAAgB,oBAM5B,CAAC;AAEF,eAAO,MAAM,kBAAkB,QAAe,MAAM,oDASnD,CAAC;AAQF,eAAO,MAAM,6BAA6B,QAAe,MAAM,oBAAoB,MAAM,iBA2DxF,CAAC"}
|
package/dist/lib/rss/parser.js
CHANGED
|
@@ -48,12 +48,24 @@ exports.getAndParseRSSFeed = getAndParseRSSFeed;
|
|
|
48
48
|
// };
|
|
49
49
|
const parseRSSFeedAndSaveToDatabase = (url, podcast_index_id) => __awaiter(void 0, void 0, void 0, function* () {
|
|
50
50
|
const feedService = new podverse_orm_1.FeedService();
|
|
51
|
-
let feed = yield feedService.
|
|
51
|
+
let feed = yield feedService.getByUrlAndPodcastIndexId({ url, podcast_index_id });
|
|
52
|
+
if (!feed) {
|
|
53
|
+
feed = yield feedService.getByPodcastIndexId({ podcast_index_id });
|
|
54
|
+
if (feed) {
|
|
55
|
+
feed.url = url;
|
|
56
|
+
yield feedService.update(feed.id, { url });
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
// TODO: we may not want to create feeds in this helper in production
|
|
60
|
+
// but i'm adding it here for stage testing.
|
|
61
|
+
if (!feed) {
|
|
62
|
+
feed = yield feedService.getOrCreate({ url, podcast_index_id });
|
|
63
|
+
}
|
|
52
64
|
if (!feed) {
|
|
53
65
|
throw new Error(`parseRSSFeedAndSaveToDatabase: feed not found for ${url}`);
|
|
54
66
|
}
|
|
55
67
|
const parsedFeed = yield (0, feed_1.handleGetRSSFeed)(feed);
|
|
56
|
-
feed = yield (0, feed_1.handleParsedFeed)(parsedFeed,
|
|
68
|
+
feed = yield (0, feed_1.handleParsedFeed)(parsedFeed, feed);
|
|
57
69
|
try {
|
|
58
70
|
yield feedService.update(feed.id, { is_parsing: new Date() });
|
|
59
71
|
const channelService = new podverse_orm_1.ChannelService();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "podverse-parser",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"dist/**/*"
|
|
9
9
|
],
|
|
10
10
|
"scripts": {
|
|
11
|
-
"dev:watch": "nodemon --watch 'src' --watch $(realpath node_modules/podverse-
|
|
11
|
+
"dev:watch": "nodemon --watch 'src' --watch $(realpath node_modules/podverse-helpers) --watch $(realpath node_modules/podverse-orm) --delay 500ms -x \"npm run build\"",
|
|
12
12
|
"build": "tsc",
|
|
13
13
|
"lint": "eslint ./src --ext .ts",
|
|
14
14
|
"prepare": "npm run build",
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"@eslint/js": "^9.8.0",
|
|
29
29
|
"@types/node": "^22.1.0",
|
|
30
30
|
"eslint": "^9.9.0",
|
|
31
|
+
"nodemon": "^3.1.4",
|
|
31
32
|
"ts-node": "^10.9.2",
|
|
32
33
|
"typescript": "^5.5.4",
|
|
33
34
|
"typescript-eslint": "^8.0.1"
|