Skip to content

Commit

Permalink
fix: Sonarr media existence check in collection handling
Browse files Browse the repository at this point in the history
  • Loading branch information
benscobie committed Nov 20, 2024
1 parent e299c15 commit 8cd0030
Showing 1 changed file with 31 additions and 19 deletions.
50 changes: 31 additions & 19 deletions server/src/modules/collections/collection-worker.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ export class CollectionWorkerService extends TaskBase {

if (tvdbId) {
let sonarrMedia = await sonarrApiClient.getSeriesByTvdbId(tvdbId);
if (sonarrMedia) {
if (sonarrMedia?.id) {
switch (collection.arrAction) {
case ServarrAction.DELETE:
switch (collection.type) {
Expand Down Expand Up @@ -322,12 +322,16 @@ export class CollectionWorkerService extends TaskBase {
'all',
false,
);
// unmonitor show
sonarrMedia.monitored = false;
sonarrApiClient.updateSeries(sonarrMedia);
this.infoLogger(
`[Sonarr] Unmonitored show '${sonarrMedia.title}'`,
);

if (sonarrMedia) {
// unmonitor show
sonarrMedia.monitored = false;
sonarrApiClient.updateSeries(sonarrMedia);
this.infoLogger(
`[Sonarr] Unmonitored show '${sonarrMedia.title}'`,
);
}

break;
}
break;
Expand Down Expand Up @@ -360,12 +364,16 @@ export class CollectionWorkerService extends TaskBase {
'all',
true,
);
// unmonitor show
sonarrMedia.monitored = false;
sonarrApiClient.updateSeries(sonarrMedia);
this.infoLogger(
`[Sonarr] Unmonitored show '${sonarrMedia.title}' and removed all episodes`,
);

if (sonarrMedia) {
// unmonitor show
sonarrMedia.monitored = false;
sonarrApiClient.updateSeries(sonarrMedia);
this.infoLogger(
`[Sonarr] Unmonitored show '${sonarrMedia.title}' and removed all episodes`,
);
}

break;
}
break;
Expand Down Expand Up @@ -399,12 +407,16 @@ export class CollectionWorkerService extends TaskBase {
'existing',
true,
);
// unmonitor show
sonarrMedia.monitored = false;
sonarrApiClient.updateSeries(sonarrMedia);
this.infoLogger(
`[Sonarr] Unmonitored show '${sonarrMedia.title}' and Removed exisiting episodes`,
);

if (sonarrMedia) {
// unmonitor show
sonarrMedia.monitored = false;
sonarrApiClient.updateSeries(sonarrMedia);
this.infoLogger(
`[Sonarr] Unmonitored show '${sonarrMedia.title}' and Removed exisiting episodes`,
);
}

break;
}
break;
Expand Down

0 comments on commit 8cd0030

Please sign in to comment.