diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f04d5545..fb2e7fd50 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,26 @@ # Changelog +## (unreleased) + +### **New Features** + +- Added a default set of root folders and qualities for Anime in Sonarr. [Jamie Rees] + +### **Fixes** + +- Fixed #2243 The refresh metadata was being run everytime we launched Ombi... [Jamie] + +- Fixed a issue where the Plex Content Sync wouldn't pick up new shows #2276 #2244 #2261. [Jamie] + +- Sort TvRequests by latest request. [Joe Harvey] + +- Fixed build. [Jamie Rees] + +- Fix newsletter card background overflow when only one item is available. [Anojh] + +- Fix #1745. [Anojh] + + ## v3.0.3330 (2018-05-17) ### **New Features** diff --git a/src/Ombi.Core/Engine/TvRequestEngine.cs b/src/Ombi.Core/Engine/TvRequestEngine.cs index d74b45e5e..ddf84376e 100644 --- a/src/Ombi.Core/Engine/TvRequestEngine.cs +++ b/src/Ombi.Core/Engine/TvRequestEngine.cs @@ -142,7 +142,8 @@ namespace Ombi.Core.Engine .Include(x => x.ChildRequests) .ThenInclude(x => x.SeasonRequests) .ThenInclude(x => x.Episodes) - .Skip(position).Take(count).OrderByDescending(x => x.ReleaseDate).ToListAsync(); + .OrderByDescending(x => x.ChildRequests.Max(y => y.RequestedDate)) + .Skip(position).Take(count).ToListAsync(); // Filter out children @@ -154,7 +155,8 @@ namespace Ombi.Core.Engine .Include(x => x.ChildRequests) .ThenInclude(x => x.SeasonRequests) .ThenInclude(x => x.Episodes) - .Skip(position).Take(count).OrderByDescending(x => x.ReleaseDate).ToListAsync(); + .OrderByDescending(x => x.ChildRequests.Max(y => y.RequestedDate)) + .Skip(position).Take(count).ToListAsync(); } allRequests.ForEach(async r => { await CheckForSubscription(shouldHide, r); }); @@ -172,6 +174,7 @@ namespace Ombi.Core.Engine .Include(x => x.ChildRequests) .ThenInclude(x => x.SeasonRequests) .ThenInclude(x => x.Episodes) + .OrderByDescending(x => x.ChildRequests.Max(y => y.RequestedDate)) .Skip(position).Take(count).ToListAsync(); FilterChildren(allRequests, shouldHide); @@ -182,6 +185,7 @@ namespace Ombi.Core.Engine .Include(x => x.ChildRequests) .ThenInclude(x => x.SeasonRequests) .ThenInclude(x => x.Episodes) + .OrderByDescending(x => x.ChildRequests.Max(y => y.RequestedDate)) .Skip(position).Take(count).ToListAsync(); } diff --git a/src/Ombi.Core/Senders/TvSender.cs b/src/Ombi.Core/Senders/TvSender.cs index cdf834fa5..151ad0f7b 100644 --- a/src/Ombi.Core/Senders/TvSender.cs +++ b/src/Ombi.Core/Senders/TvSender.cs @@ -118,17 +118,31 @@ namespace Ombi.Core.Senders return null; } - int.TryParse(s.QualityProfile, out var qualityToUse); + int qualityToUse; + string rootFolderPath; + + if (model.SeriesType == SeriesType.Anime) + { + // Get the root path from the rootfolder selected. + // For some reason, if we haven't got one use the first root folder in Sonarr + // TODO make this overrideable via the UI + rootFolderPath = await GetSonarrRootPath(model.ParentRequest.RootFolder ?? int.Parse(s.RootPathAnime), s); + int.TryParse(s.QualityProfileAnime, out qualityToUse); + } + else + { + int.TryParse(s.QualityProfile, out qualityToUse); + // Get the root path from the rootfolder selected. + // For some reason, if we haven't got one use the first root folder in Sonarr + // TODO make this overrideable via the UI + rootFolderPath = await GetSonarrRootPath(model.ParentRequest.RootFolder ?? int.Parse(s.RootPath), s); + } if (model.ParentRequest.QualityOverride.HasValue) { qualityToUse = model.ParentRequest.QualityOverride.Value; } - - // Get the root path from the rootfolder selected. - // For some reason, if we haven't got one use the first root folder in Sonarr - // TODO make this overrideable via the UI - var rootFolderPath = await GetSonarrRootPath(model.ParentRequest.RootFolder ?? int.Parse(s.RootPath), s); + try { // Does the series actually exist? @@ -160,13 +174,13 @@ namespace Ombi.Core.Senders // Montitor the correct seasons, // If we have that season in the model then it's monitored! var seasonsToAdd = new List(); - for (var i = 1; i < model.ParentRequest.TotalSeasons + 1; i++) + for (var i = 0; i < model.ParentRequest.TotalSeasons + 1; i++) { var index = i; var season = new Season { seasonNumber = i, - monitored = model.SeasonRequests.Any(x => x.SeasonNumber == index) + monitored = model.SeasonRequests.Any(x => x.SeasonNumber == index && x.SeasonNumber != 0) }; seasonsToAdd.Add(season); } diff --git a/src/Ombi.Schedule/JobSetup.cs b/src/Ombi.Schedule/JobSetup.cs index 44997f272..e24e4bd87 100644 --- a/src/Ombi.Schedule/JobSetup.cs +++ b/src/Ombi.Schedule/JobSetup.cs @@ -68,8 +68,6 @@ namespace Ombi.Schedule RecurringJob.AddOrUpdate(() => _embyUserImporter.Start(), JobSettingsHelper.UserImporter(s)); RecurringJob.AddOrUpdate(() => _plexUserImporter.Start(), JobSettingsHelper.UserImporter(s)); RecurringJob.AddOrUpdate(() => _newsletter.Start(), JobSettingsHelper.Newsletter(s)); - - BackgroundJob.Enqueue(() => _refreshMetadata.Start()); } diff --git a/src/Ombi.Schedule/Jobs/Ombi/HtmlTemplateGenerator.cs b/src/Ombi.Schedule/Jobs/Ombi/HtmlTemplateGenerator.cs index a28133bc2..51e920b15 100644 --- a/src/Ombi.Schedule/Jobs/Ombi/HtmlTemplateGenerator.cs +++ b/src/Ombi.Schedule/Jobs/Ombi/HtmlTemplateGenerator.cs @@ -7,7 +7,7 @@ namespace Ombi.Schedule.Jobs.Ombi protected virtual void AddBackgroundInsideTable(StringBuilder sb, string url) { sb.Append(""); - sb.AppendFormat("", url); + sb.AppendFormat("
", url); sb.Append(""); sb.Append("
"); sb.Append(""); diff --git a/src/Ombi.Schedule/Jobs/Plex/PlexContentSync.cs b/src/Ombi.Schedule/Jobs/Plex/PlexContentSync.cs index 95cd3ba38..57804d0f3 100644 --- a/src/Ombi.Schedule/Jobs/Plex/PlexContentSync.cs +++ b/src/Ombi.Schedule/Jobs/Plex/PlexContentSync.cs @@ -119,7 +119,7 @@ namespace Ombi.Schedule.Jobs.Plex { try { - Logger.LogInformation("Starting to cache the content on server {0}", servers.Name); + Logger.LogInformation("Starting to cache the content on server {0}", servers.Name); if (recentlyAddedSearch) { @@ -162,8 +162,10 @@ namespace Ombi.Schedule.Jobs.Plex if (content.viewGroup.Equals(PlexMediaType.Episode.ToString(), StringComparison.CurrentCultureIgnoreCase)) { Logger.LogInformation("Found some episodes, this must be a recently added sync"); + var count = 0; foreach (var epInfo in content.Metadata) { + count++; var grandParentKey = epInfo.grandparentRatingKey; // Lookup the rating key var showMetadata = await PlexApi.GetMetadata(servers.PlexAuthToken, servers.FullUri, grandParentKey); @@ -174,18 +176,59 @@ namespace Ombi.Schedule.Jobs.Plex } await ProcessTvShow(servers, show, contentToAdd, recentlyAddedSearch, processedContent); + if (contentToAdd.Any()) + { + await Repo.AddRange(contentToAdd, false); + if (recentlyAddedSearch) + { + foreach (var plexServerContent in contentToAdd) + { + processedContent.Add(plexServerContent.Id); + } + } + contentToAdd.Clear(); + } + if (count > 200) + { + await Repo.SaveChangesAsync(); + + } } + // Save just to make sure we don't leave anything hanging + await Repo.SaveChangesAsync(); + await EpisodeSync.ProcessEpsiodes(content.Metadata, allEps); } if (content.viewGroup.Equals(PlexMediaType.Show.ToString(), StringComparison.CurrentCultureIgnoreCase)) { // Process Shows Logger.LogInformation("Processing TV Shows"); + var count = 0; foreach (var show in content.Metadata ?? new Metadata[] { }) { + count++; await ProcessTvShow(servers, show, contentToAdd, recentlyAddedSearch, processedContent); + + if (contentToAdd.Any()) + { + await Repo.AddRange(contentToAdd, false); + if (recentlyAddedSearch) + { + foreach (var plexServerContent in contentToAdd) + { + processedContent.Add(plexServerContent.Id); + } + } + contentToAdd.Clear(); + } + if (count > 200) + { + await Repo.SaveChangesAsync(); + } } + + await Repo.SaveChangesAsync(); } if (content.viewGroup.Equals(PlexMediaType.Movie.ToString(), StringComparison.CurrentCultureIgnoreCase)) { @@ -464,21 +507,6 @@ namespace Ombi.Schedule.Jobs.Plex show.title); } } - - if (contentToAdd.Count > 500 || recentlyAdded) - { - await Repo.AddRange(contentToAdd); - foreach (var plexServerContent in contentToAdd) - { - contentProcessed.Add(plexServerContent.Id); - } - contentToAdd.Clear(); - } - - if (contentToAdd.Any()) - { - await Repo.AddRange(contentToAdd); - } } /// diff --git a/src/Ombi.Settings/Settings/Models/External/SonarrSettings.cs b/src/Ombi.Settings/Settings/Models/External/SonarrSettings.cs index 789b8f384..0c7e17900 100644 --- a/src/Ombi.Settings/Settings/Models/External/SonarrSettings.cs +++ b/src/Ombi.Settings/Settings/Models/External/SonarrSettings.cs @@ -13,6 +13,10 @@ /// The root path. /// public string RootPath { get; set; } + + + public string QualityProfileAnime { get; set; } + public string RootPathAnime { get; set; } public bool AddOnly { get; set; } } } \ No newline at end of file diff --git a/src/Ombi.Store/Repository/IRepository.cs b/src/Ombi.Store/Repository/IRepository.cs index c85b45d8f..810b586a3 100644 --- a/src/Ombi.Store/Repository/IRepository.cs +++ b/src/Ombi.Store/Repository/IRepository.cs @@ -14,7 +14,7 @@ namespace Ombi.Store.Repository Task Find(object key); IQueryable GetAll(); Task FirstOrDefaultAsync(Expression> predicate); - Task AddRange(IEnumerable content); + Task AddRange(IEnumerable content, bool save = true); Task Add(T content); Task DeleteRange(IEnumerable req); Task Delete(T request); diff --git a/src/Ombi.Store/Repository/Repository.cs b/src/Ombi.Store/Repository/Repository.cs index 049da0356..8c07c2371 100644 --- a/src/Ombi.Store/Repository/Repository.cs +++ b/src/Ombi.Store/Repository/Repository.cs @@ -35,10 +35,13 @@ namespace Ombi.Store.Repository return await _db.FirstOrDefaultAsync(predicate); } - public async Task AddRange(IEnumerable content) + public async Task AddRange(IEnumerable content, bool save = true) { _db.AddRange(content); - await _ctx.SaveChangesAsync(); + if (save) + { + await _ctx.SaveChangesAsync(); + } } public async Task Add(T content) diff --git a/src/Ombi/ClientApp/app/interfaces/ISettings.ts b/src/Ombi/ClientApp/app/interfaces/ISettings.ts index 8e7fdbe1c..dc1825c83 100644 --- a/src/Ombi/ClientApp/app/interfaces/ISettings.ts +++ b/src/Ombi/ClientApp/app/interfaces/ISettings.ts @@ -65,8 +65,10 @@ export interface ISonarrSettings extends IExternalSettings { apiKey: string; enabled: boolean; qualityProfile: string; + qualityProfileAnime: string; seasonFolders: boolean; rootPath: string; + rootPathAnime: string; fullRootPath: string; addOnly: boolean; } diff --git a/src/Ombi/ClientApp/app/settings/sonarr/sonarr.component.html b/src/Ombi/ClientApp/app/settings/sonarr/sonarr.component.html index e041ab0d0..6a419feab 100644 --- a/src/Ombi/ClientApp/app/settings/sonarr/sonarr.component.html +++ b/src/Ombi/ClientApp/app/settings/sonarr/sonarr.component.html @@ -68,6 +68,14 @@ A Default Quality Profile is required +
+ +
+ +
+
@@ -85,6 +93,15 @@ A Default Root Path is required
+
+ +
+ +
+ +
diff --git a/src/Ombi/ClientApp/app/settings/sonarr/sonarr.component.ts b/src/Ombi/ClientApp/app/settings/sonarr/sonarr.component.ts index bb69760ef..03fadb2b7 100644 --- a/src/Ombi/ClientApp/app/settings/sonarr/sonarr.component.ts +++ b/src/Ombi/ClientApp/app/settings/sonarr/sonarr.component.ts @@ -15,7 +15,9 @@ import { SettingsService } from "../../services"; export class SonarrComponent implements OnInit { public qualities: ISonarrProfile[]; + public qualitiesAnime: ISonarrProfile[]; public rootFolders: ISonarrRootFolder[]; + public rootFoldersAnime: ISonarrRootFolder[]; public selectedRootFolder: ISonarrRootFolder; public selectedQuality: ISonarrProfile; public profilesRunning: boolean; @@ -37,6 +39,8 @@ export class SonarrComponent implements OnInit { apiKey: [x.apiKey, [Validators.required]], qualityProfile: [x.qualityProfile, [Validators.required]], rootPath: [x.rootPath, [Validators.required]], + qualityProfileAnime: [x.qualityProfileAnime], + rootPathAnime: [x.rootPathAnime], ssl: [x.ssl], subDir: [x.subDir], ip: [x.ip, [Validators.required]], @@ -64,6 +68,7 @@ export class SonarrComponent implements OnInit { .subscribe(x => { this.qualities = x; this.qualities.unshift({ name: "Please Select", id: -1 }); + this.qualitiesAnime = x; this.profilesRunning = false; this.notificationService.success("Successfully retrieved the Quality Profiles"); @@ -76,6 +81,7 @@ export class SonarrComponent implements OnInit { .subscribe(x => { this.rootFolders = x; this.rootFolders.unshift({ path: "Please Select", id: -1 }); + this.rootFoldersAnime = x; this.rootFoldersRunning = false; this.notificationService.success("Successfully retrieved the Root Folders");