@apocaliss92/series-scraper-core 0.0.99 → 0.0.100
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/controllers/table.controller.d.ts +0 -4
- package/dist/controllers/table.controller.js +0 -16
- package/dist/repositories/table.repository.d.ts +5 -0
- package/dist/repositories/table.repository.js +11 -1
- package/dist/services/captcha.service.d.ts +0 -1
- package/dist/services/captcha.service.js +7 -9
- package/dist/services/core.service.js +2 -2
- package/dist/services/download.service.d.ts +0 -7
- package/dist/services/download.service.js +5 -27
- package/dist/services/fallback-sources.d.ts +1 -1
- package/dist/services/fallback-sources.js +5 -5
- package/dist/types.d.ts +0 -1
- package/package.json +1 -1
|
@@ -48,10 +48,6 @@ export declare class TableController {
|
|
|
48
48
|
ok: boolean;
|
|
49
49
|
paused: boolean | undefined;
|
|
50
50
|
};
|
|
51
|
-
toggleMute(id: string): {
|
|
52
|
-
ok: boolean;
|
|
53
|
-
muted: boolean | undefined;
|
|
54
|
-
};
|
|
55
51
|
downloadAll(id: string, force?: string): {
|
|
56
52
|
ok: boolean;
|
|
57
53
|
message: string;
|
|
@@ -88,15 +88,6 @@ let TableController = TableController_1 = class TableController {
|
|
|
88
88
|
throw new common_1.HttpException('Entry not found', common_1.HttpStatus.NOT_FOUND);
|
|
89
89
|
return { ok: true, paused: updated.paused };
|
|
90
90
|
}
|
|
91
|
-
toggleMute(id) {
|
|
92
|
-
const entry = this.tableService.getById(id);
|
|
93
|
-
if (!entry)
|
|
94
|
-
throw new common_1.HttpException('Entry not found', common_1.HttpStatus.NOT_FOUND);
|
|
95
|
-
const updated = this.tableService.update(id, { muted: !entry.muted });
|
|
96
|
-
if (!updated)
|
|
97
|
-
throw new common_1.HttpException('Entry not found', common_1.HttpStatus.NOT_FOUND);
|
|
98
|
-
return { ok: true, muted: updated.muted };
|
|
99
|
-
}
|
|
100
91
|
downloadAll(id, force) {
|
|
101
92
|
const entry = this.tableService.getById(id);
|
|
102
93
|
if (!entry)
|
|
@@ -269,13 +260,6 @@ __decorate([
|
|
|
269
260
|
__metadata("design:paramtypes", [String]),
|
|
270
261
|
__metadata("design:returntype", void 0)
|
|
271
262
|
], TableController.prototype, "togglePause", null);
|
|
272
|
-
__decorate([
|
|
273
|
-
(0, common_1.Post)(':id/mute'),
|
|
274
|
-
__param(0, (0, common_1.Param)('id')),
|
|
275
|
-
__metadata("design:type", Function),
|
|
276
|
-
__metadata("design:paramtypes", [String]),
|
|
277
|
-
__metadata("design:returntype", void 0)
|
|
278
|
-
], TableController.prototype, "toggleMute", null);
|
|
279
263
|
__decorate([
|
|
280
264
|
(0, common_1.Post)(':id/download'),
|
|
281
265
|
__param(0, (0, common_1.Param)('id')),
|
|
@@ -3,6 +3,11 @@ import { StateStore } from '../ports/state-store';
|
|
|
3
3
|
export declare class TableRepository {
|
|
4
4
|
private readonly repo;
|
|
5
5
|
constructor(state: StateStore);
|
|
6
|
+
/**
|
|
7
|
+
* Entries saved before the per-entry mute was removed carry `muted`. A muted entry was
|
|
8
|
+
* skipped by the automatic scan, so it becomes paused (nothing starts scanning by surprise)
|
|
9
|
+
* and the field is dropped; the table is rewritten once, and a clean table is never touched.
|
|
10
|
+
*/
|
|
6
11
|
getAll(): TableEntry[];
|
|
7
12
|
getById(id: string): TableEntry | undefined;
|
|
8
13
|
/** Returns the first entry matching arrId + type (legacy single-binding lookup). */
|
|
@@ -20,8 +20,18 @@ let TableRepository = class TableRepository {
|
|
|
20
20
|
constructor(state) {
|
|
21
21
|
this.repo = new state_store_1.StoredCollection(state, 'table', []);
|
|
22
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Entries saved before the per-entry mute was removed carry `muted`. A muted entry was
|
|
25
|
+
* skipped by the automatic scan, so it becomes paused (nothing starts scanning by surprise)
|
|
26
|
+
* and the field is dropped; the table is rewritten once, and a clean table is never touched.
|
|
27
|
+
*/
|
|
23
28
|
getAll() {
|
|
24
|
-
|
|
29
|
+
const stored = this.repo.read();
|
|
30
|
+
if (!stored.some((entry) => 'muted' in entry))
|
|
31
|
+
return stored;
|
|
32
|
+
const migrated = stored.map(({ muted, ...entry }) => (muted ? { ...entry, paused: true } : entry));
|
|
33
|
+
this.repo.write(migrated);
|
|
34
|
+
return migrated;
|
|
25
35
|
}
|
|
26
36
|
getById(id) {
|
|
27
37
|
return this.getAll().find((entry) => entry.id === id);
|
|
@@ -113,15 +113,13 @@ let CaptchaService = CaptchaService_1 = class CaptchaService {
|
|
|
113
113
|
};
|
|
114
114
|
this.repo.save(challenge);
|
|
115
115
|
this.logger.log(`${error.stage === 'hoster' ? 'Hoster captcha' : 'Captcha'} needed for "${entry.title}" ${label} (host ${(0, captcha_fallback_1.hostOf)(challenge.uprotUrl)}, challenge ${challenge.id})`);
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
});
|
|
124
|
-
}
|
|
116
|
+
this.notifications.emit({
|
|
117
|
+
type: 'captcha_needed',
|
|
118
|
+
title: 'Captcha needed',
|
|
119
|
+
message: `Captcha needed for ${entry.title}${season > 0 ? ` ${label}` : ''}`,
|
|
120
|
+
level: 'warning',
|
|
121
|
+
data: { entryId: entry.id, title: entry.title, episode: label, challengeId: challenge.id },
|
|
122
|
+
});
|
|
125
123
|
return challenge;
|
|
126
124
|
}
|
|
127
125
|
list() {
|
|
@@ -115,8 +115,8 @@ let CoreService = CoreService_1 = class CoreService {
|
|
|
115
115
|
const filteredMovies = this.tags.filterByTags(missingMovies);
|
|
116
116
|
this.logger.log(`Found ${filteredEpisodes.length} missing episodes, ${filteredMovies.length} missing movies (after tag filter)`);
|
|
117
117
|
// Only notify scan_start when there is actually actionable work (avoids webhook spam on idle scans)
|
|
118
|
-
const hasWork = filteredEpisodes.some((ep) => this.table.getAllByArrId(ep.seriesId, 'series').some((e) => !e.paused
|
|
119
|
-
|| filteredMovies.some((m) => this.table.getAllByArrId(m.movieId, 'movie').some((e) => !e.paused
|
|
118
|
+
const hasWork = filteredEpisodes.some((ep) => this.table.getAllByArrId(ep.seriesId, 'series').some((e) => !e.paused))
|
|
119
|
+
|| filteredMovies.some((m) => this.table.getAllByArrId(m.movieId, 'movie').some((e) => !e.paused));
|
|
120
120
|
if (hasWork) {
|
|
121
121
|
this.notifications.emit({
|
|
122
122
|
type: 'scan_start',
|
|
@@ -105,11 +105,6 @@ export declare class DownloadService implements OnApplicationBootstrap, OnModule
|
|
|
105
105
|
/** A link that stopped at a captcha becomes a pending challenge for the operator (one per item). */
|
|
106
106
|
private handleLinkError;
|
|
107
107
|
private clearEpisodeFailure;
|
|
108
|
-
/**
|
|
109
|
-
* Returns true if the entry is currently muted, reading fresh from disk so that
|
|
110
|
-
* toggling mute during an in-progress download takes effect immediately.
|
|
111
|
-
*/
|
|
112
|
-
private isMuted;
|
|
113
108
|
/**
|
|
114
109
|
* Public method to resolve a URL to a downloadable video link.
|
|
115
110
|
* Used by the UI to test/resolve streaming links before downloading.
|
|
@@ -126,8 +121,6 @@ export declare class DownloadService implements OnApplicationBootstrap, OnModule
|
|
|
126
121
|
*
|
|
127
122
|
* Behaviour:
|
|
128
123
|
* - paused: skipped silently in auto-scan; bypassed when `manual: true` (explicit user action).
|
|
129
|
-
* - muted: always skipped in auto-scan; bypassed when `manual: true` BUT the notify()
|
|
130
|
-
* wrapper inside downloadSeries/downloadMovie still suppresses webhooks/toasts.
|
|
131
124
|
*/
|
|
132
125
|
/** All of an entry's work runs in its egress context, so its exit override reaches every request. */
|
|
133
126
|
downloadEntry(entry: TableEntry, seasonNumber?: number, opts?: {
|
|
@@ -409,7 +409,7 @@ let DownloadService = DownloadService_1 = class DownloadService {
|
|
|
409
409
|
/** A link that stopped at a captcha becomes a pending challenge for the operator (one per item). */
|
|
410
410
|
handleLinkError(entry, season, episode, label, link, error) {
|
|
411
411
|
if (error instanceof uprot_captcha_1.CaptchaRequiredError) {
|
|
412
|
-
const challenge = this.captcha.register({ entry: { id: entry.id, title: entry.title
|
|
412
|
+
const challenge = this.captcha.register({ entry: { id: entry.id, title: entry.title }, season, episode, label, error });
|
|
413
413
|
// The item already had a live challenge: the page just opened for this one will never be used.
|
|
414
414
|
if (error.sessionId && challenge.sessionId !== error.sessionId)
|
|
415
415
|
void this.headless.dismissHosterSession(error.sessionId);
|
|
@@ -429,14 +429,6 @@ let DownloadService = DownloadService_1 = class DownloadService {
|
|
|
429
429
|
clearEpisodeFailure(entry, season, episode) {
|
|
430
430
|
this.failedRepo.clear(entry.id, season, episode);
|
|
431
431
|
}
|
|
432
|
-
/**
|
|
433
|
-
* Returns true if the entry is currently muted, reading fresh from disk so that
|
|
434
|
-
* toggling mute during an in-progress download takes effect immediately.
|
|
435
|
-
*/
|
|
436
|
-
isMuted(entryId, fallbackMuted) {
|
|
437
|
-
const current = this.tableRepo.getById(entryId);
|
|
438
|
-
return current?.muted ?? fallbackMuted;
|
|
439
|
-
}
|
|
440
432
|
/**
|
|
441
433
|
* Public method to resolve a URL to a downloadable video link.
|
|
442
434
|
* Used by the UI to test/resolve streaming links before downloading.
|
|
@@ -459,8 +451,6 @@ let DownloadService = DownloadService_1 = class DownloadService {
|
|
|
459
451
|
*
|
|
460
452
|
* Behaviour:
|
|
461
453
|
* - paused: skipped silently in auto-scan; bypassed when `manual: true` (explicit user action).
|
|
462
|
-
* - muted: always skipped in auto-scan; bypassed when `manual: true` BUT the notify()
|
|
463
|
-
* wrapper inside downloadSeries/downloadMovie still suppresses webhooks/toasts.
|
|
464
454
|
*/
|
|
465
455
|
/** All of an entry's work runs in its egress context, so its exit override reaches every request. */
|
|
466
456
|
downloadEntry(entry, seasonNumber, opts) {
|
|
@@ -537,10 +527,6 @@ let DownloadService = DownloadService_1 = class DownloadService {
|
|
|
537
527
|
this.logger.debug(`Skipping paused binding "${entry.title}"`);
|
|
538
528
|
return { success: true, downloaded: 0, failed: 0, details: [{ status: 'skipped', message: 'Entry is paused' }] };
|
|
539
529
|
}
|
|
540
|
-
if (entry.muted && !isManual) {
|
|
541
|
-
this.logger.debug(`Skipping muted binding "${entry.title}"`);
|
|
542
|
-
return { success: true, downloaded: 0, failed: 0, details: [{ status: 'skipped', message: 'Entry is muted' }] };
|
|
543
|
-
}
|
|
544
530
|
if (this.tracker.isActive(entry.id) && !isForced) {
|
|
545
531
|
this.logger.debug(`Download already running for "${entry.title}" — skipping`);
|
|
546
532
|
return { success: true, downloaded: 0, failed: 0, details: [{ status: 'skipped', message: 'Download already in progress' }] };
|
|
@@ -568,10 +554,7 @@ let DownloadService = DownloadService_1 = class DownloadService {
|
|
|
568
554
|
}
|
|
569
555
|
const settings = this.settings.get();
|
|
570
556
|
const result = { success: true, downloaded: 0, failed: 0, unavailable: 0, details: [] };
|
|
571
|
-
const notify = (payload) =>
|
|
572
|
-
if (!this.isMuted(entry.id, entry.muted ?? false))
|
|
573
|
-
this.notifications.emit(payload);
|
|
574
|
-
};
|
|
557
|
+
const notify = (payload) => this.notifications.emit(payload);
|
|
575
558
|
// Get missing episodes from Sonarr
|
|
576
559
|
const allMissing = await this.sonarr.getMissing();
|
|
577
560
|
// Which Sonarr seasons this binding is responsible for:
|
|
@@ -1184,10 +1167,8 @@ let DownloadService = DownloadService_1 = class DownloadService {
|
|
|
1184
1167
|
});
|
|
1185
1168
|
if (!notes.some((n) => n.reason === 'captcha_required')) {
|
|
1186
1169
|
const data = { entryId: entry.id, title: entry.title, episode: entry.title, type: 'movie', error: message };
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
this.notifications.emit({ type: 'episode_fail', title: 'Movie Failed', message: `${entry.title}: ${message}`, level: 'error', data });
|
|
1190
|
-
}
|
|
1170
|
+
this.notifications.emit({ type: 'download_fail', title: 'Download Failed', message: `Movie "${entry.title}" failed: ${message}`, level: 'error', data });
|
|
1171
|
+
this.notifications.emit({ type: 'episode_fail', title: 'Movie Failed', message: `${entry.title}: ${message}`, level: 'error', data });
|
|
1191
1172
|
}
|
|
1192
1173
|
return { success: false, downloaded: 0, failed: 1, details: [{ status: 'error', message }] };
|
|
1193
1174
|
}
|
|
@@ -1202,10 +1183,7 @@ let DownloadService = DownloadService_1 = class DownloadService {
|
|
|
1202
1183
|
return noteEarly({ success: false, downloaded: 0, failed: 0, details: [{ status: 'error', message: `Adapter "${entry.adapterName}" not found` }] }, 'fetch_failed', `Adapter "${entry.adapterName}" not found`);
|
|
1203
1184
|
}
|
|
1204
1185
|
const settings = this.settings.get();
|
|
1205
|
-
const notify = (payload) =>
|
|
1206
|
-
if (!this.isMuted(entry.id, entry.muted ?? false))
|
|
1207
|
-
this.notifications.emit(payload);
|
|
1208
|
-
};
|
|
1186
|
+
const notify = (payload) => this.notifications.emit(payload);
|
|
1209
1187
|
if (!entry.url) {
|
|
1210
1188
|
return noteEarly({ success: false, downloaded: 0, failed: 1, details: [{ status: 'error', message: 'No source URL for movie' }] }, 'fetch_failed', 'No source URL for movie');
|
|
1211
1189
|
}
|
|
@@ -22,7 +22,7 @@ export interface SourcePlan {
|
|
|
22
22
|
* - with no primary left the lowest-order covering fallback runs as the primary and the rest
|
|
23
23
|
* follow it, so two orphans never fetch the same item at once;
|
|
24
24
|
* - an operator-triggered run of a fallback entry runs it alone.
|
|
25
|
-
* Paused fallbacks are never asked
|
|
25
|
+
* Paused fallbacks are never asked.
|
|
26
26
|
*/
|
|
27
27
|
export declare function planSources(entry: TableEntry, siblings: readonly TableEntry[], covers: (e: TableEntry) => boolean, manual: boolean): SourcePlan;
|
|
28
28
|
export interface FallbackFieldsInput {
|
|
@@ -39,11 +39,11 @@ const byFallbackOrder = (a, b) => orderOf(a) - orderOf(b) || a.id.localeCompare(
|
|
|
39
39
|
* - with no primary left the lowest-order covering fallback runs as the primary and the rest
|
|
40
40
|
* follow it, so two orphans never fetch the same item at once;
|
|
41
41
|
* - an operator-triggered run of a fallback entry runs it alone.
|
|
42
|
-
* Paused fallbacks are never asked
|
|
42
|
+
* Paused fallbacks are never asked.
|
|
43
43
|
*/
|
|
44
44
|
function planSources(entry, siblings, covers, manual) {
|
|
45
45
|
const others = siblings.filter((e) => e.id !== entry.id && e.arrId === entry.arrId && e.type === entry.type);
|
|
46
|
-
const usable = (e) => !e.paused
|
|
46
|
+
const usable = (e) => !e.paused;
|
|
47
47
|
const askable = (e) => !!e.fallback && usable(e) && covers(e);
|
|
48
48
|
if (!entry.fallback) {
|
|
49
49
|
return { run: true, chain: others.filter(askable).sort(byFallbackOrder) };
|
|
@@ -54,14 +54,14 @@ function planSources(entry, siblings, covers, manual) {
|
|
|
54
54
|
return { run: false, chain: [] };
|
|
55
55
|
const primaries = others.filter((e) => !e.fallback && covers(e));
|
|
56
56
|
if (primaries.length > 0) {
|
|
57
|
-
// A paused
|
|
58
|
-
const live = primaries.some((e) => !e.paused
|
|
57
|
+
// A paused primary still owns the item: pausing a series pauses its sources too.
|
|
58
|
+
const live = primaries.some((e) => !e.paused);
|
|
59
59
|
return {
|
|
60
60
|
run: false,
|
|
61
61
|
chain: [],
|
|
62
62
|
skipReason: live
|
|
63
63
|
? `its primary ${primaries[0].id} covers it`
|
|
64
|
-
: `primary ${primaries.map((e) => e.id).join(',')} paused
|
|
64
|
+
: `primary ${primaries.map((e) => e.id).join(',')} paused`,
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
67
|
const orphans = [entry, ...others.filter(askable)].sort(byFallbackOrder);
|
package/dist/types.d.ts
CHANGED
|
@@ -84,7 +84,6 @@ export interface TableEntry {
|
|
|
84
84
|
watchSeasons?: number[];
|
|
85
85
|
absolute?: boolean;
|
|
86
86
|
paused?: boolean;
|
|
87
|
-
muted?: boolean;
|
|
88
87
|
label?: string;
|
|
89
88
|
/** Preferred audio language for this binding (BCP-47). Falls back to AppSettings.preferredLanguage if unset. */
|
|
90
89
|
preferredLanguage?: string;
|
package/package.json
CHANGED