Skip to content

Commit

Permalink
fix: prevent Fetcharr from adding existing items to services
Browse files Browse the repository at this point in the history
  • Loading branch information
maxnatamo committed Sep 21, 2024
1 parent 01ae083 commit 85e7430
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 18 deletions.
23 changes: 14 additions & 9 deletions src/Provider.Radarr/src/RadarrClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,17 +194,22 @@ await this._client
return await newMovieResponse.GetJsonAsync<RadarrMovie>();
}

IFlurlResponse createdMovieResponse = await this._client
.Request("/api/v3/movie")
.PostJsonAsync(requestBody);
if(movie.Id is null)
{
IFlurlResponse createdMovieResponse = await this._client
.Request("/api/v3/movie")
.PostJsonAsync(requestBody);

logger.LogDebug(
"Added '{Title} ({Year})' to Radarr instance '{Instance}'.",
movie.Title,
movie.Year,
this.Name);

logger.LogDebug(
"Added '{Title} ({Year})' to Radarr instance '{Instance}'.",
movie.Title,
movie.Year,
this.Name);
return await createdMovieResponse.GetJsonAsync<RadarrMovie>();
}

return await createdMovieResponse.GetJsonAsync<RadarrMovie>();
return null;
}

/// <summary>
Expand Down
23 changes: 14 additions & 9 deletions src/Provider.Sonarr/src/SonarrClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,17 +155,22 @@ await this._client
return await newSeriesResponse.GetJsonAsync<SonarrSeries>();
}

IFlurlResponse createdSeriesResponse = await this._client
.Request("/api/v3/series")
.PostJsonAsync(requestBody);
if(series.Id is null)
{
IFlurlResponse createdSeriesResponse = await this._client
.Request("/api/v3/series")
.PostJsonAsync(requestBody);

logger.LogDebug(
"Added '{Title} ({Year})' to Sonarr instance '{Instance}'.",
series.Title,
series.Year,
this.Name);

logger.LogDebug(
"Added '{Title} ({Year})' to Sonarr instance '{Instance}'.",
series.Title,
series.Year,
this.Name);
return await createdSeriesResponse.GetJsonAsync<SonarrSeries>();
}

return await createdSeriesResponse.GetJsonAsync<SonarrSeries>();
return null;
}

/// <summary>
Expand Down

0 comments on commit 85e7430

Please sign in to comment.