podverse-parser 5.1.6-alpha.2 → 5.1.6-alpha.4

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/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  import './module-alias-config';
2
2
  export { parseChapters } from './lib/chapters/chapters';
3
- export { parseRSSFeedAndSaveToDatabase } from './lib/rss/parser';
3
+ export { parseRSSFeedAndSaveToDatabase, ParseRSSFeedAndSaveToDatabase } from './lib/rss/parser';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,uBAAuB,CAAC;AAE/B,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,6BAA6B,EAAE,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,uBAAuB,CAAC;AAE/B,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,6BAA6B,EAAE,6BAA6B,EAAE,MAAM,kBAAkB,CAAC"}
@@ -90,7 +90,7 @@ const handleParsedFeed = (parsedFeed_2, feed_1, ...args_1) => __awaiter(void 0,
90
90
  throw new errors_1.FeedNoChangesSinceLastParsedError(feed.id);
91
91
  }
92
92
  const feedService = new podverse_orm_1.FeedService();
93
- return feedService.update(feed.id, { last_parsed_file_hash: currentFeedFileHash });
93
+ return feedService.update(feed.id, { last_parsed_file_hash: null });
94
94
  });
95
95
  exports.handleParsedFeed = handleParsedFeed;
96
96
  const checkIfFeedIsParsing = (feed) => {
@@ -1,7 +1,7 @@
1
- export declare const getAndParseRSSFeed: (url: string) => Promise<import("podcast-partytime").FeedObject>;
2
- type ParseRSSFeedAndSaveToDatabase = {
1
+ import { FeedObject } from 'podcast-partytime';
2
+ export declare const getAndParseRSSFeed: (url: string) => Promise<FeedObject>;
3
+ export type ParseRSSFeedAndSaveToDatabase = {
3
4
  forceParse?: boolean;
4
5
  };
5
- export declare const parseRSSFeedAndSaveToDatabase: (url: string, podcast_index_id: number, options?: ParseRSSFeedAndSaveToDatabase) => Promise<void>;
6
- export {};
6
+ export declare const parseRSSFeedAndSaveToDatabase: (url: string, podcast_index_id: number, options: ParseRSSFeedAndSaveToDatabase) => Promise<void>;
7
7
  //# sourceMappingURL=parser.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../../src/lib/rss/parser.ts"],"names":[],"mappings":"AAsBA,eAAO,MAAM,kBAAkB,GAAU,KAAK,MAAM,oDAUnD,CAAC;AAQF,KAAK,6BAA6B,GAAG;IACnC,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAA;AAED,eAAO,MAAM,6BAA6B,GACxC,KAAK,MAAM,EACX,kBAAkB,MAAM,EACxB,UAAS,6BAAkC,kBAwF5C,CAAC"}
1
+ {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../../src/lib/rss/parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,mBAAmB,CAAC;AAuB1D,eAAO,MAAM,kBAAkB,GAAU,KAAK,MAAM,wBAUnD,CAAC;AAQF,MAAM,MAAM,6BAA6B,GAAG;IAC1C,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAA;AAED,eAAO,MAAM,6BAA6B,GACxC,KAAK,MAAM,EACX,kBAAkB,MAAM,EACxB,SAAS,6BAA6B,kBAgGvC,CAAC"}
@@ -25,6 +25,7 @@ const loggerService_1 = require("@parser/factories/loggerService");
25
25
  // import { firebaseAccessTokenServiceFactory } from '@parser/factories/firebaseAccessTokenService';
26
26
  // import { NotificationsServiceFactory } from '@parser/factories/notificationsService';
27
27
  const _request_1 = require("../_request");
28
+ const parsedFeed_1 = require("./hash/parsedFeed");
28
29
  /*
29
30
  NOTE: All RSS feeds that have a podcast_index_id will be saved to the database.
30
31
  RSS feeds without podcast_index_id (Add By RSS feeds) will NOT be saved to the database.
@@ -39,12 +40,13 @@ const getAndParseRSSFeed = (url) => __awaiter(void 0, void 0, void 0, function*
39
40
  return parsedFeed;
40
41
  });
41
42
  exports.getAndParseRSSFeed = getAndParseRSSFeed;
42
- const parseRSSFeedAndSaveToDatabase = (url_1, podcast_index_id_1, ...args_1) => __awaiter(void 0, [url_1, podcast_index_id_1, ...args_1], void 0, function* (url, podcast_index_id, options = {}) {
43
+ const parseRSSFeedAndSaveToDatabase = (url, podcast_index_id, options) => __awaiter(void 0, void 0, void 0, function* () {
43
44
  const feedService = new podverse_orm_1.FeedService();
44
45
  let feed = null;
45
46
  let channel = null;
46
47
  const timerFullRunLabel = `parseRSSFeedAndSaveToDatabase ${url} ${podcast_index_id}`;
47
48
  timerManager_1.timerManager.start(timerFullRunLabel);
49
+ let parsedFeed = null;
48
50
  try {
49
51
  if (!url || !podcast_index_id) {
50
52
  throw new Error(`parseRSSFeedAndSaveToDatabase: url or podcast_index_id is missing for ${url} ${podcast_index_id}`);
@@ -54,7 +56,7 @@ const parseRSSFeedAndSaveToDatabase = (url_1, podcast_index_id_1, ...args_1) =>
54
56
  if (!(0, podverse_orm_1.checkIfFeedFlagStatusShouldParse)(feed.feed_flag_status.id)) {
55
57
  throw new Error(`parseRSSFeedAndSaveToDatabase: feed_flag_status.status is not Active or AlwaysAllow for ${feed.id} ${feed.podcast_index_id} ${feed.url}`);
56
58
  }
57
- const parsedFeed = yield (0, feed_1.handleRequestRSSFeed)(feed);
59
+ parsedFeed = yield (0, feed_1.handleRequestRSSFeed)(feed);
58
60
  feed = yield (0, feed_1.handleParsedFeed)(parsedFeed, feed, options);
59
61
  yield feedService.update(feed.id, { is_parsing: new Date() });
60
62
  if ((0, podverse_orm_1.checkIfSpamFeed)(parsedFeed)) {
@@ -105,7 +107,13 @@ const parseRSSFeedAndSaveToDatabase = (url_1, podcast_index_id_1, ...args_1) =>
105
107
  loggerService_1.loggerService.info(`Finished parsing channel: ${channel === null || channel === void 0 ? void 0 : channel.id} ${channel === null || channel === void 0 ? void 0 : channel.id_text} feed: ${feed === null || feed === void 0 ? void 0 : feed.id} url: ${url} podcast_index_id: ${podcast_index_id}`);
106
108
  timerManager_1.timerManager.endAll();
107
109
  if (feed) {
108
- yield feedService.update(feed.id, { is_parsing: null });
110
+ if (parsedFeed) {
111
+ const currentFeedFileHash = (0, parsedFeed_1.getParsedFeedMd5Hash)(parsedFeed);
112
+ yield feedService.update(feed.id, {
113
+ is_parsing: null,
114
+ last_parsed_file_hash: currentFeedFileHash
115
+ });
116
+ }
109
117
  }
110
118
  }
111
119
  if (channel) {
@@ -54,7 +54,7 @@ const handleRemoteItemsFeedParsing = (feedGuidsToParse) => __awaiter(void 0, voi
54
54
  if (!feed) {
55
55
  yield handleRequestDelay(piFeedData.url);
56
56
  loggerService_1.loggerService.info(`handleRemoteItemsFeedParsing: ${piFeedData.url} ${piFeedData.id}`);
57
- yield (0, parser_1.parseRSSFeedAndSaveToDatabase)(piFeedData.url, piFeedData.id);
57
+ yield (0, parser_1.parseRSSFeedAndSaveToDatabase)(piFeedData.url, piFeedData.id, { forceParse: false });
58
58
  }
59
59
  }
60
60
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "podverse-parser",
3
- "version": "5.1.6-alpha.2",
3
+ "version": "5.1.6-alpha.4",
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.9.1",
21
- "podverse-external-services": "^5.1.6-alpha.2",
22
- "podverse-helpers": "^5.1.6-alpha.0",
23
- "podverse-orm": "^5.1.6-alpha.1"
21
+ "podverse-external-services": "^5.1.6-alpha.3",
22
+ "podverse-helpers": "^5.1.6-alpha.1",
23
+ "podverse-orm": "^5.1.6-alpha.3"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@eslint/config-array": "^0.21.0",