podverse-parser 5.1.0-alpha.9 → 5.1.3-alpha.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/config/index.d.ts +1 -0
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +1 -0
- package/dist/factories/notificationsService.d.ts.map +1 -1
- package/dist/factories/notificationsService.js +1 -0
- package/dist/factories/podcastIndex.d.ts.map +1 -1
- package/dist/factories/podcastIndex.js +1 -0
- package/dist/lib/_request.d.ts +9 -0
- package/dist/lib/_request.d.ts.map +1 -0
- package/dist/lib/_request.js +19 -0
- package/dist/lib/chapters/chapters.d.ts.map +1 -1
- package/dist/lib/chapters/chapters.js +26 -13
- package/dist/lib/compat/chapters/chapters.d.ts.map +1 -1
- package/dist/lib/compat/chapters/chapters.js +4 -1
- package/dist/lib/compat/partytime/channel.d.ts +2 -2
- package/dist/lib/compat/partytime/channel.d.ts.map +1 -1
- package/dist/lib/compat/partytime/channel.js +11 -7
- package/dist/lib/compat/partytime/item.js +1 -1
- package/dist/lib/rss/feed/feed.d.ts +5 -1
- package/dist/lib/rss/feed/feed.d.ts.map +1 -1
- package/dist/lib/rss/feed/feed.js +8 -2
- package/dist/lib/rss/hash/parsedFeed.d.ts.map +1 -1
- package/dist/lib/rss/hash/parsedFeed.js +2 -2
- package/dist/lib/rss/hash/parsedItemChapter.d.ts +3 -0
- package/dist/lib/rss/hash/parsedItemChapter.d.ts.map +1 -0
- package/dist/lib/rss/hash/parsedItemChapter.js +29 -0
- package/dist/lib/rss/item/itemValue.d.ts.map +1 -1
- package/dist/lib/rss/item/itemValue.js +2 -1
- package/dist/lib/rss/liveItem/liveItem.js +5 -5
- package/dist/lib/rss/parser.d.ts +5 -1
- package/dist/lib/rss/parser.d.ts.map +1 -1
- package/dist/lib/rss/parser.js +11 -11
- package/package.json +13 -13
package/dist/config/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;CAgBlB,CAAC"}
|
package/dist/config/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notificationsService.d.ts","sourceRoot":"","sources":["../../src/factories/notificationsService.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAIlE,eAAO,MAAM,2BAA2B,GAAI,iBAAiB,MAAM,
|
|
1
|
+
{"version":3,"file":"notificationsService.d.ts","sourceRoot":"","sources":["../../src/factories/notificationsService.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAIlE,eAAO,MAAM,2BAA2B,GAAI,iBAAiB,MAAM,yBAKjE,CAAC"}
|
|
@@ -5,6 +5,7 @@ const podverse_external_services_1 = require("podverse-external-services");
|
|
|
5
5
|
const loggerService_1 = require("./loggerService");
|
|
6
6
|
const config_1 = require("../config");
|
|
7
7
|
const NotificationsServiceFactory = (googleAuthToken) => new podverse_external_services_1.NotificationsService({
|
|
8
|
+
userAgent: config_1.config.userAgent,
|
|
8
9
|
googleAuthToken,
|
|
9
10
|
firebaseProjectId: config_1.config.firebase.projectId,
|
|
10
11
|
loggerService: loggerService_1.loggerService
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"podcastIndex.d.ts","sourceRoot":"","sources":["../../src/factories/podcastIndex.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAIjE,eAAO,MAAM,mBAAmB,
|
|
1
|
+
{"version":3,"file":"podcastIndex.d.ts","sourceRoot":"","sources":["../../src/factories/podcastIndex.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAIjE,eAAO,MAAM,mBAAmB,qBAM9B,CAAC"}
|
|
@@ -5,6 +5,7 @@ const podverse_external_services_1 = require("podverse-external-services");
|
|
|
5
5
|
const loggerService_1 = require("./loggerService");
|
|
6
6
|
const config_1 = require("../config");
|
|
7
7
|
exports.podcastIndexService = new podverse_external_services_1.PodcastIndexService({
|
|
8
|
+
userAgent: config_1.config.userAgent,
|
|
8
9
|
authKey: config_1.config.podcastIndex.authKey,
|
|
9
10
|
baseUrl: config_1.config.podcastIndex.baseUrl,
|
|
10
11
|
secretKey: config_1.config.podcastIndex.secretKey,
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AxiosRequestConfig } from 'podverse-helpers';
|
|
2
|
+
export declare const _request: <T>(url: string, requestConfig?: AxiosRequestConfig, abort?: {
|
|
3
|
+
controller: AbortController;
|
|
4
|
+
timeoutMs: number;
|
|
5
|
+
}) => Promise<{
|
|
6
|
+
status: number;
|
|
7
|
+
data: T;
|
|
8
|
+
}>;
|
|
9
|
+
//# sourceMappingURL=_request.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_request.d.ts","sourceRoot":"","sources":["../../src/lib/_request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAW,MAAM,kBAAkB,CAAC;AAG/D,eAAO,MAAM,QAAQ,GAAU,CAAC,EAC9B,KAAK,MAAM,EACX,gBAAgB,kBAAkB,EAClC,QAAQ;IACN,UAAU,EAAE,eAAe,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;CACnB,KACA,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,CAAC,CAAA;CAAE,CAMrC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports._request = void 0;
|
|
13
|
+
const podverse_helpers_1 = require("podverse-helpers");
|
|
14
|
+
const config_1 = require("../config");
|
|
15
|
+
const _request = (url, requestConfig, abort) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
+
const headers = Object.assign(Object.assign({}, requestConfig === null || requestConfig === void 0 ? void 0 : requestConfig.headers), { 'User-Agent': config_1.config.userAgent });
|
|
17
|
+
return (0, podverse_helpers_1.request)(url, Object.assign(Object.assign({}, requestConfig), { headers }), abort);
|
|
18
|
+
});
|
|
19
|
+
exports._request = _request;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chapters.d.ts","sourceRoot":"","sources":["../../../src/lib/chapters/chapters.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAoE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"chapters.d.ts","sourceRoot":"","sources":["../../../src/lib/chapters/chapters.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAoE,MAAM,cAAc,CAAC;AAoCtG,eAAO,MAAM,aAAa,GAAU,MAAM,IAAI,KAAG,OAAO,CAAC,IAAI,CA6B5D,CAAC"}
|
|
@@ -13,15 +13,24 @@ exports.parseChapters = void 0;
|
|
|
13
13
|
const podverse_helpers_1 = require("podverse-helpers");
|
|
14
14
|
const podverse_orm_1 = require("podverse-orm");
|
|
15
15
|
const chapters_1 = require("@parser/lib/compat/chapters/chapters");
|
|
16
|
+
const _request_1 = require("../_request");
|
|
16
17
|
const getParsedChapters = (item_chapters_feed) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
18
|
const itemChaptersFeedLogService = new podverse_orm_1.ItemChaptersFeedLogService();
|
|
18
19
|
try {
|
|
19
|
-
const response = yield (0,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
const response = yield (0, _request_1._request)(item_chapters_feed.url);
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
|
+
const data = response.data;
|
|
23
|
+
if (data === null || data === void 0 ? void 0 : data.chapters) {
|
|
24
|
+
const chapters = data.chapters;
|
|
25
|
+
yield itemChaptersFeedLogService.update(item_chapters_feed, {
|
|
26
|
+
last_http_status: 200,
|
|
27
|
+
last_good_http_status_time: new Date()
|
|
28
|
+
});
|
|
29
|
+
return (0, chapters_1.compatParsedChapters)(chapters);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
throw new Error('No chapters found in feed');
|
|
33
|
+
}
|
|
25
34
|
}
|
|
26
35
|
catch (error) {
|
|
27
36
|
// TODO: how to handle errors?
|
|
@@ -44,15 +53,19 @@ const parseChapters = (item) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
44
53
|
}
|
|
45
54
|
const parsedChapters = yield getParsedChapters(item_chapters_feed);
|
|
46
55
|
const itemChapterService = new podverse_orm_1.ItemChapterService();
|
|
47
|
-
const existingChapters = yield itemChapterService.getAll(item_chapters_feed, { select: ['id'] });
|
|
48
|
-
const
|
|
49
|
-
const
|
|
56
|
+
const existingChapters = yield itemChapterService.getAll(item_chapters_feed, { select: ['id', 'data_hash'] });
|
|
57
|
+
const existingChaptersDataHashes = existingChapters.map(item_chapter => item_chapter.data_hash);
|
|
58
|
+
const updatedChaptersDataHashes = [];
|
|
50
59
|
for (const parsedChapter of parsedChapters) {
|
|
51
|
-
|
|
52
|
-
|
|
60
|
+
updatedChaptersDataHashes.push(parsedChapter.data_hash);
|
|
61
|
+
if (!existingChaptersDataHashes.includes(parsedChapter.data_hash)) {
|
|
62
|
+
yield itemChapterService.update(item_chapters_feed, parsedChapter);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const dataHashesToDelete = existingChaptersDataHashes.filter(hash => !updatedChaptersDataHashes.includes(hash));
|
|
66
|
+
if (dataHashesToDelete.length > 0) {
|
|
67
|
+
yield itemChapterService.deleteManyByDataHash(item_chapters_feed, dataHashesToDelete);
|
|
53
68
|
}
|
|
54
|
-
const itemChapterIdsToDelete = existingChaptersIds.filter(id => !updatedChaptersIds.includes(id));
|
|
55
|
-
yield itemChapterService.deleteMany(itemChapterIdsToDelete);
|
|
56
69
|
const itemChaptersFeedLogService = new podverse_orm_1.ItemChaptersFeedLogService();
|
|
57
70
|
yield itemChaptersFeedLogService.update(item_chapters_feed, { last_finished_parse_time: new Date() });
|
|
58
71
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chapters.d.ts","sourceRoot":"","sources":["../../../../src/lib/compat/chapters/chapters.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"chapters.d.ts","sourceRoot":"","sources":["../../../../src/lib/compat/chapters/chapters.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,MAAM,SAAS,GAAG;IACtB,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;IAClB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;IAClB,GAAG,EAAE,OAAO,CAAA;CACb,CAAA;AAED,eAAO,MAAM,oBAAoB,GAAI,UAAU,SAAS,EAAE,KAAG,cAAc,EAa1E,CAAC"}
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.compatParsedChapters = void 0;
|
|
4
|
+
const parsedItemChapter_1 = require("@parser/lib/rss/hash/parsedItemChapter");
|
|
4
5
|
const podverse_helpers_1 = require("podverse-helpers");
|
|
5
6
|
const compatParsedChapters = (chapters) => {
|
|
6
7
|
return chapters.map(chapter => {
|
|
8
|
+
const data_hash = (0, parsedItemChapter_1.getPIChapterMd5Hash)(chapter);
|
|
7
9
|
return {
|
|
8
10
|
start_time: chapter.startTime,
|
|
9
11
|
end_time: chapter.endTime || null,
|
|
10
12
|
title: chapter.title || null,
|
|
11
13
|
img: (0, podverse_helpers_1.isValidHttpUrl)(chapter.img) && chapter.img || null,
|
|
12
14
|
web_url: (0, podverse_helpers_1.isValidHttpUrl)(chapter.url) && chapter.url || null,
|
|
13
|
-
table_of_contents: chapter.toc
|
|
15
|
+
table_of_contents: chapter.toc === false ? false : true,
|
|
16
|
+
data_hash
|
|
14
17
|
};
|
|
15
18
|
});
|
|
16
19
|
};
|
|
@@ -3,7 +3,7 @@ export declare const compatChannelDto: (parsedFeed: FeedObject) => {
|
|
|
3
3
|
podcast_guid: string | null;
|
|
4
4
|
title: string | null;
|
|
5
5
|
sortable_title: string | null;
|
|
6
|
-
|
|
6
|
+
medium_id: import("podverse-helpers").MediumEnum;
|
|
7
7
|
};
|
|
8
8
|
export declare const compatChannelAboutDto: (parsedFeed: FeedObject) => {
|
|
9
9
|
author: string | null;
|
|
@@ -12,7 +12,7 @@ export declare const compatChannelAboutDto: (parsedFeed: FeedObject) => {
|
|
|
12
12
|
website_link_url: string | null;
|
|
13
13
|
itunes_type: import("podverse-orm").ChannelItunesTypeItunesTypeEnum;
|
|
14
14
|
episode_count: number;
|
|
15
|
-
last_pub_date: Date;
|
|
15
|
+
last_pub_date: Date | null;
|
|
16
16
|
};
|
|
17
17
|
export declare const compatChannelCategoryDtos: (parsedFeed: FeedObject) => {
|
|
18
18
|
category_id: import("podverse-helpers").CategoryEnum;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../../../../src/lib/compat/partytime/channel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAgB,MAAM,mBAAmB,CAAC;AAO7D,eAAO,MAAM,gBAAgB,GAAI,YAAY,UAAU;;;;;CAKrD,CAAC;AAEH,eAAO,MAAM,qBAAqB,GAAI,YAAY,UAAU;;;;;;;;
|
|
1
|
+
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../../../../src/lib/compat/partytime/channel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAgB,MAAM,mBAAmB,CAAC;AAO7D,eAAO,MAAM,gBAAgB,GAAI,YAAY,UAAU;;;;;CAKrD,CAAC;AAEH,eAAO,MAAM,qBAAqB,GAAI,YAAY,UAAU;;;;;;;;CAqB1D,CAAC;AAEH,eAAO,MAAM,yBAAyB,GAAI,YAAY,UAAU;;GAU/D,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,YAAY,UAAU;;;;;QAU1D,CAAC;AAEF,eAAO,MAAM,2BAA2B,GAAI,YAAY,UAAU;;QAOjE,CAAC;AAEF,eAAO,MAAM,wBAAwB,GAAI,YAAY,UAAU;;;GAe9D,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAAI,YAAY,UAAU;;;;;;IA8B5D,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAI,YAAY,UAAU;;;QAQ7D,CAAC;AAEF,eAAO,MAAM,wBAAwB,GAAI,YAAY,UAAU;;;;QAU9D,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAI,YAAY,UAAU;;;;;;GAkB7D,CAAC;AAEF,eAAO,MAAM,kCAAkC,GAAI,YAAY,UAAU;;;;;GAgBxE,CAAC;AAEF,eAAO,MAAM,oCAAoC,GAAI,YAAY,UAAU;;;;;GAa1E,CAAC;AAEF,eAAO,MAAM,2BAA2B,GAAI,YAAY,UAAU;;;;;GAiBjE,CAAC;AAEF,eAAO,MAAM,+BAA+B,GAAI,YAAY,UAAU;;;;;;GAiBrE,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAI,YAAY,UAAU;;;GA0B7D,CAAC;AAEF,eAAO,MAAM,wBAAwB,GAAI,YAAY,UAAU;;;;;;;GAkB9D,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,YAAY,UAAU;;;GAY1D,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAAI,YAAY,UAAU;;;;;;;;;;;;;;;GAiB5D,CAAC"}
|
|
@@ -11,12 +11,12 @@ const compatChannelDto = (parsedFeed) => {
|
|
|
11
11
|
podcast_guid: ((_a = parsedFeed.guid) === null || _a === void 0 ? void 0 : _a.slice(0, podverse_helpers_1.DATABASE_CONSTANTS.varchar_guid)) || null,
|
|
12
12
|
title: ((_b = parsedFeed.title) === null || _b === void 0 ? void 0 : _b.slice(0, podverse_helpers_1.DATABASE_CONSTANTS.varchar_normal)) || null,
|
|
13
13
|
sortable_title: ((_c = (0, podverse_helpers_1.createSortableTitle)(parsedFeed.title)) === null || _c === void 0 ? void 0 : _c.slice(0, podverse_helpers_1.DATABASE_CONSTANTS.varchar_short)) || null,
|
|
14
|
-
|
|
14
|
+
medium_id: (0, podverse_helpers_1.getMediumEnumValue)((_d = parsedFeed.medium) !== null && _d !== void 0 ? _d : podcast_partytime_1.Phase4Medium.Podcast)
|
|
15
15
|
});
|
|
16
16
|
};
|
|
17
17
|
exports.compatChannelDto = compatChannelDto;
|
|
18
18
|
const compatChannelAboutDto = (parsedFeed) => {
|
|
19
|
-
var _a, _b, _c, _d, _e
|
|
19
|
+
var _a, _b, _c, _d, _e;
|
|
20
20
|
return ({
|
|
21
21
|
author: ((_b = ((_a = (Array.isArray(parsedFeed.author)
|
|
22
22
|
? parsedFeed.author
|
|
@@ -27,13 +27,17 @@ const compatChannelAboutDto = (parsedFeed) => {
|
|
|
27
27
|
website_link_url: (0, podverse_helpers_1.isValidHttpUrl)(parsedFeed.link) && ((_d = parsedFeed.link) === null || _d === void 0 ? void 0 : _d.slice(0, podverse_helpers_1.DATABASE_CONSTANTS.varchar_url)) || null,
|
|
28
28
|
itunes_type: (0, podverse_orm_1.getChannelItunesTypeItunesTypeEnumValue)(parsedFeed.itunesType || 'episodic'),
|
|
29
29
|
episode_count: ((_e = parsedFeed.items) === null || _e === void 0 ? void 0 : _e.length) || 0,
|
|
30
|
-
last_pub_date: ((
|
|
31
|
-
|
|
30
|
+
last_pub_date: (() => {
|
|
31
|
+
var _a;
|
|
32
|
+
const itemsWithPubDate = ((_a = parsedFeed.items) === null || _a === void 0 ? void 0 : _a.filter(item => !!item.pubDate)) || [];
|
|
33
|
+
if (itemsWithPubDate.length === 0)
|
|
34
|
+
return null;
|
|
35
|
+
const latestDate = itemsWithPubDate.reduce((latest, item) => {
|
|
32
36
|
const itemDate = new Date(item.pubDate);
|
|
33
37
|
return itemDate > latest ? itemDate : latest;
|
|
34
|
-
}
|
|
35
|
-
return
|
|
36
|
-
}
|
|
38
|
+
}, new Date(itemsWithPubDate[0].pubDate));
|
|
39
|
+
return isNaN(latestDate.getTime()) ? null : latestDate;
|
|
40
|
+
})()
|
|
37
41
|
});
|
|
38
42
|
};
|
|
39
43
|
exports.compatChannelAboutDto = compatChannelAboutDto;
|
|
@@ -39,7 +39,7 @@ const compatItemChaptersFeedDto = (parsedItem) => {
|
|
|
39
39
|
exports.compatItemChaptersFeedDto = compatItemChaptersFeedDto;
|
|
40
40
|
const compatItemChatDto = (parsedItem) => {
|
|
41
41
|
var _a, _b;
|
|
42
|
-
if (!parsedItem.chat) {
|
|
42
|
+
if (!parsedItem.chat || !parsedItem.chat.server || !parsedItem.chat.protocol) {
|
|
43
43
|
return null;
|
|
44
44
|
}
|
|
45
45
|
return {
|
|
@@ -2,5 +2,9 @@ import { FeedObject } from "podcast-partytime";
|
|
|
2
2
|
import { Feed } from "podverse-orm";
|
|
3
3
|
export declare const handleGetRSSFeed: (url: string, podcast_index_id: number) => Promise<Feed>;
|
|
4
4
|
export declare const handleRequestRSSFeed: (feed: Feed) => Promise<FeedObject>;
|
|
5
|
-
|
|
5
|
+
type HandleParsedFeedOptions = {
|
|
6
|
+
forceParse?: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare const handleParsedFeed: (parsedFeed: FeedObject, feed: Feed, options?: HandleParsedFeedOptions) => Promise<Feed>;
|
|
9
|
+
export {};
|
|
6
10
|
//# 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,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;AAOjE,eAAO,MAAM,gBAAgB,GAAU,KAAK,MAAM,EAAE,kBAAkB,MAAM,KAAG,OAAO,CAAC,IAAI,CA8B1F,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAU,MAAM,IAAI,KAAG,OAAO,CAAC,UAAU,CAsCzE,CAAC;AAEF,KAAK,uBAAuB,GAAG;IAC7B,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAA;AAED,eAAO,MAAM,gBAAgB,GAC3B,YAAY,UAAU,EACtB,MAAM,IAAI,EACV,UAAS,uBAA4B,KACpC,OAAO,CAAC,IAAI,CAad,CAAC"}
|
|
@@ -16,6 +16,7 @@ const parsedFeed_1 = require("../hash/parsedFeed");
|
|
|
16
16
|
const parser_1 = require("../parser");
|
|
17
17
|
const errors_1 = require("../errors");
|
|
18
18
|
const timerManager_1 = require("@parser/factories/timerManager");
|
|
19
|
+
const _request_1 = require("../../_request");
|
|
19
20
|
const handleGetRSSFeed = (url, podcast_index_id) => __awaiter(void 0, void 0, void 0, function* () {
|
|
20
21
|
timerManager_1.timerManager.start('handleGetRSSFeed');
|
|
21
22
|
const feedService = new podverse_orm_1.FeedService();
|
|
@@ -28,6 +29,10 @@ const handleGetRSSFeed = (url, podcast_index_id) => __awaiter(void 0, void 0, vo
|
|
|
28
29
|
}
|
|
29
30
|
}
|
|
30
31
|
if (!feed) {
|
|
32
|
+
const response = yield (0, _request_1._request)(url, { method: 'HEAD' });
|
|
33
|
+
if (!response || response.status < 200 || response.status >= 300) {
|
|
34
|
+
throw new Error(`HEAD request failed for ${url} with status ${response === null || response === void 0 ? void 0 : response.status}`);
|
|
35
|
+
}
|
|
31
36
|
feed = yield feedService.getOrCreate({ url, podcast_index_id });
|
|
32
37
|
}
|
|
33
38
|
timerManager_1.timerManager.end('handleGetRSSFeed');
|
|
@@ -74,10 +79,11 @@ const handleRequestRSSFeed = (feed) => __awaiter(void 0, void 0, void 0, functio
|
|
|
74
79
|
return parsedFeed;
|
|
75
80
|
});
|
|
76
81
|
exports.handleRequestRSSFeed = handleRequestRSSFeed;
|
|
77
|
-
const handleParsedFeed = (
|
|
82
|
+
const handleParsedFeed = (parsedFeed_2, feed_1, ...args_1) => __awaiter(void 0, [parsedFeed_2, feed_1, ...args_1], void 0, function* (parsedFeed, feed, options = {}) {
|
|
78
83
|
const currentFeedFileHash = (0, parsedFeed_1.getParsedFeedMd5Hash)(parsedFeed);
|
|
79
84
|
checkIfFeedIsParsing(feed);
|
|
80
|
-
if (
|
|
85
|
+
if (!options.forceParse &&
|
|
86
|
+
feed.last_parsed_file_hash === currentFeedFileHash) {
|
|
81
87
|
throw new errors_1.FeedNoChangesSinceLastParsedError(feed.id);
|
|
82
88
|
}
|
|
83
89
|
const feedService = new podverse_orm_1.FeedService();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parsedFeed.d.ts","sourceRoot":"","sources":["../../../../src/lib/rss/hash/parsedFeed.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"parsedFeed.d.ts","sourceRoot":"","sources":["../../../../src/lib/rss/hash/parsedFeed.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,eAAO,MAAM,oBAAoB,GAAI,YAAY,UAAU,KAAG,MAY7D,CAAC"}
|
|
@@ -12,10 +12,10 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports.getParsedFeedMd5Hash = void 0;
|
|
15
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
15
16
|
const podverse_helpers_1 = require("podverse-helpers");
|
|
16
17
|
const getParsedFeedMd5Hash = (parsedFeed) => {
|
|
17
|
-
|
|
18
|
-
const { lastUpdate, lastBuildDate, pubDate } = parsedFeed, parsedFeedPruned = __rest(parsedFeed, ["lastUpdate", "lastBuildDate", "pubDate"]);
|
|
18
|
+
const { lastUpdate, lastBuildDate, pubDate, newestItemPubDate, oldestItemPubDate, lastPubDate } = parsedFeed, parsedFeedPruned = __rest(parsedFeed, ["lastUpdate", "lastBuildDate", "pubDate", "newestItemPubDate", "oldestItemPubDate", "lastPubDate"]);
|
|
19
19
|
const currentFeedFileHash = (0, podverse_helpers_1.getMd5Hash)(parsedFeedPruned);
|
|
20
20
|
return currentFeedFileHash;
|
|
21
21
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parsedItemChapter.d.ts","sourceRoot":"","sources":["../../../../src/lib/rss/hash/parsedItemChapter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AAWjE,eAAO,MAAM,mBAAmB,GAAI,WAAW,SAAS,KAAG,MAuB1D,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPIChapterMd5Hash = void 0;
|
|
4
|
+
const podverse_helpers_1 = require("podverse-helpers");
|
|
5
|
+
function stripUrlParams(url) {
|
|
6
|
+
if (!url)
|
|
7
|
+
return url;
|
|
8
|
+
try {
|
|
9
|
+
return new URL(url).origin + new URL(url).pathname;
|
|
10
|
+
}
|
|
11
|
+
catch (_a) {
|
|
12
|
+
return url;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
const getPIChapterMd5Hash = (piChapter) => {
|
|
16
|
+
const { startTime, endTime, title, img, url, toc } = piChapter;
|
|
17
|
+
const imgNoParams = stripUrlParams(img);
|
|
18
|
+
const urlNoParams = stripUrlParams(url);
|
|
19
|
+
const currentItemChapterDataHash = (0, podverse_helpers_1.getMd5Hash)({
|
|
20
|
+
startTime,
|
|
21
|
+
endTime,
|
|
22
|
+
title,
|
|
23
|
+
img: imgNoParams,
|
|
24
|
+
url: urlNoParams,
|
|
25
|
+
toc
|
|
26
|
+
});
|
|
27
|
+
return currentItemChapterDataHash;
|
|
28
|
+
};
|
|
29
|
+
exports.getPIChapterMd5Hash = getPIChapterMd5Hash;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"itemValue.d.ts","sourceRoot":"","sources":["../../../../src/lib/rss/item/itemValue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,IAAI,EAG1B,OAAO,EACR,MAAM,cAAc,CAAC;AAGtB,eAAO,MAAM,qBAAqB,GAChC,YAAY,OAAO,EACnB,MAAM,IAAI,EACV,SAAS,OAAO,EAChB,6BAA6B,aAAa,
|
|
1
|
+
{"version":3,"file":"itemValue.d.ts","sourceRoot":"","sources":["../../../../src/lib/rss/item/itemValue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,IAAI,EAG1B,OAAO,EACR,MAAM,cAAc,CAAC;AAGtB,eAAO,MAAM,qBAAqB,GAChC,YAAY,OAAO,EACnB,MAAM,IAAI,EACV,SAAS,OAAO,EAChB,6BAA6B,aAAa,kBA2D3C,CAAC"}
|
|
@@ -36,7 +36,8 @@ const handleParsedItemValue = (parsedItem, item, channel, transactionalEntityMan
|
|
|
36
36
|
if (!channel.has_value_time_splits) {
|
|
37
37
|
const channelService = new podverse_orm_1.ChannelService();
|
|
38
38
|
yield channelService.update(channel.id, {
|
|
39
|
-
has_value_time_splits: true
|
|
39
|
+
has_value_time_splits: true,
|
|
40
|
+
medium_id: channel.medium_id // needed to avoid nulling out medium_id
|
|
40
41
|
});
|
|
41
42
|
}
|
|
42
43
|
for (const itemValueTimeSplitDto of itemValueTimeSplitDtos) {
|
|
@@ -55,21 +55,21 @@ const handleParsedLiveItems = (parsedLiveItems, channel, channelSeasonIndex) =>
|
|
|
55
55
|
const liveItemService = new podverse_orm_1.LiveItemService();
|
|
56
56
|
const existingLiveItems = yield liveItemService.getManyByChannel(channel, { relations: ['item', 'live_item_status'] });
|
|
57
57
|
const existingLiveItemMap = new Map(existingLiveItems.map(live_item => [live_item.item.guid, live_item]));
|
|
58
|
-
const
|
|
59
|
-
const
|
|
58
|
+
const existingLiveItemItemIds = existingLiveItems.map(live_item => live_item.item.id);
|
|
59
|
+
const updatedLiveItemItemIds = [];
|
|
60
60
|
const newItemGuids = [];
|
|
61
61
|
const liveItemObjDtos = (0, liveItem_1.compatLiveItemsDtos)(parsedLiveItems);
|
|
62
62
|
const timerAccumulator = (0, item_1.createItemTimerAccumulator)();
|
|
63
63
|
const liveItemObjDtosBatchs = (0, podverse_helpers_1.chunkArray)(liveItemObjDtos, 50);
|
|
64
64
|
for (const liveItemObjDtosBatch of liveItemObjDtosBatchs) {
|
|
65
65
|
yield podverse_orm_1.AppDataSourceReadWrite.manager.transaction((transactionalEntityManager) => __awaiter(void 0, void 0, void 0, function* () {
|
|
66
|
-
yield processLiveItemBatch(liveItemObjDtosBatch, channel, channelSeasonIndex, existingLiveItemMap,
|
|
66
|
+
yield processLiveItemBatch(liveItemObjDtosBatch, channel, channelSeasonIndex, existingLiveItemMap, updatedLiveItemItemIds, newItemGuids, transactionalEntityManager, timerAccumulator, liveItemService);
|
|
67
67
|
}));
|
|
68
68
|
}
|
|
69
69
|
logTimerAccumulator(timerAccumulator);
|
|
70
|
-
const itemIdsToDelete =
|
|
70
|
+
const itemIdsToDelete = existingLiveItemItemIds.filter(id => !updatedLiveItemItemIds.includes(id));
|
|
71
71
|
const itemsToDelete = existingLiveItems
|
|
72
|
-
.filter(liveItem => itemIdsToDelete.includes(liveItem.id))
|
|
72
|
+
.filter(liveItem => itemIdsToDelete.includes(liveItem.item.id))
|
|
73
73
|
.map(liveItem => liveItem.item);
|
|
74
74
|
yield itemService.updateManyFlagStatus(itemsToDelete, itemFlagStatus_1.ItemFlagStatusStatusEnum.PendingArchive);
|
|
75
75
|
return { newItemGuids };
|
package/dist/lib/rss/parser.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
export declare const getAndParseRSSFeed: (url: string) => Promise<import("podcast-partytime").FeedObject>;
|
|
2
|
-
|
|
2
|
+
type ParseRSSFeedAndSaveToDatabase = {
|
|
3
|
+
forceParse?: boolean;
|
|
4
|
+
};
|
|
5
|
+
export declare const parseRSSFeedAndSaveToDatabase: (url: string, podcast_index_id: number, options?: ParseRSSFeedAndSaveToDatabase) => Promise<void>;
|
|
6
|
+
export {};
|
|
3
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,
|
|
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"}
|
package/dist/lib/rss/parser.js
CHANGED
|
@@ -11,7 +11,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.parseRSSFeedAndSaveToDatabase = exports.getAndParseRSSFeed = void 0;
|
|
13
13
|
const podcast_partytime_1 = require("podcast-partytime");
|
|
14
|
-
const podverse_helpers_1 = require("podverse-helpers");
|
|
15
14
|
const podverse_orm_1 = require("podverse-orm");
|
|
16
15
|
const notifications_1 = require("@parser/lib/notifications");
|
|
17
16
|
const channel_1 = require("@parser/lib/rss/channel/channel");
|
|
@@ -25,38 +24,38 @@ const timerManager_1 = require("@parser/factories/timerManager");
|
|
|
25
24
|
const loggerService_1 = require("@parser/factories/loggerService");
|
|
26
25
|
const firebaseAccessTokenService_1 = require("@parser/factories/firebaseAccessTokenService");
|
|
27
26
|
const notificationsService_1 = require("@parser/factories/notificationsService");
|
|
27
|
+
const _request_1 = require("../_request");
|
|
28
28
|
/*
|
|
29
29
|
NOTE: All RSS feeds that have a podcast_index_id will be saved to the database.
|
|
30
30
|
RSS feeds without podcast_index_id (Add By RSS feeds) will NOT be saved to the database.
|
|
31
31
|
*/
|
|
32
32
|
const getAndParseRSSFeed = (url) => __awaiter(void 0, void 0, void 0, function* () {
|
|
33
|
-
const
|
|
34
|
-
const
|
|
33
|
+
const response = yield (0, _request_1._request)(url);
|
|
34
|
+
const data = response.data;
|
|
35
|
+
const parsedFeed = (0, podcast_partytime_1.parseFeed)(data, { allowMissingGuid: true });
|
|
35
36
|
if (!parsedFeed) {
|
|
36
37
|
throw new Error(`getAndParseRSSFeed: parsedFeed not found for ${url}`);
|
|
37
38
|
}
|
|
38
39
|
return parsedFeed;
|
|
39
40
|
});
|
|
40
41
|
exports.getAndParseRSSFeed = getAndParseRSSFeed;
|
|
41
|
-
|
|
42
|
-
// const parsedFeed = await getAndParseRSSFeed(url);
|
|
43
|
-
// const compatData = convertParsedRSSFeedToCompat(parsedFeed);
|
|
44
|
-
// return compatData;
|
|
45
|
-
// };
|
|
46
|
-
const parseRSSFeedAndSaveToDatabase = (url, podcast_index_id) => __awaiter(void 0, void 0, void 0, function* () {
|
|
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 = {}) {
|
|
47
43
|
const feedService = new podverse_orm_1.FeedService();
|
|
48
44
|
let feed = null;
|
|
49
45
|
let channel = null;
|
|
50
46
|
const timerFullRunLabel = `parseRSSFeedAndSaveToDatabase ${url} ${podcast_index_id}`;
|
|
51
47
|
timerManager_1.timerManager.start(timerFullRunLabel);
|
|
52
48
|
try {
|
|
53
|
-
|
|
49
|
+
if (!url || !podcast_index_id) {
|
|
50
|
+
throw new Error(`parseRSSFeedAndSaveToDatabase: url or podcast_index_id is missing for ${url} ${podcast_index_id}`);
|
|
51
|
+
}
|
|
52
|
+
loggerService_1.loggerService.info(`parseRSSFeedAndSaveToDatabase url: ${url} podcast_index_id: ${podcast_index_id}`);
|
|
54
53
|
feed = yield (0, feed_1.handleGetRSSFeed)(url, podcast_index_id);
|
|
55
54
|
if (!(0, podverse_orm_1.checkIfFeedFlagStatusShouldParse)(feed.feed_flag_status.id)) {
|
|
56
55
|
throw new Error(`parseRSSFeedAndSaveToDatabase: feed_flag_status.status is not Active or AlwaysAllow for ${feed.id} ${feed.channel.podcast_index_id} ${feed.url}`);
|
|
57
56
|
}
|
|
58
57
|
const parsedFeed = yield (0, feed_1.handleRequestRSSFeed)(feed);
|
|
59
|
-
feed = yield (0, feed_1.handleParsedFeed)(parsedFeed, feed);
|
|
58
|
+
feed = yield (0, feed_1.handleParsedFeed)(parsedFeed, feed, options);
|
|
60
59
|
yield feedService.update(feed.id, { is_parsing: new Date() });
|
|
61
60
|
if ((0, podverse_orm_1.checkIfSpamFeed)(parsedFeed)) {
|
|
62
61
|
yield feedService.updateFlagStatus(feed, podverse_orm_1.FeedFlagStatusStatusEnum.Spam);
|
|
@@ -103,6 +102,7 @@ const parseRSSFeedAndSaveToDatabase = (url, podcast_index_id) => __awaiter(void
|
|
|
103
102
|
}
|
|
104
103
|
}
|
|
105
104
|
finally {
|
|
105
|
+
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
106
|
timerManager_1.timerManager.endAll();
|
|
107
107
|
if (feed) {
|
|
108
108
|
yield feedService.update(feed.id, { is_parsing: null });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "podverse-parser",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.3-alpha.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -17,20 +17,20 @@
|
|
|
17
17
|
"license": "AGPLv3",
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"module-alias": "^2.2.3",
|
|
20
|
-
"podcast-partytime": "^4.
|
|
21
|
-
"podverse-external-services": "^5.1.
|
|
22
|
-
"podverse-helpers": "^5.1.
|
|
23
|
-
"podverse-orm": "^5.1.
|
|
20
|
+
"podcast-partytime": "^4.9.1",
|
|
21
|
+
"podverse-external-services": "^5.1.3-alpha.0",
|
|
22
|
+
"podverse-helpers": "^5.1.3-alpha.0",
|
|
23
|
+
"podverse-orm": "^5.1.3-alpha.0"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@eslint/config-array": "^0.
|
|
27
|
-
"@eslint/eslintrc": "^3.1
|
|
28
|
-
"@eslint/js": "^9.
|
|
29
|
-
"@types/node": "^
|
|
30
|
-
"eslint": "^9.
|
|
31
|
-
"nodemon": "^3.1.
|
|
26
|
+
"@eslint/config-array": "^0.21.0",
|
|
27
|
+
"@eslint/eslintrc": "^3.3.1",
|
|
28
|
+
"@eslint/js": "^9.35.0",
|
|
29
|
+
"@types/node": "^24.4.0",
|
|
30
|
+
"eslint": "^9.35.0",
|
|
31
|
+
"nodemon": "^3.1.10",
|
|
32
32
|
"ts-node": "^10.9.2",
|
|
33
|
-
"typescript": "^5.
|
|
34
|
-
"typescript-eslint": "^8.0
|
|
33
|
+
"typescript": "^5.9.2",
|
|
34
|
+
"typescript-eslint": "^8.44.0"
|
|
35
35
|
}
|
|
36
36
|
}
|