mirror of
https://github.com/sct/overseerr.git
synced 2025-09-17 17:24:35 +02:00
fix(sonarr): correctly search when updating existing sonarr series
fixes #588
This commit is contained in:
@@ -207,11 +207,6 @@ class SonarrAPI extends ExternalAPI {
|
|||||||
if (series.id) {
|
if (series.id) {
|
||||||
series.seasons = this.buildSeasonList(options.seasons, series.seasons);
|
series.seasons = this.buildSeasonList(options.seasons, series.seasons);
|
||||||
|
|
||||||
series.addOptions = {
|
|
||||||
ignoreEpisodesWithFiles: true,
|
|
||||||
searchForMissingEpisodes: options.searchNow,
|
|
||||||
};
|
|
||||||
|
|
||||||
const newSeriesResponse = await this.axios.put<SonarrSeries>(
|
const newSeriesResponse = await this.axios.put<SonarrSeries>(
|
||||||
'/series',
|
'/series',
|
||||||
series
|
series
|
||||||
@@ -225,6 +220,9 @@ class SonarrAPI extends ExternalAPI {
|
|||||||
label: 'Sonarr',
|
label: 'Sonarr',
|
||||||
movie: newSeriesResponse.data,
|
movie: newSeriesResponse.data,
|
||||||
});
|
});
|
||||||
|
if (options.searchNow) {
|
||||||
|
this.searchSeries(newSeriesResponse.data.id);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
logger.error('Failed to update series in Sonarr', {
|
logger.error('Failed to update series in Sonarr', {
|
||||||
label: 'Sonarr',
|
label: 'Sonarr',
|
||||||
@@ -350,6 +348,33 @@ class SonarrAPI extends ExternalAPI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async searchSeries(seriesId: number): Promise<void> {
|
||||||
|
logger.info('Executing series search command', {
|
||||||
|
label: 'Sonarr API',
|
||||||
|
seriesId,
|
||||||
|
});
|
||||||
|
await this.runCommand('SeriesSearch', { seriesId });
|
||||||
|
}
|
||||||
|
|
||||||
|
private async runCommand(
|
||||||
|
commandName: string,
|
||||||
|
options: Record<string, unknown>
|
||||||
|
): Promise<void> {
|
||||||
|
try {
|
||||||
|
await this.axios.post(`/command`, {
|
||||||
|
name: commandName,
|
||||||
|
...options,
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
logger.error('Something went wrong attempting to run a Sonarr command.', {
|
||||||
|
label: 'Sonarr API',
|
||||||
|
message: e.message,
|
||||||
|
});
|
||||||
|
|
||||||
|
throw new Error('Failed to run Sonarr command.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private buildSeasonList(
|
private buildSeasonList(
|
||||||
seasons: number[],
|
seasons: number[],
|
||||||
existingSeasons?: SonarrSeason[]
|
existingSeasons?: SonarrSeason[]
|
||||||
|
Reference in New Issue
Block a user