@apocaliss92/series-scraper-core 0.0.99 → 0.0.101

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.
@@ -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
- return this.repo.read();
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);
@@ -49,7 +49,6 @@ interface RegisterInput {
49
49
  entry: {
50
50
  id: string;
51
51
  title: string;
52
- muted?: boolean;
53
52
  };
54
53
  season: number;
55
54
  episode: number;
@@ -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
- if (!entry.muted) {
117
- this.notifications.emit({
118
- type: 'captcha_needed',
119
- title: 'Captcha needed',
120
- message: `Captcha needed for ${entry.title}${season > 0 ? ` ${label}` : ''}`,
121
- level: 'warning',
122
- data: { entryId: entry.id, title: entry.title, episode: label, challengeId: challenge.id },
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 && !e.muted))
119
- || filteredMovies.some((m) => this.table.getAllByArrId(m.movieId, 'movie').some((e) => !e.paused && !e.muted));
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, muted: entry.muted }, season, episode, label, error });
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:
@@ -929,10 +912,13 @@ let DownloadService = DownloadService_1 = class DownloadService {
929
912
  const childId = childTrackerId(owner.id, epLabel);
930
913
  const tag = this.epTag(entry.title, epLabel);
931
914
  if (!episode) {
932
- const notFoundMsg = siteEpNumber !== epNumber
915
+ const listed = episodes.map((e) => e.number);
916
+ const baseMsg = siteEpNumber !== epNumber
933
917
  ? `Episode ${epNumber} not found on source (looked for site ep ${siteEpNumber})`
934
918
  : `Episode ${epNumber} not found on source`;
935
- const reason = (0, failure_reason_1.missingEpisodeReason)(episodes.map((e) => e.number), siteEpNumber);
919
+ const hint = (0, failure_reason_1.numberingHint)(listed, siteEpNumber);
920
+ const notFoundMsg = hint === null ? baseMsg : `${baseMsg}; ${hint}`;
921
+ const reason = (0, failure_reason_1.missingEpisodeReason)(listed, siteEpNumber);
936
922
  if (reason === 'not_available') {
937
923
  this.noteNotAvailable(entry, missingEp.seasonNumber, epNumber, epLabel, notFoundMsg, tag, undefined, false);
938
924
  return {
@@ -1184,10 +1170,8 @@ let DownloadService = DownloadService_1 = class DownloadService {
1184
1170
  });
1185
1171
  if (!notes.some((n) => n.reason === 'captcha_required')) {
1186
1172
  const data = { entryId: entry.id, title: entry.title, episode: entry.title, type: 'movie', error: message };
1187
- if (!this.isMuted(entry.id, entry.muted ?? false)) {
1188
- this.notifications.emit({ type: 'download_fail', title: 'Download Failed', message: `Movie "${entry.title}" failed: ${message}`, level: 'error', data });
1189
- this.notifications.emit({ type: 'episode_fail', title: 'Movie Failed', message: `${entry.title}: ${message}`, level: 'error', data });
1190
- }
1173
+ this.notifications.emit({ type: 'download_fail', title: 'Download Failed', message: `Movie "${entry.title}" failed: ${message}`, level: 'error', data });
1174
+ this.notifications.emit({ type: 'episode_fail', title: 'Movie Failed', message: `${entry.title}: ${message}`, level: 'error', data });
1191
1175
  }
1192
1176
  return { success: false, downloaded: 0, failed: 1, details: [{ status: 'error', message }] };
1193
1177
  }
@@ -1202,10 +1186,7 @@ let DownloadService = DownloadService_1 = class DownloadService {
1202
1186
  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
1187
  }
1204
1188
  const settings = this.settings.get();
1205
- const notify = (payload) => {
1206
- if (!this.isMuted(entry.id, entry.muted ?? false))
1207
- this.notifications.emit(payload);
1208
- };
1189
+ const notify = (payload) => this.notifications.emit(payload);
1209
1190
  if (!entry.url) {
1210
1191
  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
1192
  }
@@ -3005,7 +2986,10 @@ let DownloadService = DownloadService_1 = class DownloadService {
3005
2986
  const episodes = await adapter.fetchEpisodes(seasonBinding.url);
3006
2987
  const ep = episodes.find((e) => e.number === siteEp);
3007
2988
  if (!ep) {
3008
- this.recordEpisodeFailure(entry, season, episode, epLabel, 'Episode not found on source', (0, failure_reason_1.missingEpisodeReason)(episodes.map((e) => e.number), siteEp));
2989
+ const listed = episodes.map((e) => e.number);
2990
+ const hint = (0, failure_reason_1.numberingHint)(listed, siteEp);
2991
+ const msg = hint === null ? 'Episode not found on source' : `Episode not found on source; ${hint}`;
2992
+ this.recordEpisodeFailure(entry, season, episode, epLabel, msg, (0, failure_reason_1.missingEpisodeReason)(listed, siteEp));
3009
2993
  this.tracker.finish(entry.id);
3010
2994
  return;
3011
2995
  }
@@ -29,3 +29,9 @@ export declare function isUnavailableCoolingDown(record: {
29
29
  * source/scrape problem, not a release that has not happened.
30
30
  */
31
31
  export declare function missingEpisodeReason(listedNumbers: readonly number[], siteEpisode: number): FailureReason;
32
+ /**
33
+ * Why an episode below the source's whole list is missing: the source most likely numbers
34
+ * episodes continuously across seasons (S02E01 listed as 25). Null when the gap says nothing
35
+ * about numbering.
36
+ */
37
+ export declare function numberingHint(listedNumbers: readonly number[], siteEpisode: number): string | null;
@@ -6,6 +6,7 @@ exports.classifyLinkFailures = classifyLinkFailures;
6
6
  exports.effectiveReason = effectiveReason;
7
7
  exports.isUnavailableCoolingDown = isUnavailableCoolingDown;
8
8
  exports.missingEpisodeReason = missingEpisodeReason;
9
+ exports.numberingHint = numberingHint;
9
10
  const egress_router_1 = require("./egress/egress-router");
10
11
  const uprot_captcha_1 = require("./uprot-captcha");
11
12
  /** A not-available item is not re-queried on every scan; it is re-checked after this. */
@@ -59,3 +60,16 @@ function missingEpisodeReason(listedNumbers, siteEpisode) {
59
60
  return 'fetch_failed';
60
61
  return siteEpisode > Math.max(...listedNumbers) ? 'not_available' : 'fetch_failed';
61
62
  }
63
+ /**
64
+ * Why an episode below the source's whole list is missing: the source most likely numbers
65
+ * episodes continuously across seasons (S02E01 listed as 25). Null when the gap says nothing
66
+ * about numbering.
67
+ */
68
+ function numberingHint(listedNumbers, siteEpisode) {
69
+ if (listedNumbers.length === 0)
70
+ return null;
71
+ const first = Math.min(...listedNumbers);
72
+ if (siteEpisode >= first)
73
+ return null;
74
+ return `the source starts at episode ${first}: it may number episodes across seasons — use absolute numbering on the binding or a season offset`;
75
+ }
@@ -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; muted ones only on an operator-triggered run.
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; muted ones only on an operator-triggered run.
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 && (manual || !e.muted);
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 or muted primary still owns the item: pausing a series pauses its sources too.
58
- const live = primaries.some((e) => !e.paused && !e.muted);
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/muted`,
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apocaliss92/series-scraper-core",
3
- "version": "0.0.99",
3
+ "version": "0.0.101",
4
4
  "description": "Host-agnostic scraper core: services, repositories, controllers and the ports a host supplies",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",