Skip to content

Commit

Permalink
Removed the V3 switch from Radarr, no one is using V2 Radarr anymore.
Browse files Browse the repository at this point in the history
  • Loading branch information
tidusjar committed Jun 8, 2021
1 parent 9dbadc1 commit 5e33088
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 78 deletions.
65 changes: 15 additions & 50 deletions src/Ombi.Core/Senders/MovieSender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ private async Task<DogNzbMovieAddResult> SendToDogNzb(FullBaseRequest model, Dog

private async Task<SenderResult> SendToRadarr(MovieRequests model, RadarrSettings settings)
{
var v3 = settings.V3;
var qualityToUse = int.Parse(settings.DefaultQualityProfile);

var rootFolderPath = settings.DefaultRootPath;
Expand Down Expand Up @@ -159,30 +158,16 @@ private async Task<SenderResult> SendToRadarr(MovieRequests model, RadarrSetting

List<MovieResponse> movies;
// Check if the movie already exists? Since it could be unmonitored
if (settings.V3)
{
movies = await _radarrV3Api.GetMovies(settings.ApiKey, settings.FullUri);
}
else
{
movies = await _radarrV2Api.GetMovies(settings.ApiKey, settings.FullUri);
}

movies = await _radarrV3Api.GetMovies(settings.ApiKey, settings.FullUri);

var existingMovie = movies.FirstOrDefault(x => x.tmdbId == model.TheMovieDbId);
if (existingMovie == null)
{
RadarrAddMovie result;
if (v3)
{
result = await _radarrV3Api.AddMovie(model.TheMovieDbId, model.Title, model.ReleaseDate.Year,
qualityToUse, rootFolderPath, settings.ApiKey, settings.FullUri, !settings.AddOnly,
settings.MinimumAvailability);
}
else
{
result = await _radarrV2Api.AddMovie(model.TheMovieDbId, model.Title, model.ReleaseDate.Year,
qualityToUse, rootFolderPath, settings.ApiKey, settings.FullUri, !settings.AddOnly,
settings.MinimumAvailability);
}
var result = await _radarrV3Api.AddMovie(model.TheMovieDbId, model.Title, model.ReleaseDate.Year,
qualityToUse, rootFolderPath, settings.ApiKey, settings.FullUri, !settings.AddOnly,
settings.MinimumAvailability);

if (!string.IsNullOrEmpty(result.Error?.message))
{
_log.LogError(LoggingEvents.RadarrCacher, result.Error.message);
Expand All @@ -199,23 +184,12 @@ private async Task<SenderResult> SendToRadarr(MovieRequests model, RadarrSetting
{
// let's set it to monitored and search for it
existingMovie.monitored = true;
if (v3)
{
await _radarrV3Api.UpdateMovie(existingMovie, settings.ApiKey, settings.FullUri);
// Search for it
if (!settings.AddOnly)
{
await _radarrV3Api.MovieSearch(new[] { existingMovie.id }, settings.ApiKey, settings.FullUri);
}
}
else

await _radarrV3Api.UpdateMovie(existingMovie, settings.ApiKey, settings.FullUri);
// Search for it
if (!settings.AddOnly)
{
await _radarrV2Api.UpdateMovie(existingMovie, settings.ApiKey, settings.FullUri);
// Search for it
if (!settings.AddOnly)
{
await _radarrV2Api.MovieSearch(new[] { existingMovie.id }, settings.ApiKey, settings.FullUri);
}
await _radarrV3Api.MovieSearch(new[] { existingMovie.id }, settings.ApiKey, settings.FullUri);
}

return new SenderResult { Success = true, Sent = true };
Expand All @@ -226,18 +200,9 @@ private async Task<SenderResult> SendToRadarr(MovieRequests model, RadarrSetting

private async Task<string> RadarrRootPath(int overrideId, RadarrSettings settings)
{
if (settings.V3)
{
var paths = await _radarrV3Api.GetRootFolders(settings.ApiKey, settings.FullUri);
var selectedPath = paths.FirstOrDefault(x => x.id == overrideId);
return selectedPath?.path ?? string.Empty;
}
else
{
var paths = await _radarrV2Api.GetRootFolders(settings.ApiKey, settings.FullUri);
var selectedPath = paths.FirstOrDefault(x => x.id == overrideId);
return selectedPath?.path ?? string.Empty;
}
var paths = await _radarrV3Api.GetRootFolders(settings.ApiKey, settings.FullUri);
var selectedPath = paths.FirstOrDefault(x => x.id == overrideId);
return selectedPath?.path ?? string.Empty;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
public class RadarrSettings : ExternalSettings
{
public bool Enabled { get; set; }
public bool V3 { get; set; }
public string ApiKey { get; set; }
public string DefaultQualityProfile { get; set; }
public string DefaultRootPath { get; set; }
Expand Down
1 change: 0 additions & 1 deletion src/Ombi/ClientApp/src/app/interfaces/ISettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ export interface IRadarrSettings extends IExternalSettings {
addOnly: boolean;
minimumAvailability: string;
scanForAvailability: boolean;
v3: boolean;
}

export interface ILidarrSettings extends IExternalSettings {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
<div class="md-form-field">
<mat-slide-toggle formControlName="enabled" id="enable">Enable</mat-slide-toggle>
</div>
<div class="md-form-field">
<mat-slide-toggle formControlName="v3">V3</mat-slide-toggle>
</div>
<div class="md-form-field">
<mat-slide-toggle formControlName="scanForAvailability">Scan for Availability</mat-slide-toggle>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ export class RadarrComponent implements OnInit {
port: [x.port, [Validators.required]],
addOnly: [x.addOnly],
minimumAvailability: [x.minimumAvailability, [Validators.required]],
scanForAvailability: [x.scanForAvailability],
v3: [x.v3 ?? true]
scanForAvailability: [x.scanForAvailability]
});

if (x.defaultQualityProfile) {
Expand Down
24 changes: 4 additions & 20 deletions src/Ombi/Controllers/V1/External/RadarrController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,7 @@ public RadarrController(IRadarrApi radarr, ISettingsService<RadarrSettings> sett
[PowerUser]
public async Task<IActionResult> GetProfiles([FromBody] RadarrSettings settings)
{
if (settings.V3)
{
return Ok(await _radarrV3Api.GetProfiles(settings.ApiKey, settings.FullUri));
}
return Ok(await _radarrApi.GetProfiles(settings.ApiKey, settings.FullUri));
return Ok(await _radarrV3Api.GetProfiles(settings.ApiKey, settings.FullUri));
}

[HttpGet("enabled")]
Expand All @@ -64,11 +60,7 @@ public async Task<bool> Enabled()
[PowerUser]
public async Task<IEnumerable<RadarrRootFolder>> GetRootFolders([FromBody] RadarrSettings settings)
{
if (settings.V3)
{
return await _radarrV3Api.GetRootFolders(settings.ApiKey, settings.FullUri);
}
return await _radarrApi.GetRootFolders(settings.ApiKey, settings.FullUri);
return await _radarrV3Api.GetRootFolders(settings.ApiKey, settings.FullUri);
}

/// <summary>
Expand All @@ -83,11 +75,7 @@ public async Task<IActionResult> GetProfiles()
var settings = await _radarrSettings.GetSettingsAsync();
if (settings.Enabled)
{
if (settings.V3)
{
return Ok(await _radarrV3Api.GetProfiles(settings.ApiKey, settings.FullUri));
}
return Ok(await _radarrApi.GetProfiles(settings.ApiKey, settings.FullUri));
return Ok(await _radarrV3Api.GetProfiles(settings.ApiKey, settings.FullUri));
}
return null;
}
Expand All @@ -104,11 +92,7 @@ public async Task<IEnumerable<RadarrRootFolder>> GetRootFolders()
var settings = await _radarrSettings.GetSettingsAsync();
if (settings.Enabled)
{
if (settings.V3)
{
return await _radarrV3Api.GetRootFolders(settings.ApiKey, settings.FullUri);
}
return await _radarrApi.GetRootFolders(settings.ApiKey, settings.FullUri);
return await _radarrV3Api.GetRootFolders(settings.ApiKey, settings.FullUri);
}
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Ombi/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
"Ombi": {
"commandName": "Project",
"commandLineArgs": "--host http://localhost:3577",
"commandLineArgs": "--host http://localhost:3577 --demo true",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
Expand Down

0 comments on commit 5e33088

Please sign in to comment.