podverse-parser 5.1.12-alpha.0 → 5.1.12-alpha.1
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 +3 -0
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +3 -0
- package/dist/lib/rss/item/itemValue.d.ts.map +1 -1
- package/dist/lib/rss/item/itemValue.js +4 -0
- package/dist/lib/rss/parser.d.ts +7 -1
- package/dist/lib/rss/parser.d.ts.map +1 -1
- package/dist/lib/rss/parser.js +25 -6
- package/dist/lib/rss/remoteItemParser.d.ts +8 -1
- package/dist/lib/rss/remoteItemParser.d.ts.map +1 -1
- package/dist/lib/rss/remoteItemParser.js +33 -31
- package/package.json +4 -4
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;;;;;;;;;;;;;;;;;;;CAmBlB,CAAC"}
|
package/dist/config/index.js
CHANGED
|
@@ -16,5 +16,8 @@ exports.config = {
|
|
|
16
16
|
authKey: process.env.PODCAST_INDEX_AUTH_KEY || '',
|
|
17
17
|
baseUrl: process.env.PODCAST_INDEX_BASE_URL || '',
|
|
18
18
|
secretKey: process.env.PODCAST_INDEX_SECRET_KEY || ''
|
|
19
|
+
},
|
|
20
|
+
parser: {
|
|
21
|
+
addRemoteItemsToMQ: process.env.PARSER_ADD_REMOTE_ITEMS_TO_MQ === 'true',
|
|
19
22
|
}
|
|
20
23
|
};
|
|
@@ -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,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"itemValue.d.ts","sourceRoot":"","sources":["../../../../src/lib/rss/item/itemValue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7C,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,kBA8D3C,CAAC"}
|
|
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.handleParsedItemValue = void 0;
|
|
13
|
+
const podverse_helpers_1 = require("podverse-helpers");
|
|
13
14
|
const podverse_orm_1 = require("podverse-orm");
|
|
14
15
|
const item_1 = require("@parser/lib/compat/partytime/item");
|
|
15
16
|
const handleParsedItemValue = (parsedItem, item, channel, transactionalEntityManager) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -53,6 +54,9 @@ const handleParsedItemValue = (parsedItem, item, channel, transactionalEntityMan
|
|
|
53
54
|
}
|
|
54
55
|
const itemValueTimeSplitRemoteItemDto = itemValueTimeSplitDto.item_value_time_splits_remote_item;
|
|
55
56
|
if (itemValueTimeSplitRemoteItemDto) {
|
|
57
|
+
if (!(0, podverse_helpers_1.hasValidFeedUuid)(itemValueTimeSplitRemoteItemDto)) {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
56
60
|
yield itemValueTimeSplitRemoteItemService.update(item_value_time_split, itemValueTimeSplitRemoteItemDto);
|
|
57
61
|
}
|
|
58
62
|
else {
|
package/dist/lib/rss/parser.d.ts
CHANGED
|
@@ -10,5 +10,11 @@ export type ParseRSSFeedAndSaveToDatabaseOptions = {
|
|
|
10
10
|
forceParse: boolean;
|
|
11
11
|
onDemandParserEvent: ParseRSSOnDemandParserEvent;
|
|
12
12
|
};
|
|
13
|
-
export declare const parseRSSFeedAndSaveToDatabase: (url: string, podcast_index_id: number, options: ParseRSSFeedAndSaveToDatabaseOptions) => Promise<
|
|
13
|
+
export declare const parseRSSFeedAndSaveToDatabase: (url: string, podcast_index_id: number, options: ParseRSSFeedAndSaveToDatabaseOptions) => Promise<{
|
|
14
|
+
remoteItemsToParse: {
|
|
15
|
+
url: string;
|
|
16
|
+
podcast_index_id: number;
|
|
17
|
+
options: ParseRSSFeedAndSaveToDatabaseOptions;
|
|
18
|
+
}[];
|
|
19
|
+
}>;
|
|
14
20
|
//# sourceMappingURL=parser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../../src/lib/rss/parser.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../../src/lib/rss/parser.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EAKxB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAa,MAAM,oBAAoB,CAAC;AAiC3D,eAAO,MAAM,kBAAkB,GAAU,KAAK,MAAM,wBAUnD,CAAC;AAQF,MAAM,MAAM,2BAA2B,GAAG;IACxC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,0BAA0B,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1C,IAAI,EAAE,uBAAuB,GAAG,IAAI,CAAC;CACtC,CAAA;AAED,MAAM,MAAM,oCAAoC,GAAG;IACjD,UAAU,EAAE,OAAO,CAAC;IACpB,mBAAmB,EAAE,2BAA2B,CAAC;CAClD,CAAA;AAgBD,eAAO,MAAM,6BAA6B,GACxC,KAAK,MAAM,EACX,kBAAkB,MAAM,EACxB,SAAS,oCAAoC;;;;;;EA4I9C,CAAC"}
|
package/dist/lib/rss/parser.js
CHANGED
|
@@ -27,6 +27,7 @@ const loggerService_1 = require("@parser/factories/loggerService");
|
|
|
27
27
|
// import { NotificationsServiceFactory } from '@parser/factories/notificationsService';
|
|
28
28
|
const _request_1 = require("../_request");
|
|
29
29
|
const parsedFeed_1 = require("./hash/parsedFeed");
|
|
30
|
+
const config_1 = require("@parser/config");
|
|
30
31
|
/*
|
|
31
32
|
NOTE: All RSS feeds that have a podcast_index_id will be saved to the database.
|
|
32
33
|
RSS feeds without podcast_index_id (Add By RSS feeds) will NOT be saved to the database.
|
|
@@ -41,6 +42,20 @@ const getAndParseRSSFeed = (url) => __awaiter(void 0, void 0, void 0, function*
|
|
|
41
42
|
return parsedFeed;
|
|
42
43
|
});
|
|
43
44
|
exports.getAndParseRSSFeed = getAndParseRSSFeed;
|
|
45
|
+
// Handle request delay for specific domains to avoid rate limiting
|
|
46
|
+
function handleRateLimitRequestDelay(url) {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
const delayConfig = [
|
|
49
|
+
{ regex: /^https?:\/\/(www\.)?wavlake\.com/, delay: 5000 },
|
|
50
|
+
];
|
|
51
|
+
for (const { regex, delay } of delayConfig) {
|
|
52
|
+
if (regex.test(url)) {
|
|
53
|
+
yield (0, podverse_helpers_1.sleep)(delay);
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
44
59
|
const parseRSSFeedAndSaveToDatabase = (url, podcast_index_id, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
45
60
|
const { onDemandParserEvent } = options;
|
|
46
61
|
const onDemandParserEventService = new podverse_orm_1.OnDemandParserEventService();
|
|
@@ -71,6 +86,7 @@ const parseRSSFeedAndSaveToDatabase = (url, podcast_index_id, options) => __awai
|
|
|
71
86
|
if (!url || !podcast_index_id) {
|
|
72
87
|
throw new Error(`parseRSSFeedAndSaveToDatabase: url or podcast_index_id is missing for ${url} ${podcast_index_id}`);
|
|
73
88
|
}
|
|
89
|
+
yield handleRateLimitRequestDelay(url);
|
|
74
90
|
loggerService_1.loggerService.info(`parseRSSFeedAndSaveToDatabase url: ${url} podcast_index_id: ${podcast_index_id}`);
|
|
75
91
|
feed = yield (0, feed_1.handleGetRSSFeed)(url, podcast_index_id);
|
|
76
92
|
if (!(0, podverse_orm_1.checkIfFeedFlagStatusShouldParse)(feed.feed_flag_status.id)) {
|
|
@@ -151,12 +167,15 @@ const parseRSSFeedAndSaveToDatabase = (url, podcast_index_id, options) => __awai
|
|
|
151
167
|
}
|
|
152
168
|
}
|
|
153
169
|
}
|
|
154
|
-
if (
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
170
|
+
if (config_1.config.parser.addRemoteItemsToMQ) {
|
|
171
|
+
if (channel) {
|
|
172
|
+
const remoteItems = yield (0, remoteItemParser_1.handleAllRemoteItemsFeedParsing)(channel, {
|
|
173
|
+
accountId: (onDemandParserEvent === null || onDemandParserEvent === void 0 ? void 0 : onDemandParserEvent.accountId) || null,
|
|
174
|
+
remoteParentPodcastIndexId: podcast_index_id,
|
|
175
|
+
});
|
|
176
|
+
return { remoteItemsToParse: remoteItems };
|
|
177
|
+
}
|
|
159
178
|
}
|
|
160
|
-
return;
|
|
179
|
+
return { remoteItemsToParse: [] };
|
|
161
180
|
});
|
|
162
181
|
exports.parseRSSFeedAndSaveToDatabase = parseRSSFeedAndSaveToDatabase;
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import { Channel } from 'podverse-orm';
|
|
2
|
+
import type { ParseRSSFeedAndSaveToDatabaseOptions } from '@parser/lib/rss/parser';
|
|
2
3
|
export type OnDemandParserRemoteItemParams = {
|
|
3
4
|
accountId: number | null;
|
|
4
5
|
remoteParentPodcastIndexId: number;
|
|
5
6
|
};
|
|
6
|
-
|
|
7
|
+
type RemoteItemsQueueMessage = {
|
|
8
|
+
url: string;
|
|
9
|
+
podcast_index_id: number;
|
|
10
|
+
options: ParseRSSFeedAndSaveToDatabaseOptions;
|
|
11
|
+
};
|
|
12
|
+
export declare const handleAllRemoteItemsFeedParsing: (channel: Channel, params: OnDemandParserRemoteItemParams) => Promise<RemoteItemsQueueMessage[]>;
|
|
13
|
+
export {};
|
|
7
14
|
//# sourceMappingURL=remoteItemParser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remoteItemParser.d.ts","sourceRoot":"","sources":["../../../src/lib/rss/remoteItemParser.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,OAAO,EAUR,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"remoteItemParser.d.ts","sourceRoot":"","sources":["../../../src/lib/rss/remoteItemParser.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,OAAO,EAUR,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAE,oCAAoC,EAAE,MAAM,wBAAwB,CAAC;AAQnF,MAAM,MAAM,8BAA8B,GAAG;IAC3C,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,0BAA0B,EAAE,MAAM,CAAC;CACpC,CAAA;AAED,KAAK,uBAAuB,GAAG;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,gBAAgB,EAAE,MAAM,CAAC;IACzB,OAAO,EAAE,oCAAoC,CAAC;CAC/C,CAAA;AA4DD,eAAO,MAAM,+BAA+B,GAAU,SAAS,OAAO,EAAE,QAAQ,8BAA8B,KAAG,OAAO,CAAC,uBAAuB,EAAE,CAWjJ,CAAC"}
|
|
@@ -13,21 +13,7 @@ exports.handleAllRemoteItemsFeedParsing = void 0;
|
|
|
13
13
|
const podverse_helpers_1 = require("podverse-helpers");
|
|
14
14
|
const podverse_orm_1 = require("podverse-orm");
|
|
15
15
|
const podcastIndex_1 = require("@parser/factories/podcastIndex");
|
|
16
|
-
const parser_1 = require("@parser/lib/rss/parser");
|
|
17
16
|
const loggerService_1 = require("@parser/factories/loggerService");
|
|
18
|
-
function handleRequestDelay(url) {
|
|
19
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
const delayConfig = [
|
|
21
|
-
{ regex: /^https?:\/\/(www\.)?wavlake\.com/, delay: 5000 },
|
|
22
|
-
];
|
|
23
|
-
for (const { regex, delay } of delayConfig) {
|
|
24
|
-
if (regex.test(url)) {
|
|
25
|
-
yield (0, podverse_helpers_1.sleep)(delay);
|
|
26
|
-
break;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
17
|
const handleRemoteItemsFeedParsing = (feedGuidsToParse, params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
32
18
|
var _a, _b;
|
|
33
19
|
const { accountId, remoteParentPodcastIndexId } = params;
|
|
@@ -53,33 +39,41 @@ const handleRemoteItemsFeedParsing = (feedGuidsToParse, params) => __awaiter(voi
|
|
|
53
39
|
}
|
|
54
40
|
}
|
|
55
41
|
}
|
|
42
|
+
const queueMessages = [];
|
|
56
43
|
for (const piFeedData of piFeedDatas) {
|
|
57
44
|
const feedService = new podverse_orm_1.FeedService();
|
|
58
|
-
|
|
45
|
+
const feed = yield feedService.getByUrlAndPodcastIndexId({
|
|
59
46
|
url: piFeedData.url,
|
|
60
47
|
podcast_index_id: piFeedData.id
|
|
61
48
|
});
|
|
62
49
|
if (!feed) {
|
|
63
|
-
yield handleRequestDelay(piFeedData.url);
|
|
64
50
|
loggerService_1.loggerService.info(`handleRemoteItemsFeedParsing: ${piFeedData.url} ${piFeedData.id}`);
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
51
|
+
queueMessages.push({
|
|
52
|
+
url: piFeedData.url,
|
|
53
|
+
podcast_index_id: piFeedData.id,
|
|
54
|
+
options: {
|
|
55
|
+
forceParse: false,
|
|
56
|
+
onDemandParserEvent: {
|
|
57
|
+
accountId,
|
|
58
|
+
remoteParentPodcastIndexId,
|
|
59
|
+
type: podverse_helpers_1.OnDemandParserEventType.REMOTE_ITEM,
|
|
60
|
+
}
|
|
61
|
+
}
|
|
72
62
|
});
|
|
73
63
|
}
|
|
74
64
|
}
|
|
65
|
+
return queueMessages;
|
|
75
66
|
});
|
|
76
67
|
const handleAllRemoteItemsFeedParsing = (channel, params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
77
68
|
const channelService = new podverse_orm_1.ChannelService();
|
|
78
69
|
const latestChannel = yield channelService.get(channel.id);
|
|
79
|
-
|
|
80
|
-
yield
|
|
81
|
-
yield
|
|
82
|
-
yield
|
|
70
|
+
const results = [];
|
|
71
|
+
const podrollResults = yield handleRemoteItemsPodrollParsing(latestChannel, params);
|
|
72
|
+
const publisherResults = yield handleRemoteItemsPublisherParsing(latestChannel, params);
|
|
73
|
+
const channelResults = yield handleRemoteItemsChannelParsing(latestChannel, params);
|
|
74
|
+
const timeSplitResults = yield handleRemoteItemsItemValueTimeSplitParsing(latestChannel, params);
|
|
75
|
+
results.push(...podrollResults, ...publisherResults, ...channelResults, ...timeSplitResults);
|
|
76
|
+
return results;
|
|
83
77
|
});
|
|
84
78
|
exports.handleAllRemoteItemsFeedParsing = handleAllRemoteItemsFeedParsing;
|
|
85
79
|
const handleRemoteItemsPodrollParsing = (channel, params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -89,8 +83,9 @@ const handleRemoteItemsPodrollParsing = (channel, params) => __awaiter(void 0, v
|
|
|
89
83
|
const channelPodrollRemoteItemService = new podverse_orm_1.ChannelPodrollRemoteItemService();
|
|
90
84
|
const channelPodrollRemoteItems = yield channelPodrollRemoteItemService.getAll(channelPodroll);
|
|
91
85
|
const feedGuidsToParse = channelPodrollRemoteItems.map(remoteItem => remoteItem.feed_guid);
|
|
92
|
-
yield handleRemoteItemsFeedParsing(feedGuidsToParse, params);
|
|
86
|
+
return yield handleRemoteItemsFeedParsing(feedGuidsToParse, params);
|
|
93
87
|
}
|
|
88
|
+
return [];
|
|
94
89
|
});
|
|
95
90
|
const handleRemoteItemsPublisherParsing = (channel, params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
96
91
|
const channelPublisherService = new podverse_orm_1.ChannelPublisherService();
|
|
@@ -99,14 +94,15 @@ const handleRemoteItemsPublisherParsing = (channel, params) => __awaiter(void 0,
|
|
|
99
94
|
const channelPublisherRemoteItemService = new podverse_orm_1.ChannelPublisherRemoteItemService();
|
|
100
95
|
const channelPublisherRemoteItems = yield channelPublisherRemoteItemService.getAll(channelPublisher);
|
|
101
96
|
const feedGuidsToParse = channelPublisherRemoteItems.map(remoteItem => remoteItem.feed_guid);
|
|
102
|
-
yield handleRemoteItemsFeedParsing(feedGuidsToParse, params);
|
|
97
|
+
return yield handleRemoteItemsFeedParsing(feedGuidsToParse, params);
|
|
103
98
|
}
|
|
99
|
+
return [];
|
|
104
100
|
});
|
|
105
101
|
const handleRemoteItemsChannelParsing = (channel, params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
106
102
|
const channelRemoteItemService = new podverse_orm_1.ChannelRemoteItemService();
|
|
107
103
|
const channelRemoteItems = yield channelRemoteItemService.getAll(channel);
|
|
108
104
|
const feedGuidsToParse = channelRemoteItems.map(remoteItem => remoteItem.feed_guid);
|
|
109
|
-
yield handleRemoteItemsFeedParsing(feedGuidsToParse, params);
|
|
105
|
+
return yield handleRemoteItemsFeedParsing(feedGuidsToParse, params);
|
|
110
106
|
});
|
|
111
107
|
const handleRemoteItemsItemValueTimeSplitParsing = (channel, params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
112
108
|
var _a, _b;
|
|
@@ -120,6 +116,7 @@ const handleRemoteItemsItemValueTimeSplitParsing = (channel, params) => __awaite
|
|
|
120
116
|
'item_values.item_value_time_splits.item_value_time_split_remote_item'
|
|
121
117
|
]
|
|
122
118
|
});
|
|
119
|
+
const results = [];
|
|
123
120
|
for (const item of items) {
|
|
124
121
|
if (item) {
|
|
125
122
|
if (((_a = item.item_values) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
@@ -128,7 +125,10 @@ const handleRemoteItemsItemValueTimeSplitParsing = (channel, params) => __awaite
|
|
|
128
125
|
for (const itemValueTimeSplit of itemValue.item_value_time_splits) {
|
|
129
126
|
if (itemValueTimeSplit.item_value_time_split_remote_item) {
|
|
130
127
|
const feedGuid = itemValueTimeSplit.item_value_time_split_remote_item.feed_guid;
|
|
131
|
-
yield handleRemoteItemsFeedParsing([feedGuid], params);
|
|
128
|
+
const res = yield handleRemoteItemsFeedParsing([feedGuid], params);
|
|
129
|
+
if (res && res.length > 0) {
|
|
130
|
+
results.push(...res);
|
|
131
|
+
}
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
}
|
|
@@ -136,5 +136,7 @@ const handleRemoteItemsItemValueTimeSplitParsing = (channel, params) => __awaite
|
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
|
+
return results;
|
|
139
140
|
}
|
|
141
|
+
return [];
|
|
140
142
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "podverse-parser",
|
|
3
|
-
"version": "5.1.12-alpha.
|
|
3
|
+
"version": "5.1.12-alpha.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
"license": "AGPLv3",
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"module-alias": "^2.2.3",
|
|
20
|
-
"podverse-external-services": "^5.1.12-alpha.
|
|
21
|
-
"podverse-helpers": "^5.1.12-alpha.
|
|
22
|
-
"podverse-orm": "^5.1.12-alpha.
|
|
20
|
+
"podverse-external-services": "^5.1.12-alpha.2",
|
|
21
|
+
"podverse-helpers": "^5.1.12-alpha.1",
|
|
22
|
+
"podverse-orm": "^5.1.12-alpha.1",
|
|
23
23
|
"podverse-partytime": "^5.0.0"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|