podverse-parser 5.1.0-alpha.4 → 5.1.0-alpha.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.
- package/dist/lib/rss/errors.d.ts +7 -0
- package/dist/lib/rss/errors.d.ts.map +1 -0
- package/dist/lib/rss/errors.js +17 -0
- package/dist/lib/rss/feed/feed.d.ts.map +1 -1
- package/dist/lib/rss/feed/feed.js +3 -3
- package/dist/lib/rss/parser.d.ts.map +1 -1
- package/dist/lib/rss/parser.js +11 -1
- package/package.json +3 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/lib/rss/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,kBAAmB,SAAQ,KAAK;gBAC/B,MAAM,EAAE,MAAM;CAI3B;AAED,qBAAa,iCAAkC,SAAQ,KAAK;gBAC9C,MAAM,EAAE,MAAM;CAI3B"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FeedNoChangesSinceLastParsedError = exports.FeedIsParsingError = void 0;
|
|
4
|
+
class FeedIsParsingError extends Error {
|
|
5
|
+
constructor(feedId) {
|
|
6
|
+
super(`Feed ${feedId} is already parsing`);
|
|
7
|
+
this.name = 'FeedIsParsingError';
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.FeedIsParsingError = FeedIsParsingError;
|
|
11
|
+
class FeedNoChangesSinceLastParsedError extends Error {
|
|
12
|
+
constructor(feedId) {
|
|
13
|
+
super(`Feed ${feedId} has no changes since last parsed.`);
|
|
14
|
+
this.name = 'FeedNoChangesSinceLastParsedError';
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.FeedNoChangesSinceLastParsedError = FeedNoChangesSinceLastParsedError;
|
|
@@ -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,EAAE,IAAI,EAA+B,MAAM,cAAc,CAAC;
|
|
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,EAAE,IAAI,EAA+B,MAAM,cAAc,CAAC;AAMjE,eAAO,MAAM,gBAAgB,GAAU,KAAK,MAAM,EAAE,kBAAkB,MAAM,KAAG,OAAO,CAAC,IAAI,CA0B1F,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAU,MAAM,IAAI,KAAG,OAAO,CAAC,UAAU,CAsCzE,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAU,YAAY,UAAU,EAAE,MAAM,IAAI,KAAG,OAAO,CAAC,IAAI,CAYvF,CAAC"}
|
|
@@ -15,6 +15,7 @@ const podverse_orm_1 = require("podverse-orm");
|
|
|
15
15
|
const config_1 = require("@parser/config");
|
|
16
16
|
const parsedFeed_1 = require("../hash/parsedFeed");
|
|
17
17
|
const parser_1 = require("../parser");
|
|
18
|
+
const errors_1 = require("../errors");
|
|
18
19
|
const handleGetRSSFeed = (url, podcast_index_id) => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
20
|
podverse_helpers_1.timerManager.start('handleGetRSSFeed');
|
|
20
21
|
const feedService = new podverse_orm_1.FeedService();
|
|
@@ -78,7 +79,7 @@ const handleParsedFeed = (parsedFeed, feed) => __awaiter(void 0, void 0, void 0,
|
|
|
78
79
|
if (config_1.config.nodeEnv === 'production') {
|
|
79
80
|
checkIfFeedIsParsing(feed);
|
|
80
81
|
if (feed.last_parsed_file_hash === currentFeedFileHash) {
|
|
81
|
-
throw new
|
|
82
|
+
throw new errors_1.FeedNoChangesSinceLastParsedError(feed.id);
|
|
82
83
|
}
|
|
83
84
|
}
|
|
84
85
|
const feedService = new podverse_orm_1.FeedService();
|
|
@@ -86,13 +87,12 @@ const handleParsedFeed = (parsedFeed, feed) => __awaiter(void 0, void 0, void 0,
|
|
|
86
87
|
});
|
|
87
88
|
exports.handleParsedFeed = handleParsedFeed;
|
|
88
89
|
const checkIfFeedIsParsing = (feed) => {
|
|
89
|
-
// TODO: handle with caching db / redis instead of database?
|
|
90
90
|
if (feed.is_parsing) {
|
|
91
91
|
const parsingDate = new Date(feed.is_parsing);
|
|
92
92
|
const currentDate = new Date();
|
|
93
93
|
const timeDifference = (currentDate.getTime() - parsingDate.getTime()) / (1000 * 60);
|
|
94
94
|
if (timeDifference <= 15) {
|
|
95
|
-
throw new
|
|
95
|
+
throw new errors_1.FeedIsParsingError(feed.id);
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../../src/lib/rss/parser.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../../src/lib/rss/parser.ts"],"names":[],"mappings":"AAoBA,eAAO,MAAM,kBAAkB,GAAU,KAAK,MAAM,oDASnD,CAAC;AAQF,eAAO,MAAM,6BAA6B,GAAU,KAAK,MAAM,EAAE,kBAAkB,MAAM,kBAoFxF,CAAC"}
|
package/dist/lib/rss/parser.js
CHANGED
|
@@ -22,6 +22,7 @@ const feed_1 = require("@parser/lib/rss/feed/feed");
|
|
|
22
22
|
const item_1 = require("@parser/lib/rss/item/item");
|
|
23
23
|
const liveItem_1 = require("@parser/lib/rss/liveItem/liveItem");
|
|
24
24
|
const remoteItemParser_1 = require("@parser/lib/rss/remoteItemParser");
|
|
25
|
+
const errors_1 = require("./errors");
|
|
25
26
|
/*
|
|
26
27
|
NOTE: All RSS feeds that have a podcast_index_id will be saved to the database.
|
|
27
28
|
RSS feeds without podcast_index_id (Add By RSS feeds) will NOT be saved to the database.
|
|
@@ -87,7 +88,16 @@ const parseRSSFeedAndSaveToDatabase = (url, podcast_index_id) => __awaiter(void
|
|
|
87
88
|
yield feedLogService.update(feed, { last_finished_parse_time: new Date() });
|
|
88
89
|
}
|
|
89
90
|
catch (error) {
|
|
90
|
-
(
|
|
91
|
+
if (error instanceof errors_1.FeedIsParsingError) {
|
|
92
|
+
podverse_helpers_1.logger.warn(`Feed ${feed === null || feed === void 0 ? void 0 : feed.id} is already parsing.`);
|
|
93
|
+
}
|
|
94
|
+
else if (error instanceof errors_1.FeedNoChangesSinceLastParsedError) {
|
|
95
|
+
podverse_helpers_1.logger.warn(`Feed ${feed === null || feed === void 0 ? void 0 : feed.id} has no changes since last parsed.`);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
// TODO: Handle other errors
|
|
99
|
+
(0, podverse_helpers_1.logError)('parseRSSFeedAndSaveToDatabase', error);
|
|
100
|
+
}
|
|
91
101
|
}
|
|
92
102
|
finally {
|
|
93
103
|
podverse_helpers_1.timerManager.endAll();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "podverse-parser",
|
|
3
|
-
"version": "5.1.0-alpha.
|
|
3
|
+
"version": "5.1.0-alpha.6",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"module-alias": "^2.2.3",
|
|
20
20
|
"podcast-partytime": "^4.8.1",
|
|
21
|
-
"podverse-external-services": "^5.1.1-alpha.
|
|
21
|
+
"podverse-external-services": "^5.1.1-alpha.10",
|
|
22
22
|
"podverse-helpers": "^5.1.2-alpha.4",
|
|
23
|
-
"podverse-orm": "^5.1.0-alpha.
|
|
23
|
+
"podverse-orm": "^5.1.0-alpha.8"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@eslint/config-array": "^0.18.0",
|