diff --git a/src/Ombi.Api/Api.cs b/src/Ombi.Api/Api.cs index a674db290..034250178 100644 --- a/src/Ombi.Api/Api.cs +++ b/src/Ombi.Api/Api.cs @@ -1,29 +1,45 @@ -using System.IO; +using System; +using System.IO; using System.Net.Http; using System.Threading.Tasks; using System.Xml.Serialization; +using Microsoft.Extensions.Caching.Memory; using Newtonsoft.Json; using Microsoft.Extensions.Logging; +using Ombi.Core.Settings; using Ombi.Helpers; +using Ombi.Settings.Settings.Models; namespace Ombi.Api { public class Api : IApi { - public Api(ILogger log) + public Api(ILogger log, ISettingsService s, IMemoryCache cache) { Logger = log; + _settings = s; + _cache = cache; } private ILogger Logger { get; } + private readonly ISettingsService _settings; + private readonly IMemoryCache _cache; - - private HttpMessageHandler GetHandler() + private async Task GetHandler() { - return new HttpClientHandler + var settings = await _cache.GetOrCreateAsync(CacheKeys.OmbiSettings, async entry => + { + entry.AbsoluteExpiration = DateTimeOffset.Now.AddHours(1); + return await _settings.GetSettingsAsync(); + }); + if (settings.IgnoreCertificateErrors) { - ServerCertificateCustomValidationCallback = (message, certificate2, arg3, arg4) => true - }; + return new HttpClientHandler + { + ServerCertificateCustomValidationCallback = (message, certificate2, arg3, arg4) => true + }; + } + return new HttpClientHandler(); } private static readonly JsonSerializerSettings Settings = new JsonSerializerSettings @@ -33,7 +49,7 @@ namespace Ombi.Api public async Task Request(Request request) { - using (var httpClient = new HttpClient(GetHandler())) + using (var httpClient = new HttpClient(await GetHandler())) { using (var httpRequestMessage = new HttpRequestMessage(request.HttpMethod, request.FullUri)) @@ -79,7 +95,7 @@ namespace Ombi.Api public async Task RequestContent(Request request) { - using (var httpClient = new HttpClient(GetHandler())) + using (var httpClient = new HttpClient(await GetHandler())) { using (var httpRequestMessage = new HttpRequestMessage(request.HttpMethod, request.FullUri)) { @@ -113,7 +129,7 @@ namespace Ombi.Api public async Task Request(Request request) { - using (var httpClient = new HttpClient(GetHandler())) + using (var httpClient = new HttpClient(await GetHandler())) { using (var httpRequestMessage = new HttpRequestMessage(request.HttpMethod, request.FullUri)) { diff --git a/src/Ombi.Api/Ombi.Api.csproj b/src/Ombi.Api/Ombi.Api.csproj index afbe5ea20..eab82a56f 100644 --- a/src/Ombi.Api/Ombi.Api.csproj +++ b/src/Ombi.Api/Ombi.Api.csproj @@ -16,6 +16,7 @@ + \ No newline at end of file diff --git a/src/Ombi.Core/Rule/Rules/Search/CouchPotatoCacheRule.cs b/src/Ombi.Core/Rule/Rules/Search/CouchPotatoCacheRule.cs new file mode 100644 index 000000000..fc58f1d79 --- /dev/null +++ b/src/Ombi.Core/Rule/Rules/Search/CouchPotatoCacheRule.cs @@ -0,0 +1,35 @@ +using System.Linq; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; +using Ombi.Core.Models.Search; +using Ombi.Core.Rule.Interfaces; +using Ombi.Store.Context; +using Ombi.Store.Entities; + +namespace Ombi.Core.Rule.Rules.Search +{ + public class CouchPotatoCacheRule : BaseSearchRule, IRules + { + public CouchPotatoCacheRule(IOmbiContext ctx) + { + _ctx = ctx; + } + + private readonly IOmbiContext _ctx; + + public async Task Execute(SearchViewModel obj) + { + if (obj.Type == RequestType.Movie) + { + // Check if it's in Radarr + var result = await _ctx.CouchPotatoCache.FirstOrDefaultAsync(x => x.TheMovieDbId == obj.Id); + if (result != null) + { + obj.Approved = + true; // It's in cp so it's approved... Maybe have a new property called "Processing" or something? + } + } + return Success(); + } + } +} \ No newline at end of file diff --git a/src/Ombi.DependencyInjection/IocExtensions.cs b/src/Ombi.DependencyInjection/IocExtensions.cs index 324369680..2d4aaa814 100644 --- a/src/Ombi.DependencyInjection/IocExtensions.cs +++ b/src/Ombi.DependencyInjection/IocExtensions.cs @@ -38,10 +38,12 @@ using Ombi.Api.Service; using Ombi.Api.Slack; using Ombi.Core.Rule.Interfaces; using Ombi.Core.Senders; +using Ombi.Schedule.Jobs.Couchpotato; using Ombi.Schedule.Jobs.Emby; using Ombi.Schedule.Jobs.Ombi; using Ombi.Schedule.Jobs.Plex; using Ombi.Schedule.Jobs.Sonarr; +using Ombi.Store.Entities; using Ombi.Store.Repository.Requests; using PlexContentCacher = Ombi.Schedule.Jobs.Plex.PlexContentCacher; @@ -129,11 +131,12 @@ namespace Ombi.DependencyInjection services.AddTransient(); services.AddTransient(); - services.AddTransient(); } public static void RegisterJobs(this IServiceCollection services) { + services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); @@ -147,6 +150,7 @@ namespace Ombi.DependencyInjection services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); } } } diff --git a/src/Ombi.Helpers/LoggingEvents.cs b/src/Ombi.Helpers/LoggingEvents.cs index d74ca2556..a5bbad6aa 100644 --- a/src/Ombi.Helpers/LoggingEvents.cs +++ b/src/Ombi.Helpers/LoggingEvents.cs @@ -17,6 +17,7 @@ namespace Ombi.Helpers public static EventId PlexUserImporter => new EventId(2004); public static EventId EmbyUserImporter => new EventId(2005); public static EventId SonarrCacher => new EventId(2006); + public static EventId CouchPotatoCacher => new EventId(2007); public static EventId MovieSender => new EventId(3000); diff --git a/src/Ombi.Schedule/JobSetup.cs b/src/Ombi.Schedule/JobSetup.cs index 7e39f60ea..2880dbba0 100644 --- a/src/Ombi.Schedule/JobSetup.cs +++ b/src/Ombi.Schedule/JobSetup.cs @@ -1,5 +1,6 @@ using Hangfire; using Ombi.Schedule.Jobs; +using Ombi.Schedule.Jobs.Couchpotato; using Ombi.Schedule.Jobs.Emby; using Ombi.Schedule.Jobs.Ombi; using Ombi.Schedule.Jobs.Plex; @@ -12,7 +13,7 @@ namespace Ombi.Schedule { public JobSetup(IPlexContentCacher plexContentCacher, IRadarrCacher radarrCacher, IOmbiAutomaticUpdater updater, IEmbyContentCacher embyCacher, IPlexUserImporter userImporter, - IEmbyUserImporter embyUserImporter, ISonarrCacher cache) + IEmbyUserImporter embyUserImporter, ISonarrCacher cache, ICouchPotatoCacher cpCache) { PlexContentCacher = plexContentCacher; RadarrCacher = radarrCacher; @@ -21,6 +22,7 @@ namespace Ombi.Schedule PlexUserImporter = userImporter; EmbyUserImporter = embyUserImporter; SonarrCacher = cache; + CpCache = cpCache; } private IPlexContentCacher PlexContentCacher { get; } @@ -30,16 +32,20 @@ namespace Ombi.Schedule private IEmbyContentCacher EmbyContentCacher { get; } private IEmbyUserImporter EmbyUserImporter { get; } private ISonarrCacher SonarrCacher { get; } + private ICouchPotatoCacher CpCache { get; } public void Setup() { - RecurringJob.AddOrUpdate(() => PlexContentCacher.CacheContent(), Cron.Hourly(20)); RecurringJob.AddOrUpdate(() => EmbyContentCacher.Start(), Cron.Hourly(5)); RecurringJob.AddOrUpdate(() => SonarrCacher.Start(), Cron.Hourly(10)); RecurringJob.AddOrUpdate(() => RadarrCacher.CacheContent(), Cron.Hourly(15)); - RecurringJob.AddOrUpdate(() => PlexUserImporter.Start(), Cron.Daily(5)); - RecurringJob.AddOrUpdate(() => EmbyUserImporter.Start(), Cron.Daily); + RecurringJob.AddOrUpdate(() => PlexContentCacher.CacheContent(), Cron.Hourly(20)); + RecurringJob.AddOrUpdate(() => CpCache.Start(), Cron.Hourly(30)); + RecurringJob.AddOrUpdate(() => Updater.Update(null), Cron.HourInterval(6)); + + RecurringJob.AddOrUpdate(() => EmbyUserImporter.Start(), Cron.Daily); + RecurringJob.AddOrUpdate(() => PlexUserImporter.Start(), Cron.Daily(5)); } } } diff --git a/src/Ombi.Schedule/Jobs/Couchpotato/CouchPotatoCacher.cs b/src/Ombi.Schedule/Jobs/Couchpotato/CouchPotatoCacher.cs new file mode 100644 index 000000000..79ed8a30c --- /dev/null +++ b/src/Ombi.Schedule/Jobs/Couchpotato/CouchPotatoCacher.cs @@ -0,0 +1,105 @@ +#region Copyright +// /************************************************************************ +// Copyright (c) 2017 Jamie Rees +// File: CouchPotatoCacher.cs +// Created By: Jamie Rees +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// ************************************************************************/ +#endregion + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; +using Ombi.Api.CouchPotato; +using Ombi.Core.Settings; +using Ombi.Helpers; +using Ombi.Settings.Settings.Models.External; +using Ombi.Store.Context; +using Ombi.Store.Entities; + +namespace Ombi.Schedule.Jobs.Couchpotato +{ + public class CouchPotatoCacher : ICouchPotatoCacher + { + public CouchPotatoCacher(ISettingsService cpSettings, + ICouchPotatoApi api, ILogger log, IOmbiContext ctx) + { + _settings = cpSettings; + _api = api; + _log = log; + _ctx = ctx; + } + + private readonly ISettingsService _settings; + private readonly ICouchPotatoApi _api; + private readonly ILogger _log; + private readonly IOmbiContext _ctx; + + public async Task Start() + { + var settings = await _settings.GetSettingsAsync(); + if (!settings.Enabled) + { + return; + } + + try + { + _log.LogInformation(LoggingEvents.CouchPotatoCacher, "Getting all active movies from CP"); + var movies = await _api.GetMovies(settings.FullUri, settings.ApiKey, new[] {"active"}); + if (movies != null) + { + // Let's remove the old cached data + await _ctx.Database.ExecuteSqlCommandAsync("DELETE FROM CouchPotatoCache"); + + // Save + var movieIds = new List(); + foreach (var m in movies.movies) + { + if (m.info == null) + { + _log.LogInformation("Movie {0} does nto have a tmdbid", m.title); + continue; + } + if (m.info.tmdb_id > 0) + { + movieIds.Add(new CouchPotatoCache { TheMovieDbId = m.info.tmdb_id }); + } + else + { + _log.LogError("TMDBId is not > 0 for movie {0}", m.title); + } + } + await _ctx.CouchPotatoCache.AddRangeAsync(movieIds); + + await _ctx.SaveChangesAsync(); + } + } + catch (Exception e) + { + _log.LogError(LoggingEvents.CouchPotatoCacher, e, "error when trying to get movies from CP"); + throw; + } + } + } +} \ No newline at end of file diff --git a/src/Ombi.Schedule/Jobs/Couchpotato/ICouchPotatoCacher.cs b/src/Ombi.Schedule/Jobs/Couchpotato/ICouchPotatoCacher.cs new file mode 100644 index 000000000..6a115d438 --- /dev/null +++ b/src/Ombi.Schedule/Jobs/Couchpotato/ICouchPotatoCacher.cs @@ -0,0 +1,9 @@ +using System.Threading.Tasks; + +namespace Ombi.Schedule.Jobs.Couchpotato +{ + public interface ICouchPotatoCacher + { + Task Start(); + } +} \ No newline at end of file diff --git a/src/Ombi.Schedule/Jobs/Radarr/RadarrCacher.cs b/src/Ombi.Schedule/Jobs/Radarr/RadarrCacher.cs index 9667af648..5aa2cc49b 100644 --- a/src/Ombi.Schedule/Jobs/Radarr/RadarrCacher.cs +++ b/src/Ombi.Schedule/Jobs/Radarr/RadarrCacher.cs @@ -56,7 +56,7 @@ namespace Ombi.Schedule.Jobs.Radarr } else { - Log.Error("TMDBId is not > 0 for movie {0}", m.title); + Logger.LogError("TMDBId is not > 0 for movie {0}", m.title); } } await _ctx.RadarrCache.AddRangeAsync(movieIds); diff --git a/src/Ombi.Schedule/Ombi.Schedule.csproj b/src/Ombi.Schedule/Ombi.Schedule.csproj index ed6db8bbd..3d884cc4a 100644 --- a/src/Ombi.Schedule/Ombi.Schedule.csproj +++ b/src/Ombi.Schedule/Ombi.Schedule.csproj @@ -22,6 +22,7 @@ + diff --git a/src/Ombi.Settings/Settings/Models/OmbiSettings.cs b/src/Ombi.Settings/Settings/Models/OmbiSettings.cs index 9cacbd8e2..c4bf18ad1 100644 --- a/src/Ombi.Settings/Settings/Models/OmbiSettings.cs +++ b/src/Ombi.Settings/Settings/Models/OmbiSettings.cs @@ -6,6 +6,7 @@ public bool CollectAnalyticData { get; set; } public bool Wizard { get; set; } public string ApiKey { get; set; } + public bool IgnoreCertificateErrors { get; set; } } } \ No newline at end of file diff --git a/src/Ombi.Store/Context/IOmbiContext.cs b/src/Ombi.Store/Context/IOmbiContext.cs index 665b93ab9..1bd705280 100644 --- a/src/Ombi.Store/Context/IOmbiContext.cs +++ b/src/Ombi.Store/Context/IOmbiContext.cs @@ -37,5 +37,6 @@ namespace Ombi.Store.Context DbSet SonarrEpisodeCache { get; set; } EntityEntry Update(object entity); EntityEntry Update(TEntity entity) where TEntity : class; + DbSet CouchPotatoCache { get; set; } } } \ No newline at end of file diff --git a/src/Ombi.Store/Context/OmbiContext.cs b/src/Ombi.Store/Context/OmbiContext.cs index be3ddea5b..89644cbbc 100644 --- a/src/Ombi.Store/Context/OmbiContext.cs +++ b/src/Ombi.Store/Context/OmbiContext.cs @@ -26,6 +26,7 @@ namespace Ombi.Store.Context public DbSet PlexContent { get; set; } public DbSet PlexEpisode { get; set; } public DbSet RadarrCache { get; set; } + public DbSet CouchPotatoCache { get; set; } public DbSet EmbyContent { get; set; } public DbSet EmbyEpisode { get; set; } diff --git a/src/Ombi.Store/Entities/CouchPotatoCache.cs b/src/Ombi.Store/Entities/CouchPotatoCache.cs new file mode 100644 index 000000000..dbf49c2db --- /dev/null +++ b/src/Ombi.Store/Entities/CouchPotatoCache.cs @@ -0,0 +1,10 @@ +using System.ComponentModel.DataAnnotations.Schema; + +namespace Ombi.Store.Entities +{ + [Table("CouchPotatoCache")] + public class CouchPotatoCache : Entity + { + public int TheMovieDbId { get; set; } + } +} \ No newline at end of file diff --git a/src/Ombi.Store/Migrations/20171015200035_CouchPotatoCacher.Designer.cs b/src/Ombi.Store/Migrations/20171015200035_CouchPotatoCacher.Designer.cs new file mode 100644 index 000000000..e94514748 --- /dev/null +++ b/src/Ombi.Store/Migrations/20171015200035_CouchPotatoCacher.Designer.cs @@ -0,0 +1,775 @@ +// +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage; +using Microsoft.EntityFrameworkCore.Storage.Internal; +using Ombi.Helpers; +using Ombi.Store.Context; +using Ombi.Store.Entities; +using System; + +namespace Ombi.Store.Migrations +{ + [DbContext(typeof(OmbiContext))] + [Migration("20171015200035_CouchPotatoCacher")] + partial class CouchPotatoCacher + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "2.0.0-rtm-26452"); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken(); + + b.Property("Name") + .HasMaxLength(256); + + b.Property("NormalizedName") + .HasMaxLength(256); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasName("RoleNameIndex"); + + b.ToTable("AspNetRoles"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ClaimType"); + + b.Property("ClaimValue"); + + b.Property("RoleId") + .IsRequired(); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ClaimType"); + + b.Property("ClaimValue"); + + b.Property("UserId") + .IsRequired(); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider"); + + b.Property("ProviderKey"); + + b.Property("ProviderDisplayName"); + + b.Property("UserId") + .IsRequired(); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId"); + + b.Property("RoleId"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId"); + + b.Property("LoginProvider"); + + b.Property("Name"); + + b.Property("Value"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.ApplicationConfiguration", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Type"); + + b.Property("Value"); + + b.HasKey("Id"); + + b.ToTable("ApplicationConfiguration"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Audit", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("AuditArea"); + + b.Property("AuditType"); + + b.Property("DateTime"); + + b.Property("Description"); + + b.Property("User"); + + b.HasKey("Id"); + + b.ToTable("Audit"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.CouchPotatoCache", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("TheMovieDbId"); + + b.HasKey("Id"); + + b.ToTable("CouchPotatoCache"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.EmbyContent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("AddedAt"); + + b.Property("EmbyId") + .IsRequired(); + + b.Property("ProviderId"); + + b.Property("Title"); + + b.Property("Type"); + + b.HasKey("Id"); + + b.ToTable("EmbyContent"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.EmbyEpisode", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("AddedAt"); + + b.Property("EmbyId"); + + b.Property("EpisodeNumber"); + + b.Property("ParentId"); + + b.Property("ProviderId"); + + b.Property("SeasonNumber"); + + b.Property("Title"); + + b.HasKey("Id"); + + b.HasIndex("ParentId"); + + b.ToTable("EmbyEpisode"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.GlobalSettings", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Content"); + + b.Property("SettingsName"); + + b.HasKey("Id"); + + b.ToTable("GlobalSettings"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.NotificationTemplates", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Agent"); + + b.Property("Enabled"); + + b.Property("Message"); + + b.Property("NotificationType"); + + b.Property("Subject"); + + b.HasKey("Id"); + + b.ToTable("NotificationTemplates"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.OmbiUser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("AccessFailedCount"); + + b.Property("Alias"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken(); + + b.Property("Email") + .HasMaxLength(256); + + b.Property("EmailConfirmed"); + + b.Property("LastLoggedIn"); + + b.Property("LockoutEnabled"); + + b.Property("LockoutEnd"); + + b.Property("NormalizedEmail") + .HasMaxLength(256); + + b.Property("NormalizedUserName") + .HasMaxLength(256); + + b.Property("PasswordHash"); + + b.Property("PhoneNumber"); + + b.Property("PhoneNumberConfirmed"); + + b.Property("ProviderUserId"); + + b.Property("SecurityStamp"); + + b.Property("TwoFactorEnabled"); + + b.Property("UserName") + .HasMaxLength(256); + + b.Property("UserType"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasName("UserNameIndex"); + + b.ToTable("AspNetUsers"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.PlexContent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("AddedAt"); + + b.Property("Key"); + + b.Property("ProviderId"); + + b.Property("Quality"); + + b.Property("ReleaseYear"); + + b.Property("Title"); + + b.Property("Type"); + + b.Property("Url"); + + b.HasKey("Id"); + + b.ToTable("PlexContent"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.PlexEpisode", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("EpisodeNumber"); + + b.Property("GrandparentKey"); + + b.Property("Key"); + + b.Property("ParentKey"); + + b.Property("SeasonNumber"); + + b.Property("Title"); + + b.HasKey("Id"); + + b.HasIndex("GrandparentKey"); + + b.ToTable("PlexEpisode"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.PlexSeasonsContent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ParentKey"); + + b.Property("PlexContentId"); + + b.Property("SeasonKey"); + + b.Property("SeasonNumber"); + + b.HasKey("Id"); + + b.HasIndex("PlexContentId"); + + b.ToTable("PlexSeasonsContent"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.RadarrCache", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("TheMovieDbId"); + + b.HasKey("Id"); + + b.ToTable("RadarrCache"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.ChildRequests", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Approved"); + + b.Property("Available"); + + b.Property("Denied"); + + b.Property("DeniedReason"); + + b.Property("IssueId"); + + b.Property("ParentRequestId"); + + b.Property("RequestType"); + + b.Property("RequestedDate"); + + b.Property("RequestedUserId"); + + b.Property("Title"); + + b.HasKey("Id"); + + b.HasIndex("ParentRequestId"); + + b.HasIndex("RequestedUserId"); + + b.ToTable("ChildRequests"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.MovieIssues", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Description"); + + b.Property("IssueId"); + + b.Property("MovieId"); + + b.Property("Subect"); + + b.HasKey("Id"); + + b.HasIndex("IssueId"); + + b.HasIndex("MovieId"); + + b.ToTable("MovieIssues"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.MovieRequests", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Approved"); + + b.Property("Available"); + + b.Property("Denied"); + + b.Property("DeniedReason"); + + b.Property("ImdbId"); + + b.Property("IssueId"); + + b.Property("Overview"); + + b.Property("PosterPath"); + + b.Property("QualityOverride"); + + b.Property("ReleaseDate"); + + b.Property("RequestType"); + + b.Property("RequestedDate"); + + b.Property("RequestedUserId"); + + b.Property("RootPathOverride"); + + b.Property("Status"); + + b.Property("TheMovieDbId"); + + b.Property("Title"); + + b.HasKey("Id"); + + b.HasIndex("RequestedUserId"); + + b.ToTable("MovieRequests"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.TvIssues", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Description"); + + b.Property("IssueId"); + + b.Property("Subect"); + + b.Property("TvId"); + + b.HasKey("Id"); + + b.HasIndex("IssueId"); + + b.HasIndex("TvId"); + + b.ToTable("TvIssues"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.TvRequests", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ImdbId"); + + b.Property("Overview"); + + b.Property("PosterPath"); + + b.Property("ReleaseDate"); + + b.Property("RootFolder"); + + b.Property("Status"); + + b.Property("Title"); + + b.Property("TvDbId"); + + b.HasKey("Id"); + + b.ToTable("TvRequests"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.SonarrCache", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("TvDbId"); + + b.HasKey("Id"); + + b.ToTable("SonarrCache"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.SonarrEpisodeCache", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("EpisodeNumber"); + + b.Property("SeasonNumber"); + + b.Property("TvDbId"); + + b.HasKey("Id"); + + b.ToTable("SonarrEpisodeCache"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Tokens", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Token"); + + b.Property("UserId"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Tokens"); + }); + + modelBuilder.Entity("Ombi.Store.Repository.Requests.EpisodeRequests", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("AirDate"); + + b.Property("Approved"); + + b.Property("Available"); + + b.Property("EpisodeNumber"); + + b.Property("Requested"); + + b.Property("SeasonId"); + + b.Property("Title"); + + b.Property("Url"); + + b.HasKey("Id"); + + b.HasIndex("SeasonId"); + + b.ToTable("EpisodeRequests"); + }); + + modelBuilder.Entity("Ombi.Store.Repository.Requests.SeasonRequests", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ChildRequestId"); + + b.Property("SeasonNumber"); + + b.HasKey("Id"); + + b.HasIndex("ChildRequestId"); + + b.ToTable("SeasonRequests"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("Ombi.Store.Entities.OmbiUser") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Ombi.Store.Entities.EmbyEpisode", b => + { + b.HasOne("Ombi.Store.Entities.EmbyContent", "Series") + .WithMany("Episodes") + .HasForeignKey("ParentId") + .HasPrincipalKey("EmbyId"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.PlexEpisode", b => + { + b.HasOne("Ombi.Store.Entities.PlexContent", "Series") + .WithMany("Episodes") + .HasForeignKey("GrandparentKey") + .HasPrincipalKey("Key") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Ombi.Store.Entities.PlexSeasonsContent", b => + { + b.HasOne("Ombi.Store.Entities.PlexContent") + .WithMany("Seasons") + .HasForeignKey("PlexContentId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.ChildRequests", b => + { + b.HasOne("Ombi.Store.Entities.Requests.TvRequests", "ParentRequest") + .WithMany("ChildRequests") + .HasForeignKey("ParentRequestId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("Ombi.Store.Entities.OmbiUser", "RequestedUser") + .WithMany() + .HasForeignKey("RequestedUserId"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.MovieIssues", b => + { + b.HasOne("Ombi.Store.Entities.Requests.MovieRequests") + .WithMany("Issues") + .HasForeignKey("IssueId"); + + b.HasOne("Ombi.Store.Entities.Requests.MovieRequests", "Movie") + .WithMany() + .HasForeignKey("MovieId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.MovieRequests", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", "RequestedUser") + .WithMany() + .HasForeignKey("RequestedUserId"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.TvIssues", b => + { + b.HasOne("Ombi.Store.Entities.Requests.ChildRequests") + .WithMany("Issues") + .HasForeignKey("IssueId"); + + b.HasOne("Ombi.Store.Entities.Requests.ChildRequests", "Child") + .WithMany() + .HasForeignKey("TvId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Tokens", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", "User") + .WithMany() + .HasForeignKey("UserId"); + }); + + modelBuilder.Entity("Ombi.Store.Repository.Requests.EpisodeRequests", b => + { + b.HasOne("Ombi.Store.Repository.Requests.SeasonRequests", "Season") + .WithMany("Episodes") + .HasForeignKey("SeasonId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Ombi.Store.Repository.Requests.SeasonRequests", b => + { + b.HasOne("Ombi.Store.Entities.Requests.ChildRequests", "ChildRequest") + .WithMany("SeasonRequests") + .HasForeignKey("ChildRequestId") + .OnDelete(DeleteBehavior.Cascade); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Ombi.Store/Migrations/20171015200035_CouchPotatoCacher.cs b/src/Ombi.Store/Migrations/20171015200035_CouchPotatoCacher.cs new file mode 100644 index 000000000..0bb3b3243 --- /dev/null +++ b/src/Ombi.Store/Migrations/20171015200035_CouchPotatoCacher.cs @@ -0,0 +1,31 @@ +using Microsoft.EntityFrameworkCore.Migrations; +using System; +using System.Collections.Generic; + +namespace Ombi.Store.Migrations +{ + public partial class CouchPotatoCacher : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "CouchPotatoCache", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + TheMovieDbId = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_CouchPotatoCache", x => x.Id); + }); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "CouchPotatoCache"); + } + } +} diff --git a/src/Ombi.Store/Migrations/OmbiContextModelSnapshot.cs b/src/Ombi.Store/Migrations/OmbiContextModelSnapshot.cs index 03410a385..efae58afa 100644 --- a/src/Ombi.Store/Migrations/OmbiContextModelSnapshot.cs +++ b/src/Ombi.Store/Migrations/OmbiContextModelSnapshot.cs @@ -162,6 +162,18 @@ namespace Ombi.Store.Migrations b.ToTable("Audit"); }); + modelBuilder.Entity("Ombi.Store.Entities.CouchPotatoCache", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("TheMovieDbId"); + + b.HasKey("Id"); + + b.ToTable("CouchPotatoCache"); + }); + modelBuilder.Entity("Ombi.Store.Entities.EmbyContent", b => { b.Property("Id") diff --git a/src/Ombi.Store/Migrations/OmbiMigrations.ps1 b/src/Ombi.Store/Migrations/OmbiMigrations.ps1 deleted file mode 100644 index 9914917a4..000000000 --- a/src/Ombi.Store/Migrations/OmbiMigrations.ps1 +++ /dev/null @@ -1,2 +0,0 @@ -cd .. -dotnet ef migrations add Inital --context OmbiContext --startup-project ../Ombi/Ombi.csproj \ 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 c65c93995..6589b3b62 100644 --- a/src/Ombi/ClientApp/app/interfaces/ISettings.ts +++ b/src/Ombi/ClientApp/app/interfaces/ISettings.ts @@ -8,13 +8,11 @@ export interface IExternalSettings extends ISettings { } export interface IOmbiSettings extends ISettings { - port: number; baseUrl: string; collectAnalyticData: boolean; wizard: boolean; apiKey: string; - externalUrl: string; - allowExternalUsersToAuthenticate: boolean; + ignoreCertificateErrors: boolean; } export interface IUpdateSettings extends ISettings { diff --git a/src/Ombi/ClientApp/app/settings/ombi/ombi.component.html b/src/Ombi/ClientApp/app/settings/ombi/ombi.component.html index ca6be181b..0d416c3d7 100644 --- a/src/Ombi/ClientApp/app/settings/ombi/ombi.component.html +++ b/src/Ombi/ClientApp/app/settings/ombi/ombi.component.html @@ -44,6 +44,13 @@ +
+
+
+ + +
+
diff --git a/src/Ombi/ClientApp/app/settings/ombi/ombi.component.ts b/src/Ombi/ClientApp/app/settings/ombi/ombi.component.ts index b481dd1bd..c4ea3581c 100644 --- a/src/Ombi/ClientApp/app/settings/ombi/ombi.component.ts +++ b/src/Ombi/ClientApp/app/settings/ombi/ombi.component.ts @@ -18,11 +18,9 @@ export class OmbiComponent implements OnInit { public ngOnInit() { this.settingsService.getOmbi().subscribe(x => { this.form = this.fb.group({ - port: [x.port], collectAnalyticData: [x.collectAnalyticData], apiKey: [x.apiKey], - externalUrl: [x.externalUrl], - allowExternalUsersToAuthenticate: [x.allowExternalUsersToAuthenticate], + ignoreCertificateErrors: [x.ignoreCertificateErrors], baseUrl: [x.baseUrl], }); }); diff --git a/src/Ombi/ClientApp/app/settings/settingsmenu.component.html b/src/Ombi/ClientApp/app/settings/settingsmenu.component.html index b9268dfa4..0e3ce4267 100644 --- a/src/Ombi/ClientApp/app/settings/settingsmenu.component.html +++ b/src/Ombi/ClientApp/app/settings/settingsmenu.component.html @@ -40,7 +40,7 @@ Movies