diff --git a/CHANGELOG.md b/CHANGELOG.md index 8bfe7e633..ecb1a790d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,30 @@ ### **New Features** +- Added a new Job. Plex Recently Added, this is a slimmed down version of the Plex Sync job, this will just scan the recently added list and not the whole library. I'd reccomend running this very regulary and the full scan not as regular. [Jamie] + +### **Fixes** + +- Add web-app-capable for IOS and Android. [Thomas] + +- Fixed the bug where the newsletter CRON was not appearing on the job settings page. [Jamie] + +- Add base url as a startup argument #2153. [Jamie Rees] + +- Fixed a bug with the RefreshMetadata where we would never get TheMovieDBId's if it was missing it. [Jamie] + + +## v3.0.3173 (2018-04-12) + +### **Fixes** + +- Removed some early disposition that seemed to be causing errors in the API. [Jamie] + + +## v3.0.3164 (2018-04-10) + +### **New Features** + - Added the ability to send newsletter out to users that are not in Ombi. [Jamie] - Added the ability to turn off TV or Movies from the newsletter. [Jamie] @@ -56,6 +80,12 @@ - Fixed the issue where movies were not appearing in the newsletter for users with Emby #2111. [Jamie] +- The fact that this button has another style really bothers me. [Louis Laureys] + +- Fix discord current user count. [Avi] + +- Fix broken images and new discord invite. [Avi] + ## v3.0.3111 (2018-03-27) diff --git a/src/Ombi.Api.Plex/IPlexApi.cs b/src/Ombi.Api.Plex/IPlexApi.cs index e11d6d914..0734262cf 100644 --- a/src/Ombi.Api.Plex/IPlexApi.cs +++ b/src/Ombi.Api.Plex/IPlexApi.cs @@ -19,5 +19,6 @@ namespace Ombi.Api.Plex Task GetAllEpisodes(string authToken, string host, string section, int start, int retCount); Task GetUsers(string authToken); Task GetAccount(string authToken); + Task GetRecentlyAdded(string authToken, string uri, string sectionId); } } \ No newline at end of file diff --git a/src/Ombi.Api.Plex/Models/Metadata.cs b/src/Ombi.Api.Plex/Models/Metadata.cs index 28bdf002d..dcde62818 100644 --- a/src/Ombi.Api.Plex/Models/Metadata.cs +++ b/src/Ombi.Api.Plex/Models/Metadata.cs @@ -23,8 +23,8 @@ namespace Ombi.Api.Plex.Models public int leafCount { get; set; } public int viewedLeafCount { get; set; } public int childCount { get; set; } - public long addedAt { get; set; } - public int updatedAt { get; set; } + //public long addedAt { get; set; } + //public int updatedAt { get; set; } public Genre[] Genre { get; set; } //public Role[] Role { get; set; } public string primaryExtraKey { get; set; } diff --git a/src/Ombi.Api.Plex/PlexApi.cs b/src/Ombi.Api.Plex/PlexApi.cs index b5c6b958d..e6c52d1df 100644 --- a/src/Ombi.Api.Plex/PlexApi.cs +++ b/src/Ombi.Api.Plex/PlexApi.cs @@ -147,6 +147,15 @@ namespace Ombi.Api.Plex return await Api.Request(request); } + public async Task GetRecentlyAdded(string authToken, string uri, string sectionId) + { + var request = new Request($"library/sections/{sectionId}/recentlyAdded", uri, HttpMethod.Get); + AddHeaders(request, authToken); + AddLimitHeaders(request, 0, 50); + + return await Api.Request(request); + } + /// /// Adds the required headers and also the authorization header /// diff --git a/src/Ombi.DependencyInjection/IocExtensions.cs b/src/Ombi.DependencyInjection/IocExtensions.cs index 92ecf8282..e2f667465 100644 --- a/src/Ombi.DependencyInjection/IocExtensions.cs +++ b/src/Ombi.DependencyInjection/IocExtensions.cs @@ -175,6 +175,7 @@ namespace Ombi.DependencyInjection services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); } } } diff --git a/src/Ombi.Helpers/OmbiRoles.cs b/src/Ombi.Helpers/OmbiRoles.cs index e7527279d..ba8c8d087 100644 --- a/src/Ombi.Helpers/OmbiRoles.cs +++ b/src/Ombi.Helpers/OmbiRoles.cs @@ -2,6 +2,8 @@ { public static class OmbiRoles { + // DONT FORGET TO ADD TO IDENTITYCONTROLLER.CREATEROLES AND THE UI! + public const string Admin = nameof(Admin); public const string AutoApproveMovie = nameof(AutoApproveMovie); public const string AutoApproveTv = nameof(AutoApproveTv); diff --git a/src/Ombi.Schedule/JobSetup.cs b/src/Ombi.Schedule/JobSetup.cs index b328e6daf..1e78d226c 100644 --- a/src/Ombi.Schedule/JobSetup.cs +++ b/src/Ombi.Schedule/JobSetup.cs @@ -19,7 +19,7 @@ namespace Ombi.Schedule IOmbiAutomaticUpdater updater, IEmbyContentSync embySync, IPlexUserImporter userImporter, IEmbyUserImporter embyUserImporter, ISonarrSync cache, ICouchPotatoSync cpCache, ISettingsService jobsettings, ISickRageSync srSync, IRefreshMetadata refresh, - INewsletterJob newsletter) + INewsletterJob newsletter, IPlexRecentlyAddedSync recentlyAddedSync) { _plexContentSync = plexContentSync; _radarrSync = radarrSync; @@ -33,6 +33,7 @@ namespace Ombi.Schedule _srSync = srSync; _refreshMetadata = refresh; _newsletter = newsletter; + _plexRecentlyAddedSync = recentlyAddedSync; } private readonly IPlexContentSync _plexContentSync; @@ -47,6 +48,7 @@ namespace Ombi.Schedule private readonly ISettingsService _jobSettings; private readonly IRefreshMetadata _refreshMetadata; private readonly INewsletterJob _newsletter; + private readonly IPlexRecentlyAddedSync _plexRecentlyAddedSync; public void Setup() { @@ -55,7 +57,8 @@ namespace Ombi.Schedule RecurringJob.AddOrUpdate(() => _embyContentSync.Start(), JobSettingsHelper.EmbyContent(s)); RecurringJob.AddOrUpdate(() => _sonarrSync.Start(), JobSettingsHelper.Sonarr(s)); RecurringJob.AddOrUpdate(() => _radarrSync.CacheContent(), JobSettingsHelper.Radarr(s)); - RecurringJob.AddOrUpdate(() => _plexContentSync.CacheContent(), JobSettingsHelper.PlexContent(s)); + RecurringJob.AddOrUpdate(() => _plexContentSync.CacheContent(false), JobSettingsHelper.PlexContent(s)); + RecurringJob.AddOrUpdate(() => _plexContentSync.CacheContent(true), JobSettingsHelper.PlexRecentlyAdded(s)); RecurringJob.AddOrUpdate(() => _cpCache.Start(), JobSettingsHelper.CouchPotato(s)); RecurringJob.AddOrUpdate(() => _srSync.Start(), JobSettingsHelper.SickRageSync(s)); RecurringJob.AddOrUpdate(() => _refreshMetadata.Start(), JobSettingsHelper.RefreshMetadata(s)); diff --git a/src/Ombi.Schedule/Jobs/Ombi/RefreshMetadata.cs b/src/Ombi.Schedule/Jobs/Ombi/RefreshMetadata.cs index 9d073facf..9b7726a15 100644 --- a/src/Ombi.Schedule/Jobs/Ombi/RefreshMetadata.cs +++ b/src/Ombi.Schedule/Jobs/Ombi/RefreshMetadata.cs @@ -80,7 +80,7 @@ namespace Ombi.Schedule.Jobs.Ombi if (!hasTheMovieDb) { - var id = await GetTheMovieDbId(hasTvDbId, hasImdb, show.TvDbId, show.ImdbId, show.Title); + var id = await GetTheMovieDbId(hasTvDbId, hasImdb, show.TvDbId, show.ImdbId, show.Title, false); show.TheMovieDbId = id; } @@ -120,7 +120,7 @@ namespace Ombi.Schedule.Jobs.Ombi if (!hasTheMovieDb) { - var id = await GetTheMovieDbId(hasTvDbId, hasImdb, show.TvDbId, show.ImdbId, show.Title); + var id = await GetTheMovieDbId(hasTvDbId, hasImdb, show.TvDbId, show.ImdbId, show.Title, false); show.TheMovieDbId = id; } @@ -166,7 +166,7 @@ namespace Ombi.Schedule.Jobs.Ombi } if (!hasTheMovieDb) { - var id = await GetTheMovieDbId(false, hasImdb, string.Empty, movie.ImdbId, movie.Title); + var id = await GetTheMovieDbId(false, hasImdb, string.Empty, movie.ImdbId, movie.Title, true); movie.TheMovieDbId = id; _plexRepo.UpdateWithoutSave(movie); } @@ -200,7 +200,7 @@ namespace Ombi.Schedule.Jobs.Ombi } if (!hasTheMovieDb) { - var id = await GetTheMovieDbId(false, hasImdb, string.Empty, movie.ImdbId, movie.Title); + var id = await GetTheMovieDbId(false, hasImdb, string.Empty, movie.ImdbId, movie.Title, true); movie.TheMovieDbId = id; _embyRepo.UpdateWithoutSave(movie); } @@ -215,7 +215,7 @@ namespace Ombi.Schedule.Jobs.Ombi await _embyRepo.SaveChangesAsync(); } - private async Task GetTheMovieDbId(bool hasTvDbId, bool hasImdb, string tvdbID, string imdbId, string title) + private async Task GetTheMovieDbId(bool hasTvDbId, bool hasImdb, string tvdbID, string imdbId, string title, bool movie) { _log.LogInformation("The Media item {0} does not have a TheMovieDbId, searching for TheMovieDbId", title); FindResult result = null; @@ -230,13 +230,29 @@ namespace Ombi.Schedule.Jobs.Ombi if (hasImdb && !hasResult) { result = await _movieApi.Find(imdbId, ExternalSource.imdb_id); - hasResult = result?.tv_results?.Length > 0; + if (movie) + { + hasResult = result?.movie_results?.Length > 0; + } + else + { + hasResult = result?.tv_results?.Length > 0; + + } _log.LogInformation("Setting Show {0} because we have ImdbId, result: {1}", title, hasResult); } if (hasResult) { - return result.tv_results?[0]?.id.ToString() ?? string.Empty; + if (movie) + { + return result.movie_results?[0]?.id.ToString() ?? string.Empty; + } + else + { + + return result.tv_results?[0]?.id.ToString() ?? string.Empty; + } } return string.Empty; } diff --git a/src/Ombi.Schedule/Jobs/Plex/Interfaces/IPlexContentSync.cs b/src/Ombi.Schedule/Jobs/Plex/Interfaces/IPlexContentSync.cs index a9fadae9d..17a8bbb4f 100644 --- a/src/Ombi.Schedule/Jobs/Plex/Interfaces/IPlexContentSync.cs +++ b/src/Ombi.Schedule/Jobs/Plex/Interfaces/IPlexContentSync.cs @@ -4,6 +4,6 @@ namespace Ombi.Schedule.Jobs { public interface IPlexContentSync : IBaseJob { - Task CacheContent(); + Task CacheContent(bool recentlyAddedSearch = false); } } \ No newline at end of file diff --git a/src/Ombi.Schedule/Jobs/Plex/Interfaces/IPlexRecentlyAddedSync.cs b/src/Ombi.Schedule/Jobs/Plex/Interfaces/IPlexRecentlyAddedSync.cs new file mode 100644 index 000000000..6616f29bc --- /dev/null +++ b/src/Ombi.Schedule/Jobs/Plex/Interfaces/IPlexRecentlyAddedSync.cs @@ -0,0 +1,9 @@ +using System.Threading.Tasks; + +namespace Ombi.Schedule.Jobs.Plex +{ + public interface IPlexRecentlyAddedSync : IBaseJob + { + Task Start(); + } +} \ No newline at end of file diff --git a/src/Ombi.Schedule/Jobs/Plex/PlexContentSync.cs b/src/Ombi.Schedule/Jobs/Plex/PlexContentSync.cs index 3c00a7a29..0292b6b54 100644 --- a/src/Ombi.Schedule/Jobs/Plex/PlexContentSync.cs +++ b/src/Ombi.Schedule/Jobs/Plex/PlexContentSync.cs @@ -62,7 +62,7 @@ namespace Ombi.Schedule.Jobs.Plex private IPlexContentRepository Repo { get; } private IPlexEpisodeSync EpisodeSync { get; } - public async Task CacheContent() + public async Task CacheContent(bool recentlyAddedSearch = false) { var plexSettings = await Plex.GetSettingsAsync(); if (!plexSettings.Enable) @@ -78,7 +78,7 @@ namespace Ombi.Schedule.Jobs.Plex Logger.LogInformation("Starting Plex Content Cacher"); try { - await StartTheCache(plexSettings); + await StartTheCache(plexSettings, recentlyAddedSearch); } catch (Exception e) { @@ -89,14 +89,14 @@ namespace Ombi.Schedule.Jobs.Plex BackgroundJob.Enqueue(() => EpisodeSync.Start()); } - private async Task StartTheCache(PlexSettings plexSettings) + private async Task StartTheCache(PlexSettings plexSettings, bool recentlyAddedSearch) { foreach (var servers in plexSettings.Servers ?? new List()) { try { Logger.LogInformation("Starting to cache the content on server {0}", servers.Name); - await ProcessServer(servers); + await ProcessServer(servers, recentlyAddedSearch); } catch (Exception e) { @@ -105,10 +105,10 @@ namespace Ombi.Schedule.Jobs.Plex } } - private async Task ProcessServer(PlexServers servers) + private async Task ProcessServer(PlexServers servers, bool recentlyAddedSearch) { Logger.LogInformation("Getting all content from server {0}", servers.Name); - var allContent = await GetAllContent(servers); + var allContent = await GetAllContent(servers, recentlyAddedSearch); Logger.LogInformation("We found {0} items", allContent.Count); // Let's now process this. @@ -388,8 +388,9 @@ namespace Ombi.Schedule.Jobs.Plex /// If they have not set the settings then we will monitor them all /// /// The plex settings. + /// /// - private async Task> GetAllContent(PlexServers plexSettings) + private async Task> GetAllContent(PlexServers plexSettings, bool recentlyAddedSearch) { var sections = await PlexApi.GetLibrarySections(plexSettings.PlexAuthToken, plexSettings.FullUri); @@ -413,10 +414,23 @@ namespace Ombi.Schedule.Jobs.Plex } } } - var lib = await PlexApi.GetLibrary(plexSettings.PlexAuthToken, plexSettings.FullUri, dir.key); - if (lib != null) + + if (recentlyAddedSearch) { - libs.Add(lib.MediaContainer); + var container = await PlexApi.GetRecentlyAdded(plexSettings.PlexAuthToken, plexSettings.FullUri, + dir.key); + if (container != null) + { + libs.Add(container.MediaContainer); + } + } + else + { + var lib = await PlexApi.GetLibrary(plexSettings.PlexAuthToken, plexSettings.FullUri, dir.key); + if (lib != null) + { + libs.Add(lib.MediaContainer); + } } } } diff --git a/src/Ombi.Schedule/Jobs/Plex/PlexRecentlyAddedSync.cs b/src/Ombi.Schedule/Jobs/Plex/PlexRecentlyAddedSync.cs new file mode 100644 index 000000000..dfcb9cac1 --- /dev/null +++ b/src/Ombi.Schedule/Jobs/Plex/PlexRecentlyAddedSync.cs @@ -0,0 +1,40 @@ +using System; +using System.Threading.Tasks; +using Ombi.Api.Plex; + +namespace Ombi.Schedule.Jobs.Plex +{ + public class PlexRecentlyAddedSync : IPlexRecentlyAddedSync + { + public PlexRecentlyAddedSync(IPlexContentSync contentSync) + { + _sync = contentSync; + } + + private readonly IPlexContentSync _sync; + + public async Task Start() + { + await _sync.CacheContent(true); + } + + private bool _disposed; + protected virtual void Dispose(bool disposing) + { + if (_disposed) + return; + + if (disposing) + { + _sync?.Dispose(); + } + _disposed = true; + } + + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + } +} \ No newline at end of file diff --git a/src/Ombi.Settings/Settings/Models/JobSettings.cs b/src/Ombi.Settings/Settings/Models/JobSettings.cs index a68ceb8bb..bb536a685 100644 --- a/src/Ombi.Settings/Settings/Models/JobSettings.cs +++ b/src/Ombi.Settings/Settings/Models/JobSettings.cs @@ -6,6 +6,7 @@ public string SonarrSync { get; set; } public string RadarrSync { get; set; } public string PlexContentSync { get; set; } + public string PlexRecentlyAddedSync { get; set; } public string CouchPotatoSync { get; set; } public string AutomaticUpdater { get; set; } public string UserImporter { get; set; } diff --git a/src/Ombi.Settings/Settings/Models/JobSettingsHelper.cs b/src/Ombi.Settings/Settings/Models/JobSettingsHelper.cs index db4083fcd..c4fcb8ceb 100644 --- a/src/Ombi.Settings/Settings/Models/JobSettingsHelper.cs +++ b/src/Ombi.Settings/Settings/Models/JobSettingsHelper.cs @@ -21,7 +21,11 @@ namespace Ombi.Settings.Settings.Models } public static string PlexContent(JobSettings s) { - return Get(s.PlexContentSync, Cron.Hourly(20)); + return Get(s.PlexContentSync, Cron.HourInterval(6)); + } + public static string PlexRecentlyAdded(JobSettings s) + { + return Get(s.PlexRecentlyAddedSync, Cron.Hourly(0)); } public static string CouchPotato(JobSettings s) { @@ -49,7 +53,6 @@ namespace Ombi.Settings.Settings.Models return Get(s.RefreshMetadata, Cron.Daily(3)); } - private static string Get(string settings, string defaultCron) { return settings.HasValue() ? settings : defaultCron; diff --git a/src/Ombi.Store/Entities/ApplicationConfiguration.cs b/src/Ombi.Store/Entities/ApplicationConfiguration.cs index 1499ca34f..809264312 100644 --- a/src/Ombi.Store/Entities/ApplicationConfiguration.cs +++ b/src/Ombi.Store/Entities/ApplicationConfiguration.cs @@ -17,5 +17,6 @@ namespace Ombi.Store.Entities TheMovieDb = 4, StoragePath = 5, Notification = 6, + BaseUrl=7, } } \ No newline at end of file diff --git a/src/Ombi/ClientApp/app/interfaces/ISettings.ts b/src/Ombi/ClientApp/app/interfaces/ISettings.ts index 1ce3778ec..d67ebc698 100644 --- a/src/Ombi/ClientApp/app/interfaces/ISettings.ts +++ b/src/Ombi/ClientApp/app/interfaces/ISettings.ts @@ -128,6 +128,7 @@ export interface IJobSettings { sickRageSync: string; refreshMetadata: string; newsletter: string; + plexRecentlyAddedSync: string; } export interface IIssueSettings extends ISettings { diff --git a/src/Ombi/ClientApp/app/services/job.service.ts b/src/Ombi/ClientApp/app/services/job.service.ts index 79957af97..2fe940316 100644 --- a/src/Ombi/ClientApp/app/services/job.service.ts +++ b/src/Ombi/ClientApp/app/services/job.service.ts @@ -35,6 +35,10 @@ export class JobService extends ServiceHelpers { return this.http.post(`${this.url}plexcontentcacher/`, {headers: this.headers}); } + public runPlexRecentlyAddedCacher(): Observable { + return this.http.post(`${this.url}plexrecentlyadded/`, {headers: this.headers}); + } + public runEmbyCacher(): Observable { return this.http.post(`${this.url}embycontentcacher/`, {headers: this.headers}); } diff --git a/src/Ombi/ClientApp/app/settings/jobs/jobs.component.html b/src/Ombi/ClientApp/app/settings/jobs/jobs.component.html index 0d8b85930..72b78a64d 100644 --- a/src/Ombi/ClientApp/app/settings/jobs/jobs.component.html +++ b/src/Ombi/ClientApp/app/settings/jobs/jobs.component.html @@ -57,6 +57,12 @@ The Plex Sync is required +
+ + + The Plex Sync is required + +
diff --git a/src/Ombi/ClientApp/app/settings/jobs/jobs.component.ts b/src/Ombi/ClientApp/app/settings/jobs/jobs.component.ts index 5978e7ab2..d0a7a8b83 100644 --- a/src/Ombi/ClientApp/app/settings/jobs/jobs.component.ts +++ b/src/Ombi/ClientApp/app/settings/jobs/jobs.component.ts @@ -33,6 +33,7 @@ export class JobsComponent implements OnInit { sickRageSync: [x.sickRageSync, Validators.required], refreshMetadata: [x.refreshMetadata, Validators.required], newsletter: [x.newsletter, Validators.required], + plexRecentlyAddedSync: [x.plexRecentlyAddedSync, Validators.required], }); }); } diff --git a/src/Ombi/ClientApp/app/settings/plex/plex.component.html b/src/Ombi/ClientApp/app/settings/plex/plex.component.html index 6beaa3fea..6310a9cf1 100644 --- a/src/Ombi/ClientApp/app/settings/plex/plex.component.html +++ b/src/Ombi/ClientApp/app/settings/plex/plex.component.html @@ -171,19 +171,26 @@
-
+
-
-
-
- -
+
+
+
+
+
+
+
+
+ +
+
+
diff --git a/src/Ombi/ClientApp/app/settings/plex/plex.component.ts b/src/Ombi/ClientApp/app/settings/plex/plex.component.ts index 61b57b393..23bd74225 100644 --- a/src/Ombi/ClientApp/app/settings/plex/plex.component.ts +++ b/src/Ombi/ClientApp/app/settings/plex/plex.component.ts @@ -121,7 +121,15 @@ export class PlexComponent implements OnInit, OnDestroy { public runCacher(): void { this.jobService.runPlexCacher().subscribe(x => { if(x) { - this.notificationService.success("Triggered the Plex Content Cacher"); + this.notificationService.success("Triggered the Plex Full Sync"); + } + }); + } + + public runRecentlyAddedCacher(): void { + this.jobService.runPlexRecentlyAddedCacher().subscribe(x => { + if(x) { + this.notificationService.success("Triggered the Plex Recently Added Sync"); } }); } diff --git a/src/Ombi/Controllers/IdentityController.cs b/src/Ombi/Controllers/IdentityController.cs index 6a8aee52c..5db5f2168 100644 --- a/src/Ombi/Controllers/IdentityController.cs +++ b/src/Ombi/Controllers/IdentityController.cs @@ -194,6 +194,7 @@ namespace Ombi.Controllers await CreateRole(OmbiRoles.RequestMovie); await CreateRole(OmbiRoles.RequestTv); await CreateRole(OmbiRoles.Disabled); + await CreateRole(OmbiRoles.RecievesNewsletter); } private async Task CreateRole(string role) diff --git a/src/Ombi/Controllers/JobController.cs b/src/Ombi/Controllers/JobController.cs index 76ca42c41..a89346250 100644 --- a/src/Ombi/Controllers/JobController.cs +++ b/src/Ombi/Controllers/JobController.cs @@ -117,7 +117,18 @@ namespace Ombi.Controllers [HttpPost("plexcontentcacher")] public bool StartPlexContentCacher() { - BackgroundJob.Enqueue(() => _plexContentSync.CacheContent()); + BackgroundJob.Enqueue(() => _plexContentSync.CacheContent(false)); + return true; + } + + /// + /// Runs a smaller version of the content cacher + /// + /// + [HttpPost("plexrecentlyadded")] + public bool StartRecentlyAdded() + { + BackgroundJob.Enqueue(() => _plexContentSync.CacheContent(true)); return true; } diff --git a/src/Ombi/Controllers/SettingsController.cs b/src/Ombi/Controllers/SettingsController.cs index 9ffa9d81f..30469cd57 100644 --- a/src/Ombi/Controllers/SettingsController.cs +++ b/src/Ombi/Controllers/SettingsController.cs @@ -473,6 +473,8 @@ namespace Ombi.Controllers j.UserImporter = j.UserImporter.HasValue() ? j.UserImporter : JobSettingsHelper.UserImporter(j); j.SickRageSync = j.SickRageSync.HasValue() ? j.SickRageSync : JobSettingsHelper.SickRageSync(j); j.RefreshMetadata = j.RefreshMetadata.HasValue() ? j.RefreshMetadata : JobSettingsHelper.RefreshMetadata(j); + j.PlexRecentlyAddedSync = j.PlexRecentlyAddedSync.HasValue() ? j.PlexRecentlyAddedSync : JobSettingsHelper.PlexRecentlyAdded(j); + j.Newsletter = j.Newsletter.HasValue() ? j.Newsletter : JobSettingsHelper.Newsletter(j); return j; } diff --git a/src/Ombi/Program.cs b/src/Ombi/Program.cs index 9ced1715e..9294852f9 100644 --- a/src/Ombi/Program.cs +++ b/src/Ombi/Program.cs @@ -23,11 +23,13 @@ namespace Ombi var host = string.Empty; var storagePath = string.Empty; + var baseUrl = string.Empty; var result = Parser.Default.ParseArguments(args) .WithParsed(o => { host = o.Host; storagePath = o.StoragePath; + baseUrl = o.BaseUrl; }).WithNotParsed(err => { foreach (var e in err) @@ -47,6 +49,7 @@ namespace Ombi { var config = ctx.ApplicationConfigurations.ToList(); var url = config.FirstOrDefault(x => x.Type == ConfigurationTypes.Url); + var dbBaseUrl = config.FirstOrDefault(x => x.Type == ConfigurationTypes.BaseUrl); if (url == null) { url = new ApplicationConfiguration @@ -65,6 +68,25 @@ namespace Ombi ctx.SaveChanges(); urlValue = url.Value; } + + if (dbBaseUrl == null) + { + if (baseUrl.HasValue() && baseUrl.StartsWith("/")) + { + dbBaseUrl = new ApplicationConfiguration + { + Type = ConfigurationTypes.BaseUrl, + Value = baseUrl + }; + ctx.ApplicationConfigurations.Add(dbBaseUrl); + ctx.SaveChanges(); + } + } + else if(!baseUrl.Equals(dbBaseUrl.Value)) + { + dbBaseUrl.Value = baseUrl; + ctx.SaveChanges(); + } } DeleteSchedulesDb(); @@ -118,5 +140,8 @@ namespace Ombi [Option("storage", Required = false, HelpText = "Storage path, where we save the logs and database")] public string StoragePath { get; set; } + [Option("baseurl", Required = false, HelpText = "The base URL for reverse proxy scenarios")] + public string BaseUrl { get; set; } + } } diff --git a/src/Ombi/Startup.cs b/src/Ombi/Startup.cs index 4aaadacb6..7fc0522ed 100644 --- a/src/Ombi/Startup.cs +++ b/src/Ombi/Startup.cs @@ -32,6 +32,7 @@ using Ombi.Schedule; using Ombi.Settings.Settings.Models; using Ombi.Store.Context; using Ombi.Store.Entities; +using Ombi.Store.Repository; using Serilog; using Serilog.Events; @@ -176,6 +177,22 @@ namespace Ombi { app.UsePathBase(settings.BaseUrl); } + else + { + // Check if it's in the startup args + var appConfig = serviceProvider.GetService(); + var baseUrl = appConfig.Get(ConfigurationTypes.BaseUrl).Result; + if (baseUrl != null) + { + if (baseUrl.Value.HasValue()) + { + settings.BaseUrl = baseUrl.Value; + ombiService.SaveSettings(settings); + + app.UsePathBase(settings.BaseUrl); + } + } + } app.UseHangfireServer(new BackgroundJobServerOptions { WorkerCount = 1, ServerTimeout = TimeSpan.FromDays(1), ShutdownTimeout = TimeSpan.FromDays(1)}); app.UseHangfireDashboard(settings.BaseUrl.HasValue() ? $"{settings.BaseUrl}/hangfire" : "/hangfire", diff --git a/src/Ombi/Views/Shared/_Layout.cshtml b/src/Ombi/Views/Shared/_Layout.cshtml index cafd75357..cb9985bac 100644 --- a/src/Ombi/Views/Shared/_Layout.cshtml +++ b/src/Ombi/Views/Shared/_Layout.cshtml @@ -75,6 +75,8 @@ O:::::::OOO:::::::Om::::m m::::m m::::mb:::::bbbbbb::::::bi::::::i + +