Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(sonarr): 🐛 Cleaned up and removed Sonarr v3 option, sonarr v3… #4764

Merged
merged 1 commit into from
Sep 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/Ombi.Api.Sonarr/Models/SonarrProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ namespace Ombi.Api.Sonarr.Models
public class SonarrProfile
{
public string name { get; set; }
public Cutoff cutoff { get; set; }
public List<Item> items { get; set; }
public int id { get; set; }
}
}
11 changes: 4 additions & 7 deletions src/Ombi.Core/Senders/TvSender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ public async Task<NewSeries> SendToSonarr(ChildRequests model, SonarrSettings s)
}

int qualityToUse;
var sonarrV3 = s.V3;
var languageProfileId = s.LanguageProfile;
string rootFolderPath;
string seriesType;
Expand Down Expand Up @@ -265,13 +264,11 @@ public async Task<NewSeries> SendToSonarr(ChildRequests model, SonarrSettings s)
ignoreEpisodesWithFiles = false, // There shouldn't be any episodes with files, this is a new season
ignoreEpisodesWithoutFiles = false, // We want all missing
searchForMissingEpisodes = false // we want dont want to search yet. We want to make sure everything is unmonitored/monitored correctly.
}
};
},
languageProfileId = languageProfileId
};

if (sonarrV3)
{
newSeries.languageProfileId = languageProfileId;
}


// Montitor the correct seasons,
// If we have that season in the model then it's monitored!
Expand Down
10 changes: 5 additions & 5 deletions src/Ombi.Helpers/MediaCacheService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public interface IMediaCacheService
}
public class MediaCacheService : CacheService, IMediaCacheService
{
private const string CacheKey = "MediaCacheServiceKeys";
private const string _cacheKey = "MediaCacheServiceKeys";

public MediaCacheService(IMemoryCache memoryCache) : base(memoryCache)
{
Expand Down Expand Up @@ -43,19 +43,19 @@ public async override Task<T> GetOrAddAsync<T>(string cacheKey, System.Func<Task

private void UpdateLocalCache(string cacheKey)
{
var mediaServiceCache = _memoryCache.Get<List<string>>(CacheKey);
var mediaServiceCache = _memoryCache.Get<List<string>>(_cacheKey);
if (mediaServiceCache == null)
{
mediaServiceCache = new List<string>();
}
mediaServiceCache.Add(cacheKey);
_memoryCache.Remove(CacheKey);
_memoryCache.Set(CacheKey, mediaServiceCache);
_memoryCache.Remove(_cacheKey);
_memoryCache.Set(_cacheKey, mediaServiceCache);
}

public Task Purge()
{
var keys = _memoryCache.Get<List<string>>(CacheKey);
var keys = _memoryCache.Get<List<string>>(_cacheKey);
if (keys == null)
{
return Task.CompletedTask;
Expand Down
2 changes: 1 addition & 1 deletion src/Ombi.Schedule/Jobs/Plex/PlexContentSync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ public async Task Execute(IJobExecutionContext context)
{
await NotifyClient("Plex Sync - Checking if any requests are now available");
Logger.LogInformation("Kicking off Plex Availability Checker");
await _mediaCacheService.Purge();
await OmbiQuartz.TriggerJob(nameof(IPlexAvailabilityChecker), "Plex");
}
var processedCont = processedContent?.Content?.Count() ?? 0;
Expand All @@ -133,6 +132,7 @@ public async Task Execute(IJobExecutionContext context)

await NotifyClient(recentlyAddedSearch ? $"Plex Recently Added Sync Finished, We processed {processedCont}, and {processedEp} Episodes" : "Plex Content Sync Finished");

await _mediaCacheService.Purge();
}

private async Task<ProcessedContent> StartTheCache(PlexSettings plexSettings, bool recentlyAddedSearch)
Expand Down
6 changes: 2 additions & 4 deletions src/Ombi.Schedule/Jobs/Sonarr/SonarrSync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace Ombi.Schedule.Jobs.Sonarr
{
public class SonarrSync : ISonarrSync
{
public SonarrSync(ISettingsService<SonarrSettings> s, ISonarrApi api, ILogger<SonarrSync> l, ExternalContext ctx,
public SonarrSync(ISettingsService<SonarrSettings> s, ISonarrV3Api api, ILogger<SonarrSync> l, ExternalContext ctx,
IMovieDbApi movieDbApi)
{
_settings = s;
Expand All @@ -35,7 +35,7 @@ public SonarrSync(ISettingsService<SonarrSettings> s, ISonarrApi api, ILogger<So
}

private readonly ISettingsService<SonarrSettings> _settings;
private readonly ISonarrApi _api;
private readonly ISonarrV3Api _api;
private readonly ILogger<SonarrSync> _log;
private readonly ExternalContext _ctx;
private readonly IMovieDbApi _movieDbApi;
Expand Down Expand Up @@ -74,8 +74,6 @@ await strat.ExecuteAsync(async () =>
}
});

var existingSeries = await _ctx.SonarrCache.Select(x => x.TvDbId).ToListAsync();

var sonarrCacheToSave = new HashSet<SonarrCache>();
foreach (var id in ids)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public class SonarrSettings : ExternalSettings
public string QualityProfileAnime { get; set; }
public string RootPathAnime { get; set; }
public bool AddOnly { get; set; }
public bool V3 { get; set; }
public int LanguageProfile { get; set; }
public int LanguageProfileAnime { get; set; }
public bool ScanForAvailability { get; set; }
Expand Down
3 changes: 2 additions & 1 deletion src/Ombi/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"emby",
"availability-rules",
"details",
"requests"
"requests",
"sonarr"
],
"rpc.enabled": true
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<p-carousel #carousel [value]="requests$ | async" [numVisible]="3" [numScroll]="1" [responsiveOptions]="responsiveOptions" [page]="0">
<ng-template let-result pTemplate="item">
<ombi-detailed-card [request]="result" [isAdmin]="isAdmin" (onClick)="navigate(result)" (onApprove)="approve(result)"></ombi-detailed-card>
</ng-template>
</p-carousel>
<div *ngIf="requests$ | async as requests">
<div *ngIf="requests.length > 0">
<p-carousel #carousel [value]="requests" [numVisible]="3" [numScroll]="1"
[responsiveOptions]="responsiveOptions" [page]="0">
<ng-template let-result pTemplate="item">
<ombi-detailed-card [request]="result" [isAdmin]="isAdmin" (onClick)="navigate(result)"
(onApprove)="approve(result)"></ombi-detailed-card>
</ng-template>
</p-carousel>
</div>
</div>
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 @@ -142,7 +142,6 @@ export interface ISonarrSettings extends IExternalSettings {
rootPathAnime: string;
fullRootPath: string;
addOnly: boolean;
v3: boolean;
languageProfile: number;
languageProfileAnime: number;
scanForAvailability: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,13 @@ export class TvAdvancedOptionsComponent implements OnInit {
this.setRootFolderOverrides();
});

if (settings.v3) {
this.sonarrService
.getV3LanguageProfiles(settings)
.subscribe((profiles: ILanguageProfiles[]) => {
this.sonarrLanguageProfiles = profiles;
this.data.languages = profiles;
this.setLanguageOverride();
});
}
});
}

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 [(ngModel)]="advanced" [ngModelOptions]="{standalone: true}">Advanced</mat-slide-toggle>
</div>
Expand Down Expand Up @@ -120,8 +117,8 @@

</div>

<div class="form-group col-md-12" *ngIf="form.controls.v3.value">
<label for="select" class="control-label">Language Profiles
<div class="form-group col-md-12">
<label for="select" class="control-label">Language Profiles
<i *ngIf="form.get('languageProfile').hasError('required')" class="fas fa-exclamation-circle error-text" pTooltip="A Language Profile is required"></i>
</label>
<div id="langaugeProfile">
Expand Down
20 changes: 3 additions & 17 deletions src/Ombi/ClientApp/src/app/settings/sonarr/sonarr.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ export class SonarrComponent implements OnInit {
port: [x.port, [Validators.required]],
addOnly: [x.addOnly],
seasonFolders: [x.seasonFolders],
v3: [x.v3],
languageProfile: [x.languageProfile],
languageProfile: [x.languageProfile, [Validators.required, validateProfile]],
languageProfileAnime: [x.languageProfileAnime],
scanForAvailability: [x.scanForAvailability],
});
Expand All @@ -87,17 +86,6 @@ export class SonarrComponent implements OnInit {
if (x.languageProfile) {
this.getLanguageProfiles(this.form);
}
if (x.v3) {
this.form.controls.languageProfile.setValidators([Validators.required]);
}

this.form.controls.v3.valueChanges.subscribe((val: boolean) => {
if (val) {
this.form.controls.languageProfile.setValidators([Validators.required, validateProfile]);
} else {
this.form.controls.languageProfile.clearValidators();
}
});

this.formErrors ={
apiKey: {},
Expand All @@ -113,6 +101,7 @@ export class SonarrComponent implements OnInit {
this.languageProfiles = [];
this.rootFolders.push({ path: "Please Select", id: -1 });
this.qualities.push({ name: "Please Select", id: -1 });
this.languageProfiles.push({ name: "Please Select", id: -1 });
}

public getProfiles(form: UntypedFormGroup) {
Expand Down Expand Up @@ -150,9 +139,6 @@ export class SonarrComponent implements OnInit {
this.langRunning = false;
this.notificationService.success("Successfully retrieved the Language Profiles");
});
if (this.form.controls.v3.value) {
this.form.controls.languageProfile.setValidators([Validators.required]);
}
}

public test(form: UntypedFormGroup) {
Expand Down Expand Up @@ -187,7 +173,7 @@ export class SonarrComponent implements OnInit {
this.notificationService.error("Please check your entered values");
}
}
if (form.controls.v3.value && form.controls.languageProfile) {
if (form.controls.languageProfile) {
if (form.controls.languageProfile.value === "Please Select") {
this.notificationService.error("Please check your entered values");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,9 @@ export class AdminRequestDialogComponent implements OnInit {
this.sonarrEnabled = await this.sonarrService.isEnabled();
if (this.sonarrEnabled) {
this.settingsService.getSonarr().subscribe((settings: ISonarrSettings) => {
if (settings.v3) {
this.sonarrService.getV3LanguageProfiles(settings).subscribe((profiles: ILanguageProfiles[]) => {
this.sonarrLanguageProfiles = profiles;
})
}
});
this.sonarrService.getQualityProfilesWithoutSettings().subscribe(c => {
this.sonarrProfiles = c;
Expand Down
16 changes: 8 additions & 8 deletions src/Ombi/Controllers/V1/External/SonarrController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ public SonarrController(ISonarrApi sonarr, ISonarrV3Api sonarrv3, ISettingsServi
/// <returns></returns>
[HttpPost("Profiles")]
[PowerUser]
public async Task<IEnumerable<SonarrProfile>> GetProfiles([FromBody] SonarrSettings settings)
public Task<IEnumerable<SonarrProfile>> GetProfiles([FromBody] SonarrSettings settings)
{
return await SonarrApi.GetProfiles(settings.ApiKey, settings.FullUri);
return SonarrV3Api.GetProfiles(settings.ApiKey, settings.FullUri);
}

/// <summary>
Expand All @@ -46,9 +46,9 @@ public async Task<IEnumerable<SonarrProfile>> GetProfiles([FromBody] SonarrSetti
/// <returns></returns>
[HttpPost("RootFolders")]
[PowerUser]
public async Task<IEnumerable<SonarrRootFolder>> GetRootFolders([FromBody] SonarrSettings settings)
public Task<IEnumerable<SonarrRootFolder>> GetRootFolders([FromBody] SonarrSettings settings)
{
return await SonarrApi.GetRootFolders(settings.ApiKey, settings.FullUri);
return SonarrV3Api.GetRootFolders(settings.ApiKey, settings.FullUri);
}

/// <summary>
Expand All @@ -62,7 +62,7 @@ public async Task<IEnumerable<SonarrProfile>> GetProfiles()
var settings = await SonarrSettings.GetSettingsAsync();
if (settings.Enabled)
{
return await SonarrApi.GetProfiles(settings.ApiKey, settings.FullUri);
return await SonarrV3Api.GetProfiles(settings.ApiKey, settings.FullUri);
}
return null;
}
Expand All @@ -78,7 +78,7 @@ public async Task<IEnumerable<SonarrRootFolder>> GetRootFolders()
var settings = await SonarrSettings.GetSettingsAsync();
if (settings.Enabled)
{
return await SonarrApi.GetRootFolders(settings.ApiKey, settings.FullUri);
return await SonarrV3Api.GetRootFolders(settings.ApiKey, settings.FullUri);
}

return null;
Expand Down Expand Up @@ -110,7 +110,7 @@ public async Task<IEnumerable<LanguageProfiles>> GetLanguageProfiles()
[PowerUser]
public async Task<IEnumerable<Tag>> GetTags([FromBody] SonarrSettings settings)
{
return await SonarrApi.GetTags(settings.ApiKey, settings.FullUri);
return await SonarrV3Api.GetTags(settings.ApiKey, settings.FullUri);
}


Expand All @@ -125,7 +125,7 @@ public async Task<IEnumerable<Tag>> GetTags()
var settings = await SonarrSettings.GetSettingsAsync();
if (settings.Enabled)
{
return await SonarrApi.GetTags(settings.ApiKey, settings.FullUri);
return await SonarrV3Api.GetTags(settings.ApiKey, settings.FullUri);
}

return null;
Expand Down