From ea7307ac07cbea356ae1139c879b9e0959607f23 Mon Sep 17 00:00:00 2001 From: tidusjar Date: Wed, 6 Jan 2021 16:42:15 +0000 Subject: [PATCH] We now show streaming information on the details page --- .../WatchProviderParserTests.cs | 94 ++ src/Ombi.Core/Engine/BaseMediaEngine.cs | 8 + .../Engine/Interfaces/IMovieEngineV2.cs | 1 + .../Engine/Interfaces/ITvSearchEngineV2.cs | 5 +- .../Engine/V2/MovieSearchEngineV2.cs | 20 + src/Ombi.Core/Engine/V2/TvSearchEngineV2.cs | 41 +- src/Ombi.Core/Helpers/WatchProviderParser.cs | 35 + .../Models/Search/V2/StreamingData.cs | 9 + src/Ombi.Core/Models/UI/UserViewModel.cs | 1 + src/Ombi.Store/Entities/OmbiUser.cs | 12 +- src/Ombi.Store/Migration.md | 23 - ...106132735_UserStreamingCountry.Designer.cs | 1225 +++++++++++++++++ .../20210106132735_UserStreamingCountry.cs | 26 + .../OmbiMySqlContextModelSnapshot.cs | 107 +- ...106134000_UserStreamingCountry.Designer.cs | 1225 +++++++++++++++++ .../20210106134000_UserStreamingCountry.cs | 26 + .../OmbiSqliteContextModelSnapshot.cs | 106 +- src/Ombi.TheMovieDbApi/IMovieDbApi.cs | 4 +- .../Models/WatchProviders.cs | 77 ++ src/Ombi.TheMovieDbApi/TheMovieDbApi.cs | 50 +- .../ClientApp/src/app/interfaces/IStreams.ts | 5 + .../ClientApp/src/app/interfaces/IUser.ts | 7 +- .../movie-information-panel.component.html | 98 +- .../movie-information-panel.component.ts | 4 + .../tv-information-panel.component.html | 11 +- .../tv-information-panel.component.ts | 4 + .../media-details.component.scss | 6 + .../src/app/services/identity.service.ts | 12 +- .../src/app/services/searchV2.service.ts | 9 + .../ClientApp/src/app/shared/shared.module.ts | 2 +- .../user-preference.component.html | 56 +- .../user-preference.component.ts | 20 +- .../usermanagement-user.component.html | 8 + .../usermanagement-user.component.ts | 9 +- src/Ombi/Controllers/V1/IdentityController.cs | 45 +- src/Ombi/Controllers/V2/SearchController.cs | 15 + .../Identity/CountryStreamingPreference.cs | 7 + src/Ombi/wwwroot/translations/en.json | 10 +- 38 files changed, 3268 insertions(+), 155 deletions(-) create mode 100644 src/Ombi.Core.Tests/WatchProviderParserTests.cs create mode 100644 src/Ombi.Core/Helpers/WatchProviderParser.cs create mode 100644 src/Ombi.Core/Models/Search/V2/StreamingData.cs create mode 100644 src/Ombi.Store/Migrations/OmbiMySql/20210106132735_UserStreamingCountry.Designer.cs create mode 100644 src/Ombi.Store/Migrations/OmbiMySql/20210106132735_UserStreamingCountry.cs create mode 100644 src/Ombi.Store/Migrations/OmbiSqlite/20210106134000_UserStreamingCountry.Designer.cs create mode 100644 src/Ombi.Store/Migrations/OmbiSqlite/20210106134000_UserStreamingCountry.cs create mode 100644 src/Ombi.TheMovieDbApi/Models/WatchProviders.cs create mode 100644 src/Ombi/ClientApp/src/app/interfaces/IStreams.ts create mode 100644 src/Ombi/Models/Identity/CountryStreamingPreference.cs diff --git a/src/Ombi.Core.Tests/WatchProviderParserTests.cs b/src/Ombi.Core.Tests/WatchProviderParserTests.cs new file mode 100644 index 000000000..c56f64946 --- /dev/null +++ b/src/Ombi.Core.Tests/WatchProviderParserTests.cs @@ -0,0 +1,94 @@ +using NUnit.Framework; +using Ombi.Api.TheMovieDb.Models; +using Ombi.Core.Helpers; +using Ombi.Store.Entities; +using System.Collections.Generic; + +namespace Ombi.Core.Tests +{ + [TestFixture] + public class WatchProviderParserTests + { + [TestCase("GB", TestName = "UpperCase")] + [TestCase("gb", TestName = "LowerCase")] + [TestCase("gB", TestName = "MixedCase")] + public void GetValidStreamData(string streamingCountry) + { + var result = WatchProviderParser.GetUserWatchProviders(new WatchProviders + { + Results = new Results + { + GB = new WatchProviderData() + { + StreamInformation = new List + { + new StreamData + { + provider_name = "Netflix", + display_priority = 0, + logo_path = "logo", + provider_id = 8 + } + } + } + } + }, new OmbiUser { StreamingCountry = streamingCountry }); + + Assert.That(result[0].provider_name, Is.EqualTo("Netflix")); + } + + [TestCase("GB", TestName = "Missing_UpperCase")] + [TestCase("gb", TestName = "Missing_LowerCase")] + [TestCase("gB", TestName = "Missing_MixedCase")] + public void GetMissingStreamData(string streamingCountry) + { + var result = WatchProviderParser.GetUserWatchProviders(new WatchProviders + { + Results = new Results + { + AR = new WatchProviderData() + { + StreamInformation = new List + { + new StreamData + { + provider_name = "Netflix", + display_priority = 0, + logo_path = "logo", + provider_id = 8 + } + } + } + } + }, new OmbiUser { StreamingCountry = streamingCountry }); + + Assert.That(result, Is.Empty); + } + + [Test] + public void GetInvalidStreamData() + { + var result = WatchProviderParser.GetUserWatchProviders(new WatchProviders + { + Results = new Results + { + AR = new WatchProviderData() + { + StreamInformation = new List + { + new StreamData + { + provider_name = "Netflix", + display_priority = 0, + logo_path = "logo", + provider_id = 8 + } + } + } + } + }, new OmbiUser { StreamingCountry = "BLAH" }); + + Assert.That(result, Is.Empty); + } + } +} diff --git a/src/Ombi.Core/Engine/BaseMediaEngine.cs b/src/Ombi.Core/Engine/BaseMediaEngine.cs index fc9847c7d..66e60767a 100644 --- a/src/Ombi.Core/Engine/BaseMediaEngine.cs +++ b/src/Ombi.Core/Engine/BaseMediaEngine.cs @@ -15,6 +15,8 @@ using Ombi.Core.Settings; using Ombi.Settings.Settings.Models; using Ombi.Store.Entities; using Ombi.Store.Repository; +using Ombi.Api.TheMovieDb.Models; +using Ombi.Core.Helpers; namespace Ombi.Core.Engine { @@ -179,6 +181,12 @@ namespace Ombi.Core.Engine return user.Language; } + protected async Task> GetUserWatchProvider(WatchProviders providers) + { + var user = await GetUser(); + return WatchProviderParser.GetUserWatchProviders(providers, user); + } + private OmbiSettings ombiSettings; protected async Task GetOmbiSettings() { diff --git a/src/Ombi.Core/Engine/Interfaces/IMovieEngineV2.cs b/src/Ombi.Core/Engine/Interfaces/IMovieEngineV2.cs index 3b8d97dc0..746045ef3 100644 --- a/src/Ombi.Core/Engine/Interfaces/IMovieEngineV2.cs +++ b/src/Ombi.Core/Engine/Interfaces/IMovieEngineV2.cs @@ -26,5 +26,6 @@ namespace Ombi.Core.Engine.Interfaces int ResultLimit { get; set; } Task GetMovieInfoByImdbId(string imdbId, CancellationToken requestAborted); + Task> GetStreamInformation(int movieDbId, CancellationToken cancellationToken); } } \ No newline at end of file diff --git a/src/Ombi.Core/Engine/Interfaces/ITvSearchEngineV2.cs b/src/Ombi.Core/Engine/Interfaces/ITvSearchEngineV2.cs index a8a27aa19..d2201825f 100644 --- a/src/Ombi.Core/Engine/Interfaces/ITvSearchEngineV2.cs +++ b/src/Ombi.Core/Engine/Interfaces/ITvSearchEngineV2.cs @@ -1,4 +1,6 @@ -using System.Threading.Tasks; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; using Ombi.Core.Models.Search.V2; namespace Ombi.Core @@ -7,5 +9,6 @@ namespace Ombi.Core { Task GetShowInformation(int tvdbid); Task GetShowByRequest(int requestId); + Task> GetStreamInformation(int tvDbId, int tvMazeId, CancellationToken cancellationToken); } } \ No newline at end of file diff --git a/src/Ombi.Core/Engine/V2/MovieSearchEngineV2.cs b/src/Ombi.Core/Engine/V2/MovieSearchEngineV2.cs index 1e2110b38..dc009371a 100644 --- a/src/Ombi.Core/Engine/V2/MovieSearchEngineV2.cs +++ b/src/Ombi.Core/Engine/V2/MovieSearchEngineV2.cs @@ -249,6 +249,26 @@ namespace Ombi.Core.Engine.V2 return result; } + public async Task> GetStreamInformation(int movieDbId, CancellationToken cancellationToken) + { + var providers = await MovieApi.GetMovieWatchProviders(movieDbId, cancellationToken); + var results = await GetUserWatchProvider(providers); + + var data = new List(); + + foreach (var result in results) + { + data.Add(new StreamingData + { + Logo = result.logo_path, + Order = result.display_priority, + StreamingProvider = result.provider_name + }); + } + + return data; + } + protected async Task> TransformMovieResultsToResponse( IEnumerable movies) { diff --git a/src/Ombi.Core/Engine/V2/TvSearchEngineV2.cs b/src/Ombi.Core/Engine/V2/TvSearchEngineV2.cs index dd2ce22aa..29ea01879 100644 --- a/src/Ombi.Core/Engine/V2/TvSearchEngineV2.cs +++ b/src/Ombi.Core/Engine/V2/TvSearchEngineV2.cs @@ -19,6 +19,8 @@ using Ombi.Core.Settings; using Ombi.Store.Repository; using TraktSharp.Entities; using Microsoft.EntityFrameworkCore; +using System.Threading; +using Ombi.Api.TheMovieDb; namespace Ombi.Core.Engine.V2 { @@ -27,15 +29,17 @@ namespace Ombi.Core.Engine.V2 private readonly ITvMazeApi _tvMaze; private readonly IMapper _mapper; private readonly ITraktApi _traktApi; + private readonly IMovieDbApi _movieApi; public TvSearchEngineV2(IPrincipal identity, IRequestServiceMain service, ITvMazeApi tvMaze, IMapper mapper, ITraktApi trakt, IRuleEvaluator r, OmbiUserManager um, ICacheService memCache, ISettingsService s, - IRepository sub) + IRepository sub, IMovieDbApi movieApi) : base(identity, service, r, um, memCache, s, sub) { _tvMaze = tvMaze; _mapper = mapper; _traktApi = trakt; + _movieApi = movieApi; } @@ -106,6 +110,39 @@ namespace Ombi.Core.Engine.V2 return await ProcessResult(mapped, traktInfoTask); } + public async Task> GetStreamInformation(int tvDbId, int tvMazeId, CancellationToken cancellationToken) + { + var tvdbshow = await Cache.GetOrAdd(nameof(GetShowInformation) + tvMazeId, + async () => await _tvMaze.ShowLookupByTheTvDbId(tvMazeId), DateTime.Now.AddHours(12)); + if (tvdbshow == null) + { + return null; + } + + /// this is a best effort guess since TV maze do not provide the TheMovieDbId + var movieDbResults = await _movieApi.SearchTv(tvdbshow.name, tvdbshow.premiered.Substring(0, 4)); + var potential = movieDbResults.FirstOrDefault(); + tvDbId = potential.Id; + // end guess + + var providers = await _movieApi.GetTvWatchProviders(tvDbId, cancellationToken); + var results = await GetUserWatchProvider(providers); + + var data = new List(); + + foreach (var result in results) + { + data.Add(new StreamingData + { + Logo = result.logo_path, + Order = result.display_priority, + StreamingProvider = result.provider_name + }); + } + + return data; + } + private IEnumerable ProcessResults(IEnumerable items) { var retVal = new List(); @@ -141,7 +178,7 @@ namespace Ombi.Core.Engine.V2 { item.Images.Medium = item.Images.Medium.ToHttpsUrl(); } - + if (item.Cast?.Any() ?? false) { foreach (var cast in item.Cast) diff --git a/src/Ombi.Core/Helpers/WatchProviderParser.cs b/src/Ombi.Core/Helpers/WatchProviderParser.cs new file mode 100644 index 000000000..68f3c26dd --- /dev/null +++ b/src/Ombi.Core/Helpers/WatchProviderParser.cs @@ -0,0 +1,35 @@ +using Ombi.Api.TheMovieDb.Models; +using Ombi.Store.Entities; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Ombi.Core.Helpers +{ + public static class WatchProviderParser + { + public static List GetUserWatchProviders(WatchProviders providers, OmbiUser user) + { + var data = new List(); + + if (providers?.Results == null) + { + return data; + } + + var resultsProp = providers.Results.GetType().GetProperties(); + var matchingStreamingCountry = resultsProp.FirstOrDefault(x => x.Name.Equals(user.StreamingCountry, StringComparison.InvariantCultureIgnoreCase)); + if (matchingStreamingCountry == null) + { + return data; + } + + var result = (WatchProviderData)matchingStreamingCountry.GetValue(providers.Results); + if (result == null || result.StreamInformation == null) + { + return data; + } + return result.StreamInformation; + } + } +} diff --git a/src/Ombi.Core/Models/Search/V2/StreamingData.cs b/src/Ombi.Core/Models/Search/V2/StreamingData.cs new file mode 100644 index 000000000..d9444c2ce --- /dev/null +++ b/src/Ombi.Core/Models/Search/V2/StreamingData.cs @@ -0,0 +1,9 @@ +namespace Ombi.Core.Models.Search.V2 +{ + public class StreamingData + { + public int Order { get; set; } + public string StreamingProvider { get; set; } + public string Logo { get; set; } + } +} diff --git a/src/Ombi.Core/Models/UI/UserViewModel.cs b/src/Ombi.Core/Models/UI/UserViewModel.cs index 0c3c9e349..0c9be846a 100644 --- a/src/Ombi.Core/Models/UI/UserViewModel.cs +++ b/src/Ombi.Core/Models/UI/UserViewModel.cs @@ -18,6 +18,7 @@ namespace Ombi.Core.Models.UI public UserType UserType { get; set; } public int MovieRequestLimit { get; set; } public int EpisodeRequestLimit { get; set; } + public string StreamingCountry { get; set; } public RequestQuotaCountModel EpisodeRequestQuota { get; set; } public RequestQuotaCountModel MovieRequestQuota { get; set; } public RequestQuotaCountModel MusicRequestQuota { get; set; } diff --git a/src/Ombi.Store/Entities/OmbiUser.cs b/src/Ombi.Store/Entities/OmbiUser.cs index 919d9a22c..46a49b1ae 100644 --- a/src/Ombi.Store/Entities/OmbiUser.cs +++ b/src/Ombi.Store/Entities/OmbiUser.cs @@ -1,9 +1,9 @@ using System; using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using Microsoft.AspNetCore.Identity; using Newtonsoft.Json; -using Ombi.Helpers; namespace Ombi.Store.Entities { @@ -21,6 +21,12 @@ namespace Ombi.Store.Entities public string Language { get; set; } + /// + /// Used to get the Streaming information for media + /// + [Required] + public string StreamingCountry { get; set; } + public int? MovieRequestLimit { get; set; } public int? EpisodeRequestLimit { get; set; } public int? MusicRequestLimit { get; set; } @@ -40,14 +46,14 @@ namespace Ombi.Store.Entities public bool EmailLogin { get; set; } [NotMapped] public bool IsSystemUser => UserType == UserType.SystemUser; - + [JsonIgnore] public override string PasswordHash { get => base.PasswordHash; set => base.PasswordHash = value; } - + [JsonIgnore] public override string SecurityStamp { diff --git a/src/Ombi.Store/Migration.md b/src/Ombi.Store/Migration.md index 50711820b..6225229a3 100644 --- a/src/Ombi.Store/Migration.md +++ b/src/Ombi.Store/Migration.md @@ -14,29 +14,6 @@ If running migrations for any db provider other than Sqlite, then ensure the dat export PATH="$HOME/.dotnet/tools:$PATH" ``` -1. In `src/Ombi`, install the `Microsoft.EntityFrameworkCore.Design` package: - - ``` - cd src/Ombi - dotnet add package Microsoft.EntityFrameworkCore.Design - ``` - -1. For some reason, the `StartupSingleton.Instance.SecurityKey` in `src/Ombi/Extensions/StartupExtensions.cs` is invalid when running `dotnet ef migrations add` so we must fix it; apply this patch which seems to do the job: - - ``` - @@ -79,7 +79,7 @@ namespace Ombi - var tokenValidationParameters = new TokenValidationParameters - { - ValidateIssuerSigningKey = true, - - IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(StartupSingleton.Instance.SecurityKey)), - + IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(StartupSingleton.Instance.SecurityKey + "s")), - RequireExpirationTime = true, - ValidateLifetime = true, - ValidAudience = "Ombi", - ``` - - *WARNING*: Don't forget to undo this before building Ombi, or things will be broken! - 1. List the available `dbcontext`s, and select the one that matches the database your fields will go in: ``` diff --git a/src/Ombi.Store/Migrations/OmbiMySql/20210106132735_UserStreamingCountry.Designer.cs b/src/Ombi.Store/Migrations/OmbiMySql/20210106132735_UserStreamingCountry.Designer.cs new file mode 100644 index 000000000..989ba1ba0 --- /dev/null +++ b/src/Ombi.Store/Migrations/OmbiMySql/20210106132735_UserStreamingCountry.Designer.cs @@ -0,0 +1,1225 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Ombi.Store.Context.MySql; + +namespace Ombi.Store.Migrations.OmbiMySql +{ + [DbContext(typeof(OmbiMySqlContext))] + [Migration("20210106132735_UserStreamingCountry")] + partial class UserStreamingCountry + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("Relational:MaxIdentifierLength", 64) + .HasAnnotation("ProductVersion", "5.0.1"); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .HasColumnType("varchar(255)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("longtext"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("AspNetRoles"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("ClaimType") + .HasColumnType("longtext"); + + b.Property("ClaimValue") + .HasColumnType("longtext"); + + b.Property("RoleId") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("ClaimType") + .HasColumnType("longtext"); + + b.Property("ClaimValue") + .HasColumnType("longtext"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("varchar(255)"); + + b.Property("ProviderKey") + .HasColumnType("varchar(255)"); + + b.Property("ProviderDisplayName") + .HasColumnType("longtext"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("varchar(255)"); + + b.Property("RoleId") + .HasColumnType("varchar(255)"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("varchar(255)"); + + b.Property("LoginProvider") + .HasColumnType("varchar(255)"); + + b.Property("Name") + .HasColumnType("varchar(255)"); + + b.Property("Value") + .HasColumnType("longtext"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Audit", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("AuditArea") + .HasColumnType("int"); + + b.Property("AuditType") + .HasColumnType("int"); + + b.Property("DateTime") + .HasColumnType("datetime(6)"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("User") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.ToTable("Audit"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.MobileDevices", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("AddedAt") + .HasColumnType("datetime(6)"); + + b.Property("Token") + .HasColumnType("longtext"); + + b.Property("UserId") + .HasColumnType("varchar(255)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("MobileDevices"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.NotificationTemplates", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Agent") + .HasColumnType("int"); + + b.Property("Enabled") + .HasColumnType("tinyint(1)"); + + b.Property("Message") + .HasColumnType("longtext"); + + b.Property("NotificationType") + .HasColumnType("int"); + + b.Property("Subject") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.ToTable("NotificationTemplates"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.NotificationUserId", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("AddedAt") + .HasColumnType("datetime(6)"); + + b.Property("PlayerId") + .HasColumnType("longtext"); + + b.Property("UserId") + .HasColumnType("varchar(255)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("NotificationUserId"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.OmbiUser", b => + { + b.Property("Id") + .HasColumnType("varchar(255)"); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("Alias") + .HasColumnType("longtext"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("longtext"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("tinyint(1)"); + + b.Property("EpisodeRequestLimit") + .HasColumnType("int"); + + b.Property("Language") + .HasColumnType("longtext"); + + b.Property("LastLoggedIn") + .HasColumnType("datetime(6)"); + + b.Property("LockoutEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("LockoutEnd") + .HasColumnType("datetime(6)"); + + b.Property("MovieRequestLimit") + .HasColumnType("int"); + + b.Property("MusicRequestLimit") + .HasColumnType("int"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("PasswordHash") + .HasColumnType("longtext"); + + b.Property("PhoneNumber") + .HasColumnType("longtext"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("tinyint(1)"); + + b.Property("ProviderUserId") + .HasColumnType("longtext"); + + b.Property("SecurityStamp") + .HasColumnType("longtext"); + + b.Property("StreamingCountry") + .HasColumnType("longtext"); + + b.Property("TwoFactorEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("UserAccessToken") + .HasColumnType("longtext"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("UserType") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex"); + + b.ToTable("AspNetUsers"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.RecentlyAddedLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("AddedAt") + .HasColumnType("datetime(6)"); + + b.Property("AlbumId") + .HasColumnType("longtext"); + + b.Property("ContentId") + .HasColumnType("int"); + + b.Property("ContentType") + .HasColumnType("int"); + + b.Property("EpisodeNumber") + .HasColumnType("int"); + + b.Property("SeasonNumber") + .HasColumnType("int"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("RecentlyAddedLog"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.RequestQueue", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Completed") + .HasColumnType("datetime(6)"); + + b.Property("Dts") + .HasColumnType("datetime(6)"); + + b.Property("Error") + .HasColumnType("longtext"); + + b.Property("RequestId") + .HasColumnType("int"); + + b.Property("RetryCount") + .HasColumnType("int"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("RequestQueue"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.RequestSubscription", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("RequestId") + .HasColumnType("int"); + + b.Property("RequestType") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("varchar(255)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("RequestSubscription"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.AlbumRequest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Approved") + .HasColumnType("tinyint(1)"); + + b.Property("ArtistName") + .HasColumnType("longtext"); + + b.Property("Available") + .HasColumnType("tinyint(1)"); + + b.Property("Cover") + .HasColumnType("longtext"); + + b.Property("Denied") + .HasColumnType("tinyint(1)"); + + b.Property("DeniedReason") + .HasColumnType("longtext"); + + b.Property("Disk") + .HasColumnType("longtext"); + + b.Property("ForeignAlbumId") + .HasColumnType("longtext"); + + b.Property("ForeignArtistId") + .HasColumnType("longtext"); + + b.Property("MarkedAsApproved") + .HasColumnType("datetime(6)"); + + b.Property("MarkedAsAvailable") + .HasColumnType("datetime(6)"); + + b.Property("MarkedAsDenied") + .HasColumnType("datetime(6)"); + + b.Property("Rating") + .HasColumnType("decimal(65,30)"); + + b.Property("ReleaseDate") + .HasColumnType("datetime(6)"); + + b.Property("RequestType") + .HasColumnType("int"); + + b.Property("RequestedByAlias") + .HasColumnType("longtext"); + + b.Property("RequestedDate") + .HasColumnType("datetime(6)"); + + b.Property("RequestedUserId") + .HasColumnType("varchar(255)"); + + b.Property("Title") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.HasIndex("RequestedUserId"); + + b.ToTable("AlbumRequests"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.ChildRequests", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Approved") + .HasColumnType("tinyint(1)"); + + b.Property("Available") + .HasColumnType("tinyint(1)"); + + b.Property("Denied") + .HasColumnType("tinyint(1)"); + + b.Property("DeniedReason") + .HasColumnType("longtext"); + + b.Property("IssueId") + .HasColumnType("int"); + + b.Property("MarkedAsApproved") + .HasColumnType("datetime(6)"); + + b.Property("MarkedAsAvailable") + .HasColumnType("datetime(6)"); + + b.Property("MarkedAsDenied") + .HasColumnType("datetime(6)"); + + b.Property("ParentRequestId") + .HasColumnType("int"); + + b.Property("RequestType") + .HasColumnType("int"); + + b.Property("RequestedByAlias") + .HasColumnType("longtext"); + + b.Property("RequestedDate") + .HasColumnType("datetime(6)"); + + b.Property("RequestedUserId") + .HasColumnType("varchar(255)"); + + b.Property("SeriesType") + .HasColumnType("int"); + + b.Property("Title") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.HasIndex("ParentRequestId"); + + b.HasIndex("RequestedUserId"); + + b.ToTable("ChildRequests"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.IssueCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.ToTable("IssueCategory"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.IssueComments", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Comment") + .HasColumnType("longtext"); + + b.Property("Date") + .HasColumnType("datetime(6)"); + + b.Property("IssuesId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("varchar(255)"); + + b.HasKey("Id"); + + b.HasIndex("IssuesId"); + + b.HasIndex("UserId"); + + b.ToTable("IssueComments"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.Issues", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("IssueCategoryId") + .HasColumnType("int"); + + b.Property("IssueId") + .HasColumnType("int"); + + b.Property("ProviderId") + .HasColumnType("longtext"); + + b.Property("RequestId") + .HasColumnType("int"); + + b.Property("RequestType") + .HasColumnType("int"); + + b.Property("ResovledDate") + .HasColumnType("datetime(6)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("Subject") + .HasColumnType("longtext"); + + b.Property("Title") + .HasColumnType("longtext"); + + b.Property("UserReportedId") + .HasColumnType("varchar(255)"); + + b.HasKey("Id"); + + b.HasIndex("IssueCategoryId"); + + b.HasIndex("IssueId"); + + b.HasIndex("UserReportedId"); + + b.ToTable("Issues"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.MovieRequests", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Approved") + .HasColumnType("tinyint(1)"); + + b.Property("Available") + .HasColumnType("tinyint(1)"); + + b.Property("Background") + .HasColumnType("longtext"); + + b.Property("Denied") + .HasColumnType("tinyint(1)"); + + b.Property("DeniedReason") + .HasColumnType("longtext"); + + b.Property("DigitalReleaseDate") + .HasColumnType("datetime(6)"); + + b.Property("ImdbId") + .HasColumnType("longtext"); + + b.Property("IssueId") + .HasColumnType("int"); + + b.Property("LangCode") + .HasColumnType("longtext"); + + b.Property("MarkedAsApproved") + .HasColumnType("datetime(6)"); + + b.Property("MarkedAsAvailable") + .HasColumnType("datetime(6)"); + + b.Property("MarkedAsDenied") + .HasColumnType("datetime(6)"); + + b.Property("Overview") + .HasColumnType("longtext"); + + b.Property("PosterPath") + .HasColumnType("longtext"); + + b.Property("QualityOverride") + .HasColumnType("int"); + + b.Property("ReleaseDate") + .HasColumnType("datetime(6)"); + + b.Property("RequestType") + .HasColumnType("int"); + + b.Property("RequestedByAlias") + .HasColumnType("longtext"); + + b.Property("RequestedDate") + .HasColumnType("datetime(6)"); + + b.Property("RequestedUserId") + .HasColumnType("varchar(255)"); + + b.Property("RootPathOverride") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("longtext"); + + b.Property("TheMovieDbId") + .HasColumnType("int"); + + b.Property("Title") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.HasIndex("RequestedUserId"); + + b.ToTable("MovieRequests"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.RequestLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("EpisodeCount") + .HasColumnType("int"); + + b.Property("RequestDate") + .HasColumnType("datetime(6)"); + + b.Property("RequestId") + .HasColumnType("int"); + + b.Property("RequestType") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("varchar(255)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("RequestLog"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.TvRequests", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Background") + .HasColumnType("longtext"); + + b.Property("ImdbId") + .HasColumnType("longtext"); + + b.Property("Overview") + .HasColumnType("longtext"); + + b.Property("PosterPath") + .HasColumnType("longtext"); + + b.Property("QualityOverride") + .HasColumnType("int"); + + b.Property("ReleaseDate") + .HasColumnType("datetime(6)"); + + b.Property("RootFolder") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("longtext"); + + b.Property("Title") + .HasColumnType("longtext"); + + b.Property("TotalSeasons") + .HasColumnType("int"); + + b.Property("TvDbId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("TvRequests"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Tokens", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Token") + .HasColumnType("longtext"); + + b.Property("UserId") + .HasColumnType("varchar(255)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Tokens"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.UserNotificationPreferences", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Agent") + .HasColumnType("int"); + + b.Property("Enabled") + .HasColumnType("tinyint(1)"); + + b.Property("UserId") + .HasColumnType("varchar(255)"); + + b.Property("Value") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserNotificationPreferences"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.UserQualityProfiles", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("RadarrQualityProfile") + .HasColumnType("int"); + + b.Property("RadarrRootPath") + .HasColumnType("int"); + + b.Property("SonarrQualityProfile") + .HasColumnType("int"); + + b.Property("SonarrQualityProfileAnime") + .HasColumnType("int"); + + b.Property("SonarrRootPath") + .HasColumnType("int"); + + b.Property("SonarrRootPathAnime") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("varchar(255)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserQualityProfiles"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Votes", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Date") + .HasColumnType("datetime(6)"); + + b.Property("Deleted") + .HasColumnType("tinyint(1)"); + + b.Property("RequestId") + .HasColumnType("int"); + + b.Property("RequestType") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("varchar(255)"); + + b.Property("VoteType") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Votes"); + }); + + modelBuilder.Entity("Ombi.Store.Repository.Requests.EpisodeRequests", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("AirDate") + .HasColumnType("datetime(6)"); + + b.Property("Approved") + .HasColumnType("tinyint(1)"); + + b.Property("Available") + .HasColumnType("tinyint(1)"); + + b.Property("EpisodeNumber") + .HasColumnType("int"); + + b.Property("Requested") + .HasColumnType("tinyint(1)"); + + b.Property("SeasonId") + .HasColumnType("int"); + + b.Property("Title") + .HasColumnType("longtext"); + + b.Property("Url") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.HasIndex("SeasonId"); + + b.ToTable("EpisodeRequests"); + }); + + modelBuilder.Entity("Ombi.Store.Repository.Requests.SeasonRequests", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("ChildRequestId") + .HasColumnType("int"); + + b.Property("SeasonNumber") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ChildRequestId"); + + b.ToTable("SeasonRequests"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Ombi.Store.Entities.OmbiUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Ombi.Store.Entities.MobileDevices", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", "User") + .WithMany() + .HasForeignKey("UserId"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.NotificationUserId", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", "User") + .WithMany("NotificationUserIds") + .HasForeignKey("UserId"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.RequestSubscription", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", "User") + .WithMany() + .HasForeignKey("UserId"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.AlbumRequest", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", "RequestedUser") + .WithMany() + .HasForeignKey("RequestedUserId"); + + b.Navigation("RequestedUser"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.ChildRequests", b => + { + b.HasOne("Ombi.Store.Entities.Requests.TvRequests", "ParentRequest") + .WithMany("ChildRequests") + .HasForeignKey("ParentRequestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Ombi.Store.Entities.OmbiUser", "RequestedUser") + .WithMany() + .HasForeignKey("RequestedUserId"); + + b.Navigation("ParentRequest"); + + b.Navigation("RequestedUser"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.IssueComments", b => + { + b.HasOne("Ombi.Store.Entities.Requests.Issues", "Issues") + .WithMany("Comments") + .HasForeignKey("IssuesId"); + + b.HasOne("Ombi.Store.Entities.OmbiUser", "User") + .WithMany() + .HasForeignKey("UserId"); + + b.Navigation("Issues"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.Issues", b => + { + b.HasOne("Ombi.Store.Entities.Requests.IssueCategory", "IssueCategory") + .WithMany() + .HasForeignKey("IssueCategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Ombi.Store.Entities.Requests.ChildRequests", null) + .WithMany("Issues") + .HasForeignKey("IssueId"); + + b.HasOne("Ombi.Store.Entities.Requests.MovieRequests", null) + .WithMany("Issues") + .HasForeignKey("IssueId"); + + b.HasOne("Ombi.Store.Entities.OmbiUser", "UserReported") + .WithMany() + .HasForeignKey("UserReportedId"); + + b.Navigation("IssueCategory"); + + b.Navigation("UserReported"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.MovieRequests", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", "RequestedUser") + .WithMany() + .HasForeignKey("RequestedUserId"); + + b.Navigation("RequestedUser"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.RequestLog", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", "User") + .WithMany() + .HasForeignKey("UserId"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Tokens", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", "User") + .WithMany() + .HasForeignKey("UserId"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.UserNotificationPreferences", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", "User") + .WithMany("UserNotificationPreferences") + .HasForeignKey("UserId"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.UserQualityProfiles", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", "User") + .WithMany() + .HasForeignKey("UserId"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Votes", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", "User") + .WithMany() + .HasForeignKey("UserId"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Ombi.Store.Repository.Requests.EpisodeRequests", b => + { + b.HasOne("Ombi.Store.Repository.Requests.SeasonRequests", "Season") + .WithMany("Episodes") + .HasForeignKey("SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("Ombi.Store.Repository.Requests.SeasonRequests", b => + { + b.HasOne("Ombi.Store.Entities.Requests.ChildRequests", "ChildRequest") + .WithMany("SeasonRequests") + .HasForeignKey("ChildRequestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ChildRequest"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.OmbiUser", b => + { + b.Navigation("NotificationUserIds"); + + b.Navigation("UserNotificationPreferences"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.ChildRequests", b => + { + b.Navigation("Issues"); + + b.Navigation("SeasonRequests"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.Issues", b => + { + b.Navigation("Comments"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.MovieRequests", b => + { + b.Navigation("Issues"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.TvRequests", b => + { + b.Navigation("ChildRequests"); + }); + + modelBuilder.Entity("Ombi.Store.Repository.Requests.SeasonRequests", b => + { + b.Navigation("Episodes"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Ombi.Store/Migrations/OmbiMySql/20210106132735_UserStreamingCountry.cs b/src/Ombi.Store/Migrations/OmbiMySql/20210106132735_UserStreamingCountry.cs new file mode 100644 index 000000000..1ee38e369 --- /dev/null +++ b/src/Ombi.Store/Migrations/OmbiMySql/20210106132735_UserStreamingCountry.cs @@ -0,0 +1,26 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +namespace Ombi.Store.Migrations.OmbiMySql +{ + public partial class UserStreamingCountry : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "StreamingCountry", + table: "AspNetUsers", + type: "longtext", + nullable: false, + defaultValue: "US"); + + migrationBuilder.Sql("UPDATE AspNetUsers SET StreamingCountry = 'US'"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "StreamingCountry", + table: "AspNetUsers"); + } + } +} diff --git a/src/Ombi.Store/Migrations/OmbiMySql/OmbiMySqlContextModelSnapshot.cs b/src/Ombi.Store/Migrations/OmbiMySql/OmbiMySqlContextModelSnapshot.cs index 1678a77c1..38487dc9f 100644 --- a/src/Ombi.Store/Migrations/OmbiMySql/OmbiMySqlContextModelSnapshot.cs +++ b/src/Ombi.Store/Migrations/OmbiMySql/OmbiMySqlContextModelSnapshot.cs @@ -14,8 +14,8 @@ namespace Ombi.Store.Migrations.OmbiMySql { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "3.1.1") - .HasAnnotation("Relational:MaxIdentifierLength", 64); + .HasAnnotation("Relational:MaxIdentifierLength", 64) + .HasAnnotation("ProductVersion", "5.0.1"); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => { @@ -27,18 +27,18 @@ namespace Ombi.Store.Migrations.OmbiMySql .HasColumnType("longtext"); b.Property("Name") - .HasColumnType("varchar(256)") - .HasMaxLength(256); + .HasMaxLength(256) + .HasColumnType("varchar(256)"); b.Property("NormalizedName") - .HasColumnType("varchar(256)") - .HasMaxLength(256); + .HasMaxLength(256) + .HasColumnType("varchar(256)"); b.HasKey("Id"); b.HasIndex("NormalizedName") .IsUnique() - .HasName("RoleNameIndex"); + .HasDatabaseName("RoleNameIndex"); b.ToTable("AspNetRoles"); }); @@ -257,8 +257,8 @@ namespace Ombi.Store.Migrations.OmbiMySql .HasColumnType("longtext"); b.Property("Email") - .HasColumnType("varchar(256)") - .HasMaxLength(256); + .HasMaxLength(256) + .HasColumnType("varchar(256)"); b.Property("EmailConfirmed") .HasColumnType("tinyint(1)"); @@ -285,12 +285,12 @@ namespace Ombi.Store.Migrations.OmbiMySql .HasColumnType("int"); b.Property("NormalizedEmail") - .HasColumnType("varchar(256)") - .HasMaxLength(256); + .HasMaxLength(256) + .HasColumnType("varchar(256)"); b.Property("NormalizedUserName") - .HasColumnType("varchar(256)") - .HasMaxLength(256); + .HasMaxLength(256) + .HasColumnType("varchar(256)"); b.Property("PasswordHash") .HasColumnType("longtext"); @@ -307,6 +307,9 @@ namespace Ombi.Store.Migrations.OmbiMySql b.Property("SecurityStamp") .HasColumnType("longtext"); + b.Property("StreamingCountry") + .HasColumnType("longtext"); + b.Property("TwoFactorEnabled") .HasColumnType("tinyint(1)"); @@ -314,8 +317,8 @@ namespace Ombi.Store.Migrations.OmbiMySql .HasColumnType("longtext"); b.Property("UserName") - .HasColumnType("varchar(256)") - .HasMaxLength(256); + .HasMaxLength(256) + .HasColumnType("varchar(256)"); b.Property("UserType") .HasColumnType("int"); @@ -323,11 +326,11 @@ namespace Ombi.Store.Migrations.OmbiMySql b.HasKey("Id"); b.HasIndex("NormalizedEmail") - .HasName("EmailIndex"); + .HasDatabaseName("EmailIndex"); b.HasIndex("NormalizedUserName") .IsUnique() - .HasName("UserNameIndex"); + .HasDatabaseName("UserNameIndex"); b.ToTable("AspNetUsers"); }); @@ -1017,6 +1020,8 @@ namespace Ombi.Store.Migrations.OmbiMySql b.HasOne("Ombi.Store.Entities.OmbiUser", "User") .WithMany() .HasForeignKey("UserId"); + + b.Navigation("User"); }); modelBuilder.Entity("Ombi.Store.Entities.NotificationUserId", b => @@ -1024,6 +1029,8 @@ namespace Ombi.Store.Migrations.OmbiMySql b.HasOne("Ombi.Store.Entities.OmbiUser", "User") .WithMany("NotificationUserIds") .HasForeignKey("UserId"); + + b.Navigation("User"); }); modelBuilder.Entity("Ombi.Store.Entities.RequestSubscription", b => @@ -1031,6 +1038,8 @@ namespace Ombi.Store.Migrations.OmbiMySql b.HasOne("Ombi.Store.Entities.OmbiUser", "User") .WithMany() .HasForeignKey("UserId"); + + b.Navigation("User"); }); modelBuilder.Entity("Ombi.Store.Entities.Requests.AlbumRequest", b => @@ -1038,6 +1047,8 @@ namespace Ombi.Store.Migrations.OmbiMySql b.HasOne("Ombi.Store.Entities.OmbiUser", "RequestedUser") .WithMany() .HasForeignKey("RequestedUserId"); + + b.Navigation("RequestedUser"); }); modelBuilder.Entity("Ombi.Store.Entities.Requests.ChildRequests", b => @@ -1051,6 +1062,10 @@ namespace Ombi.Store.Migrations.OmbiMySql b.HasOne("Ombi.Store.Entities.OmbiUser", "RequestedUser") .WithMany() .HasForeignKey("RequestedUserId"); + + b.Navigation("ParentRequest"); + + b.Navigation("RequestedUser"); }); modelBuilder.Entity("Ombi.Store.Entities.Requests.IssueComments", b => @@ -1062,6 +1077,10 @@ namespace Ombi.Store.Migrations.OmbiMySql b.HasOne("Ombi.Store.Entities.OmbiUser", "User") .WithMany() .HasForeignKey("UserId"); + + b.Navigation("Issues"); + + b.Navigation("User"); }); modelBuilder.Entity("Ombi.Store.Entities.Requests.Issues", b => @@ -1083,6 +1102,10 @@ namespace Ombi.Store.Migrations.OmbiMySql b.HasOne("Ombi.Store.Entities.OmbiUser", "UserReported") .WithMany() .HasForeignKey("UserReportedId"); + + b.Navigation("IssueCategory"); + + b.Navigation("UserReported"); }); modelBuilder.Entity("Ombi.Store.Entities.Requests.MovieRequests", b => @@ -1090,6 +1113,8 @@ namespace Ombi.Store.Migrations.OmbiMySql b.HasOne("Ombi.Store.Entities.OmbiUser", "RequestedUser") .WithMany() .HasForeignKey("RequestedUserId"); + + b.Navigation("RequestedUser"); }); modelBuilder.Entity("Ombi.Store.Entities.Requests.RequestLog", b => @@ -1097,6 +1122,8 @@ namespace Ombi.Store.Migrations.OmbiMySql b.HasOne("Ombi.Store.Entities.OmbiUser", "User") .WithMany() .HasForeignKey("UserId"); + + b.Navigation("User"); }); modelBuilder.Entity("Ombi.Store.Entities.Tokens", b => @@ -1104,6 +1131,8 @@ namespace Ombi.Store.Migrations.OmbiMySql b.HasOne("Ombi.Store.Entities.OmbiUser", "User") .WithMany() .HasForeignKey("UserId"); + + b.Navigation("User"); }); modelBuilder.Entity("Ombi.Store.Entities.UserNotificationPreferences", b => @@ -1111,6 +1140,8 @@ namespace Ombi.Store.Migrations.OmbiMySql b.HasOne("Ombi.Store.Entities.OmbiUser", "User") .WithMany("UserNotificationPreferences") .HasForeignKey("UserId"); + + b.Navigation("User"); }); modelBuilder.Entity("Ombi.Store.Entities.UserQualityProfiles", b => @@ -1118,6 +1149,8 @@ namespace Ombi.Store.Migrations.OmbiMySql b.HasOne("Ombi.Store.Entities.OmbiUser", "User") .WithMany() .HasForeignKey("UserId"); + + b.Navigation("User"); }); modelBuilder.Entity("Ombi.Store.Entities.Votes", b => @@ -1125,6 +1158,8 @@ namespace Ombi.Store.Migrations.OmbiMySql b.HasOne("Ombi.Store.Entities.OmbiUser", "User") .WithMany() .HasForeignKey("UserId"); + + b.Navigation("User"); }); modelBuilder.Entity("Ombi.Store.Repository.Requests.EpisodeRequests", b => @@ -1134,6 +1169,8 @@ namespace Ombi.Store.Migrations.OmbiMySql .HasForeignKey("SeasonId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + + b.Navigation("Season"); }); modelBuilder.Entity("Ombi.Store.Repository.Requests.SeasonRequests", b => @@ -1143,6 +1180,42 @@ namespace Ombi.Store.Migrations.OmbiMySql .HasForeignKey("ChildRequestId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + + b.Navigation("ChildRequest"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.OmbiUser", b => + { + b.Navigation("NotificationUserIds"); + + b.Navigation("UserNotificationPreferences"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.ChildRequests", b => + { + b.Navigation("Issues"); + + b.Navigation("SeasonRequests"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.Issues", b => + { + b.Navigation("Comments"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.MovieRequests", b => + { + b.Navigation("Issues"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.TvRequests", b => + { + b.Navigation("ChildRequests"); + }); + + modelBuilder.Entity("Ombi.Store.Repository.Requests.SeasonRequests", b => + { + b.Navigation("Episodes"); }); #pragma warning restore 612, 618 } diff --git a/src/Ombi.Store/Migrations/OmbiSqlite/20210106134000_UserStreamingCountry.Designer.cs b/src/Ombi.Store/Migrations/OmbiSqlite/20210106134000_UserStreamingCountry.Designer.cs new file mode 100644 index 000000000..e9c6e1f20 --- /dev/null +++ b/src/Ombi.Store/Migrations/OmbiSqlite/20210106134000_UserStreamingCountry.Designer.cs @@ -0,0 +1,1225 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Ombi.Store.Context.Sqlite; + +namespace Ombi.Store.Migrations.OmbiSqlite +{ + [DbContext(typeof(OmbiSqliteContext))] + [Migration("20210106134000_UserStreamingCountry")] + partial class UserStreamingCountry + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "5.0.1"); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .HasColumnType("TEXT"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("TEXT"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("AspNetRoles"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClaimType") + .HasColumnType("TEXT"); + + b.Property("ClaimValue") + .HasColumnType("TEXT"); + + b.Property("RoleId") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClaimType") + .HasColumnType("TEXT"); + + b.Property("ClaimValue") + .HasColumnType("TEXT"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("TEXT"); + + b.Property("ProviderKey") + .HasColumnType("TEXT"); + + b.Property("ProviderDisplayName") + .HasColumnType("TEXT"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("TEXT"); + + b.Property("RoleId") + .HasColumnType("TEXT"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("TEXT"); + + b.Property("LoginProvider") + .HasColumnType("TEXT"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("Value") + .HasColumnType("TEXT"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Audit", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AuditArea") + .HasColumnType("INTEGER"); + + b.Property("AuditType") + .HasColumnType("INTEGER"); + + b.Property("DateTime") + .HasColumnType("TEXT"); + + b.Property("Description") + .HasColumnType("TEXT"); + + b.Property("User") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("Audit"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.MobileDevices", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AddedAt") + .HasColumnType("TEXT"); + + b.Property("Token") + .HasColumnType("TEXT"); + + b.Property("UserId") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("MobileDevices"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.NotificationTemplates", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Agent") + .HasColumnType("INTEGER"); + + b.Property("Enabled") + .HasColumnType("INTEGER"); + + b.Property("Message") + .HasColumnType("TEXT"); + + b.Property("NotificationType") + .HasColumnType("INTEGER"); + + b.Property("Subject") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("NotificationTemplates"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.NotificationUserId", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AddedAt") + .HasColumnType("TEXT"); + + b.Property("PlayerId") + .HasColumnType("TEXT"); + + b.Property("UserId") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("NotificationUserId"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.OmbiUser", b => + { + b.Property("Id") + .HasColumnType("TEXT"); + + b.Property("AccessFailedCount") + .HasColumnType("INTEGER"); + + b.Property("Alias") + .HasColumnType("TEXT"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("TEXT"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("EmailConfirmed") + .HasColumnType("INTEGER"); + + b.Property("EpisodeRequestLimit") + .HasColumnType("INTEGER"); + + b.Property("Language") + .HasColumnType("TEXT"); + + b.Property("LastLoggedIn") + .HasColumnType("TEXT"); + + b.Property("LockoutEnabled") + .HasColumnType("INTEGER"); + + b.Property("LockoutEnd") + .HasColumnType("TEXT"); + + b.Property("MovieRequestLimit") + .HasColumnType("INTEGER"); + + b.Property("MusicRequestLimit") + .HasColumnType("INTEGER"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("PasswordHash") + .HasColumnType("TEXT"); + + b.Property("PhoneNumber") + .HasColumnType("TEXT"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("INTEGER"); + + b.Property("ProviderUserId") + .HasColumnType("TEXT"); + + b.Property("SecurityStamp") + .HasColumnType("TEXT"); + + b.Property("StreamingCountry") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("TwoFactorEnabled") + .HasColumnType("INTEGER"); + + b.Property("UserAccessToken") + .HasColumnType("TEXT"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("UserType") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex"); + + b.ToTable("AspNetUsers"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.RecentlyAddedLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AddedAt") + .HasColumnType("TEXT"); + + b.Property("AlbumId") + .HasColumnType("TEXT"); + + b.Property("ContentId") + .HasColumnType("INTEGER"); + + b.Property("ContentType") + .HasColumnType("INTEGER"); + + b.Property("EpisodeNumber") + .HasColumnType("INTEGER"); + + b.Property("SeasonNumber") + .HasColumnType("INTEGER"); + + b.Property("Type") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.ToTable("RecentlyAddedLog"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.RequestQueue", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Completed") + .HasColumnType("TEXT"); + + b.Property("Dts") + .HasColumnType("TEXT"); + + b.Property("Error") + .HasColumnType("TEXT"); + + b.Property("RequestId") + .HasColumnType("INTEGER"); + + b.Property("RetryCount") + .HasColumnType("INTEGER"); + + b.Property("Type") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.ToTable("RequestQueue"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.RequestSubscription", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("RequestId") + .HasColumnType("INTEGER"); + + b.Property("RequestType") + .HasColumnType("INTEGER"); + + b.Property("UserId") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("RequestSubscription"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.AlbumRequest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Approved") + .HasColumnType("INTEGER"); + + b.Property("ArtistName") + .HasColumnType("TEXT"); + + b.Property("Available") + .HasColumnType("INTEGER"); + + b.Property("Cover") + .HasColumnType("TEXT"); + + b.Property("Denied") + .HasColumnType("INTEGER"); + + b.Property("DeniedReason") + .HasColumnType("TEXT"); + + b.Property("Disk") + .HasColumnType("TEXT"); + + b.Property("ForeignAlbumId") + .HasColumnType("TEXT"); + + b.Property("ForeignArtistId") + .HasColumnType("TEXT"); + + b.Property("MarkedAsApproved") + .HasColumnType("TEXT"); + + b.Property("MarkedAsAvailable") + .HasColumnType("TEXT"); + + b.Property("MarkedAsDenied") + .HasColumnType("TEXT"); + + b.Property("Rating") + .HasColumnType("TEXT"); + + b.Property("ReleaseDate") + .HasColumnType("TEXT"); + + b.Property("RequestType") + .HasColumnType("INTEGER"); + + b.Property("RequestedByAlias") + .HasColumnType("TEXT"); + + b.Property("RequestedDate") + .HasColumnType("TEXT"); + + b.Property("RequestedUserId") + .HasColumnType("TEXT"); + + b.Property("Title") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("RequestedUserId"); + + b.ToTable("AlbumRequests"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.ChildRequests", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Approved") + .HasColumnType("INTEGER"); + + b.Property("Available") + .HasColumnType("INTEGER"); + + b.Property("Denied") + .HasColumnType("INTEGER"); + + b.Property("DeniedReason") + .HasColumnType("TEXT"); + + b.Property("IssueId") + .HasColumnType("INTEGER"); + + b.Property("MarkedAsApproved") + .HasColumnType("TEXT"); + + b.Property("MarkedAsAvailable") + .HasColumnType("TEXT"); + + b.Property("MarkedAsDenied") + .HasColumnType("TEXT"); + + b.Property("ParentRequestId") + .HasColumnType("INTEGER"); + + b.Property("RequestType") + .HasColumnType("INTEGER"); + + b.Property("RequestedByAlias") + .HasColumnType("TEXT"); + + b.Property("RequestedDate") + .HasColumnType("TEXT"); + + b.Property("RequestedUserId") + .HasColumnType("TEXT"); + + b.Property("SeriesType") + .HasColumnType("INTEGER"); + + b.Property("Title") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ParentRequestId"); + + b.HasIndex("RequestedUserId"); + + b.ToTable("ChildRequests"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.IssueCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Value") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("IssueCategory"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.IssueComments", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Comment") + .HasColumnType("TEXT"); + + b.Property("Date") + .HasColumnType("TEXT"); + + b.Property("IssuesId") + .HasColumnType("INTEGER"); + + b.Property("UserId") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("IssuesId"); + + b.HasIndex("UserId"); + + b.ToTable("IssueComments"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.Issues", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CreatedDate") + .HasColumnType("TEXT"); + + b.Property("Description") + .HasColumnType("TEXT"); + + b.Property("IssueCategoryId") + .HasColumnType("INTEGER"); + + b.Property("IssueId") + .HasColumnType("INTEGER"); + + b.Property("ProviderId") + .HasColumnType("TEXT"); + + b.Property("RequestId") + .HasColumnType("INTEGER"); + + b.Property("RequestType") + .HasColumnType("INTEGER"); + + b.Property("ResovledDate") + .HasColumnType("TEXT"); + + b.Property("Status") + .HasColumnType("INTEGER"); + + b.Property("Subject") + .HasColumnType("TEXT"); + + b.Property("Title") + .HasColumnType("TEXT"); + + b.Property("UserReportedId") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("IssueCategoryId"); + + b.HasIndex("IssueId"); + + b.HasIndex("UserReportedId"); + + b.ToTable("Issues"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.MovieRequests", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Approved") + .HasColumnType("INTEGER"); + + b.Property("Available") + .HasColumnType("INTEGER"); + + b.Property("Background") + .HasColumnType("TEXT"); + + b.Property("Denied") + .HasColumnType("INTEGER"); + + b.Property("DeniedReason") + .HasColumnType("TEXT"); + + b.Property("DigitalReleaseDate") + .HasColumnType("TEXT"); + + b.Property("ImdbId") + .HasColumnType("TEXT"); + + b.Property("IssueId") + .HasColumnType("INTEGER"); + + b.Property("LangCode") + .HasColumnType("TEXT"); + + b.Property("MarkedAsApproved") + .HasColumnType("TEXT"); + + b.Property("MarkedAsAvailable") + .HasColumnType("TEXT"); + + b.Property("MarkedAsDenied") + .HasColumnType("TEXT"); + + b.Property("Overview") + .HasColumnType("TEXT"); + + b.Property("PosterPath") + .HasColumnType("TEXT"); + + b.Property("QualityOverride") + .HasColumnType("INTEGER"); + + b.Property("ReleaseDate") + .HasColumnType("TEXT"); + + b.Property("RequestType") + .HasColumnType("INTEGER"); + + b.Property("RequestedByAlias") + .HasColumnType("TEXT"); + + b.Property("RequestedDate") + .HasColumnType("TEXT"); + + b.Property("RequestedUserId") + .HasColumnType("TEXT"); + + b.Property("RootPathOverride") + .HasColumnType("INTEGER"); + + b.Property("Status") + .HasColumnType("TEXT"); + + b.Property("TheMovieDbId") + .HasColumnType("INTEGER"); + + b.Property("Title") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("RequestedUserId"); + + b.ToTable("MovieRequests"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.RequestLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("EpisodeCount") + .HasColumnType("INTEGER"); + + b.Property("RequestDate") + .HasColumnType("TEXT"); + + b.Property("RequestId") + .HasColumnType("INTEGER"); + + b.Property("RequestType") + .HasColumnType("INTEGER"); + + b.Property("UserId") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("RequestLog"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.TvRequests", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Background") + .HasColumnType("TEXT"); + + b.Property("ImdbId") + .HasColumnType("TEXT"); + + b.Property("Overview") + .HasColumnType("TEXT"); + + b.Property("PosterPath") + .HasColumnType("TEXT"); + + b.Property("QualityOverride") + .HasColumnType("INTEGER"); + + b.Property("ReleaseDate") + .HasColumnType("TEXT"); + + b.Property("RootFolder") + .HasColumnType("INTEGER"); + + b.Property("Status") + .HasColumnType("TEXT"); + + b.Property("Title") + .HasColumnType("TEXT"); + + b.Property("TotalSeasons") + .HasColumnType("INTEGER"); + + b.Property("TvDbId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.ToTable("TvRequests"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Tokens", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Token") + .HasColumnType("TEXT"); + + b.Property("UserId") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Tokens"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.UserNotificationPreferences", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Agent") + .HasColumnType("INTEGER"); + + b.Property("Enabled") + .HasColumnType("INTEGER"); + + b.Property("UserId") + .HasColumnType("TEXT"); + + b.Property("Value") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserNotificationPreferences"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.UserQualityProfiles", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("RadarrQualityProfile") + .HasColumnType("INTEGER"); + + b.Property("RadarrRootPath") + .HasColumnType("INTEGER"); + + b.Property("SonarrQualityProfile") + .HasColumnType("INTEGER"); + + b.Property("SonarrQualityProfileAnime") + .HasColumnType("INTEGER"); + + b.Property("SonarrRootPath") + .HasColumnType("INTEGER"); + + b.Property("SonarrRootPathAnime") + .HasColumnType("INTEGER"); + + b.Property("UserId") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserQualityProfiles"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Votes", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Date") + .HasColumnType("TEXT"); + + b.Property("Deleted") + .HasColumnType("INTEGER"); + + b.Property("RequestId") + .HasColumnType("INTEGER"); + + b.Property("RequestType") + .HasColumnType("INTEGER"); + + b.Property("UserId") + .HasColumnType("TEXT"); + + b.Property("VoteType") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Votes"); + }); + + modelBuilder.Entity("Ombi.Store.Repository.Requests.EpisodeRequests", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AirDate") + .HasColumnType("TEXT"); + + b.Property("Approved") + .HasColumnType("INTEGER"); + + b.Property("Available") + .HasColumnType("INTEGER"); + + b.Property("EpisodeNumber") + .HasColumnType("INTEGER"); + + b.Property("Requested") + .HasColumnType("INTEGER"); + + b.Property("SeasonId") + .HasColumnType("INTEGER"); + + b.Property("Title") + .HasColumnType("TEXT"); + + b.Property("Url") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("SeasonId"); + + b.ToTable("EpisodeRequests"); + }); + + modelBuilder.Entity("Ombi.Store.Repository.Requests.SeasonRequests", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ChildRequestId") + .HasColumnType("INTEGER"); + + b.Property("SeasonNumber") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ChildRequestId"); + + b.ToTable("SeasonRequests"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Ombi.Store.Entities.OmbiUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Ombi.Store.Entities.MobileDevices", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", "User") + .WithMany() + .HasForeignKey("UserId"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.NotificationUserId", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", "User") + .WithMany("NotificationUserIds") + .HasForeignKey("UserId"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.RequestSubscription", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", "User") + .WithMany() + .HasForeignKey("UserId"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.AlbumRequest", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", "RequestedUser") + .WithMany() + .HasForeignKey("RequestedUserId"); + + b.Navigation("RequestedUser"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.ChildRequests", b => + { + b.HasOne("Ombi.Store.Entities.Requests.TvRequests", "ParentRequest") + .WithMany("ChildRequests") + .HasForeignKey("ParentRequestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Ombi.Store.Entities.OmbiUser", "RequestedUser") + .WithMany() + .HasForeignKey("RequestedUserId"); + + b.Navigation("ParentRequest"); + + b.Navigation("RequestedUser"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.IssueComments", b => + { + b.HasOne("Ombi.Store.Entities.Requests.Issues", "Issues") + .WithMany("Comments") + .HasForeignKey("IssuesId"); + + b.HasOne("Ombi.Store.Entities.OmbiUser", "User") + .WithMany() + .HasForeignKey("UserId"); + + b.Navigation("Issues"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.Issues", b => + { + b.HasOne("Ombi.Store.Entities.Requests.IssueCategory", "IssueCategory") + .WithMany() + .HasForeignKey("IssueCategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Ombi.Store.Entities.Requests.ChildRequests", null) + .WithMany("Issues") + .HasForeignKey("IssueId"); + + b.HasOne("Ombi.Store.Entities.Requests.MovieRequests", null) + .WithMany("Issues") + .HasForeignKey("IssueId"); + + b.HasOne("Ombi.Store.Entities.OmbiUser", "UserReported") + .WithMany() + .HasForeignKey("UserReportedId"); + + b.Navigation("IssueCategory"); + + b.Navigation("UserReported"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.MovieRequests", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", "RequestedUser") + .WithMany() + .HasForeignKey("RequestedUserId"); + + b.Navigation("RequestedUser"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.RequestLog", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", "User") + .WithMany() + .HasForeignKey("UserId"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Tokens", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", "User") + .WithMany() + .HasForeignKey("UserId"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.UserNotificationPreferences", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", "User") + .WithMany("UserNotificationPreferences") + .HasForeignKey("UserId"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.UserQualityProfiles", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", "User") + .WithMany() + .HasForeignKey("UserId"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Votes", b => + { + b.HasOne("Ombi.Store.Entities.OmbiUser", "User") + .WithMany() + .HasForeignKey("UserId"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Ombi.Store.Repository.Requests.EpisodeRequests", b => + { + b.HasOne("Ombi.Store.Repository.Requests.SeasonRequests", "Season") + .WithMany("Episodes") + .HasForeignKey("SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("Ombi.Store.Repository.Requests.SeasonRequests", b => + { + b.HasOne("Ombi.Store.Entities.Requests.ChildRequests", "ChildRequest") + .WithMany("SeasonRequests") + .HasForeignKey("ChildRequestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ChildRequest"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.OmbiUser", b => + { + b.Navigation("NotificationUserIds"); + + b.Navigation("UserNotificationPreferences"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.ChildRequests", b => + { + b.Navigation("Issues"); + + b.Navigation("SeasonRequests"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.Issues", b => + { + b.Navigation("Comments"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.MovieRequests", b => + { + b.Navigation("Issues"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.TvRequests", b => + { + b.Navigation("ChildRequests"); + }); + + modelBuilder.Entity("Ombi.Store.Repository.Requests.SeasonRequests", b => + { + b.Navigation("Episodes"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Ombi.Store/Migrations/OmbiSqlite/20210106134000_UserStreamingCountry.cs b/src/Ombi.Store/Migrations/OmbiSqlite/20210106134000_UserStreamingCountry.cs new file mode 100644 index 000000000..3e5ff7651 --- /dev/null +++ b/src/Ombi.Store/Migrations/OmbiSqlite/20210106134000_UserStreamingCountry.cs @@ -0,0 +1,26 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +namespace Ombi.Store.Migrations.OmbiSqlite +{ + public partial class UserStreamingCountry : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "StreamingCountry", + table: "AspNetUsers", + type: "TEXT", + nullable: false, + defaultValue: "US"); + + migrationBuilder.Sql("UPDATE AspNetUsers SET StreamingCountry = 'US'"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "StreamingCountry", + table: "AspNetUsers"); + } + } +} diff --git a/src/Ombi.Store/Migrations/OmbiSqlite/OmbiSqliteContextModelSnapshot.cs b/src/Ombi.Store/Migrations/OmbiSqlite/OmbiSqliteContextModelSnapshot.cs index 7e9457be4..6a00fe29b 100644 --- a/src/Ombi.Store/Migrations/OmbiSqlite/OmbiSqliteContextModelSnapshot.cs +++ b/src/Ombi.Store/Migrations/OmbiSqlite/OmbiSqliteContextModelSnapshot.cs @@ -14,7 +14,7 @@ namespace Ombi.Store.Migrations.OmbiSqlite { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "3.1.1"); + .HasAnnotation("ProductVersion", "5.0.1"); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => { @@ -26,18 +26,18 @@ namespace Ombi.Store.Migrations.OmbiSqlite .HasColumnType("TEXT"); b.Property("Name") - .HasColumnType("TEXT") - .HasMaxLength(256); + .HasMaxLength(256) + .HasColumnType("TEXT"); b.Property("NormalizedName") - .HasColumnType("TEXT") - .HasMaxLength(256); + .HasMaxLength(256) + .HasColumnType("TEXT"); b.HasKey("Id"); b.HasIndex("NormalizedName") .IsUnique() - .HasName("RoleNameIndex"); + .HasDatabaseName("RoleNameIndex"); b.ToTable("AspNetRoles"); }); @@ -256,8 +256,8 @@ namespace Ombi.Store.Migrations.OmbiSqlite .HasColumnType("TEXT"); b.Property("Email") - .HasColumnType("TEXT") - .HasMaxLength(256); + .HasMaxLength(256) + .HasColumnType("TEXT"); b.Property("EmailConfirmed") .HasColumnType("INTEGER"); @@ -284,12 +284,12 @@ namespace Ombi.Store.Migrations.OmbiSqlite .HasColumnType("INTEGER"); b.Property("NormalizedEmail") - .HasColumnType("TEXT") - .HasMaxLength(256); + .HasMaxLength(256) + .HasColumnType("TEXT"); b.Property("NormalizedUserName") - .HasColumnType("TEXT") - .HasMaxLength(256); + .HasMaxLength(256) + .HasColumnType("TEXT"); b.Property("PasswordHash") .HasColumnType("TEXT"); @@ -306,6 +306,10 @@ namespace Ombi.Store.Migrations.OmbiSqlite b.Property("SecurityStamp") .HasColumnType("TEXT"); + b.Property("StreamingCountry") + .IsRequired() + .HasColumnType("TEXT"); + b.Property("TwoFactorEnabled") .HasColumnType("INTEGER"); @@ -313,8 +317,8 @@ namespace Ombi.Store.Migrations.OmbiSqlite .HasColumnType("TEXT"); b.Property("UserName") - .HasColumnType("TEXT") - .HasMaxLength(256); + .HasMaxLength(256) + .HasColumnType("TEXT"); b.Property("UserType") .HasColumnType("INTEGER"); @@ -322,11 +326,11 @@ namespace Ombi.Store.Migrations.OmbiSqlite b.HasKey("Id"); b.HasIndex("NormalizedEmail") - .HasName("EmailIndex"); + .HasDatabaseName("EmailIndex"); b.HasIndex("NormalizedUserName") .IsUnique() - .HasName("UserNameIndex"); + .HasDatabaseName("UserNameIndex"); b.ToTable("AspNetUsers"); }); @@ -1016,6 +1020,8 @@ namespace Ombi.Store.Migrations.OmbiSqlite b.HasOne("Ombi.Store.Entities.OmbiUser", "User") .WithMany() .HasForeignKey("UserId"); + + b.Navigation("User"); }); modelBuilder.Entity("Ombi.Store.Entities.NotificationUserId", b => @@ -1023,6 +1029,8 @@ namespace Ombi.Store.Migrations.OmbiSqlite b.HasOne("Ombi.Store.Entities.OmbiUser", "User") .WithMany("NotificationUserIds") .HasForeignKey("UserId"); + + b.Navigation("User"); }); modelBuilder.Entity("Ombi.Store.Entities.RequestSubscription", b => @@ -1030,6 +1038,8 @@ namespace Ombi.Store.Migrations.OmbiSqlite b.HasOne("Ombi.Store.Entities.OmbiUser", "User") .WithMany() .HasForeignKey("UserId"); + + b.Navigation("User"); }); modelBuilder.Entity("Ombi.Store.Entities.Requests.AlbumRequest", b => @@ -1037,6 +1047,8 @@ namespace Ombi.Store.Migrations.OmbiSqlite b.HasOne("Ombi.Store.Entities.OmbiUser", "RequestedUser") .WithMany() .HasForeignKey("RequestedUserId"); + + b.Navigation("RequestedUser"); }); modelBuilder.Entity("Ombi.Store.Entities.Requests.ChildRequests", b => @@ -1050,6 +1062,10 @@ namespace Ombi.Store.Migrations.OmbiSqlite b.HasOne("Ombi.Store.Entities.OmbiUser", "RequestedUser") .WithMany() .HasForeignKey("RequestedUserId"); + + b.Navigation("ParentRequest"); + + b.Navigation("RequestedUser"); }); modelBuilder.Entity("Ombi.Store.Entities.Requests.IssueComments", b => @@ -1061,6 +1077,10 @@ namespace Ombi.Store.Migrations.OmbiSqlite b.HasOne("Ombi.Store.Entities.OmbiUser", "User") .WithMany() .HasForeignKey("UserId"); + + b.Navigation("Issues"); + + b.Navigation("User"); }); modelBuilder.Entity("Ombi.Store.Entities.Requests.Issues", b => @@ -1082,6 +1102,10 @@ namespace Ombi.Store.Migrations.OmbiSqlite b.HasOne("Ombi.Store.Entities.OmbiUser", "UserReported") .WithMany() .HasForeignKey("UserReportedId"); + + b.Navigation("IssueCategory"); + + b.Navigation("UserReported"); }); modelBuilder.Entity("Ombi.Store.Entities.Requests.MovieRequests", b => @@ -1089,6 +1113,8 @@ namespace Ombi.Store.Migrations.OmbiSqlite b.HasOne("Ombi.Store.Entities.OmbiUser", "RequestedUser") .WithMany() .HasForeignKey("RequestedUserId"); + + b.Navigation("RequestedUser"); }); modelBuilder.Entity("Ombi.Store.Entities.Requests.RequestLog", b => @@ -1096,6 +1122,8 @@ namespace Ombi.Store.Migrations.OmbiSqlite b.HasOne("Ombi.Store.Entities.OmbiUser", "User") .WithMany() .HasForeignKey("UserId"); + + b.Navigation("User"); }); modelBuilder.Entity("Ombi.Store.Entities.Tokens", b => @@ -1103,6 +1131,8 @@ namespace Ombi.Store.Migrations.OmbiSqlite b.HasOne("Ombi.Store.Entities.OmbiUser", "User") .WithMany() .HasForeignKey("UserId"); + + b.Navigation("User"); }); modelBuilder.Entity("Ombi.Store.Entities.UserNotificationPreferences", b => @@ -1110,6 +1140,8 @@ namespace Ombi.Store.Migrations.OmbiSqlite b.HasOne("Ombi.Store.Entities.OmbiUser", "User") .WithMany("UserNotificationPreferences") .HasForeignKey("UserId"); + + b.Navigation("User"); }); modelBuilder.Entity("Ombi.Store.Entities.UserQualityProfiles", b => @@ -1117,6 +1149,8 @@ namespace Ombi.Store.Migrations.OmbiSqlite b.HasOne("Ombi.Store.Entities.OmbiUser", "User") .WithMany() .HasForeignKey("UserId"); + + b.Navigation("User"); }); modelBuilder.Entity("Ombi.Store.Entities.Votes", b => @@ -1124,6 +1158,8 @@ namespace Ombi.Store.Migrations.OmbiSqlite b.HasOne("Ombi.Store.Entities.OmbiUser", "User") .WithMany() .HasForeignKey("UserId"); + + b.Navigation("User"); }); modelBuilder.Entity("Ombi.Store.Repository.Requests.EpisodeRequests", b => @@ -1133,6 +1169,8 @@ namespace Ombi.Store.Migrations.OmbiSqlite .HasForeignKey("SeasonId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + + b.Navigation("Season"); }); modelBuilder.Entity("Ombi.Store.Repository.Requests.SeasonRequests", b => @@ -1142,6 +1180,42 @@ namespace Ombi.Store.Migrations.OmbiSqlite .HasForeignKey("ChildRequestId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + + b.Navigation("ChildRequest"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.OmbiUser", b => + { + b.Navigation("NotificationUserIds"); + + b.Navigation("UserNotificationPreferences"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.ChildRequests", b => + { + b.Navigation("Issues"); + + b.Navigation("SeasonRequests"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.Issues", b => + { + b.Navigation("Comments"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.MovieRequests", b => + { + b.Navigation("Issues"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.Requests.TvRequests", b => + { + b.Navigation("ChildRequests"); + }); + + modelBuilder.Entity("Ombi.Store.Repository.Requests.SeasonRequests", b => + { + b.Navigation("Episodes"); }); #pragma warning restore 612, 618 } diff --git a/src/Ombi.TheMovieDbApi/IMovieDbApi.cs b/src/Ombi.TheMovieDbApi/IMovieDbApi.cs index c9e21c2ec..1b35381ad 100644 --- a/src/Ombi.TheMovieDbApi/IMovieDbApi.cs +++ b/src/Ombi.TheMovieDbApi/IMovieDbApi.cs @@ -13,7 +13,7 @@ namespace Ombi.Api.TheMovieDb Task> NowPlaying(string languageCode, int? page = null); Task> PopularMovies(string languageCode, int? page = null, CancellationToken cancellationToken = default(CancellationToken)); Task> SearchMovie(string searchTerm, int? year, string languageCode); - Task> SearchTv(string searchTerm); + Task> SearchTv(string searchTerm, string year = default); Task> TopRated(string languageCode, int? page = null); Task> Upcoming(string languageCode, int? page = null); Task> SimilarMovies(int movieId, string langCode); @@ -28,5 +28,7 @@ namespace Ombi.Api.TheMovieDb Task GetCollection(string langCode, int collectionId, CancellationToken cancellationToken); Task> SearchKeyword(string searchTerm); Task GetKeyword(int keywordId); + Task GetMovieWatchProviders(int theMoviedbId, CancellationToken token); + Task GetTvWatchProviders(int theMoviedbId, CancellationToken token); } } \ No newline at end of file diff --git a/src/Ombi.TheMovieDbApi/Models/WatchProviders.cs b/src/Ombi.TheMovieDbApi/Models/WatchProviders.cs new file mode 100644 index 000000000..bcd4c2418 --- /dev/null +++ b/src/Ombi.TheMovieDbApi/Models/WatchProviders.cs @@ -0,0 +1,77 @@ +using Newtonsoft.Json; +using System.Collections.Generic; + +namespace Ombi.Api.TheMovieDb.Models +{ + public class WatchProviders + { + [JsonProperty("id")] + public int Id { get; set; } + [JsonProperty("results")] + public Results Results { get; set; } + } + + public class Results + { + public WatchProviderData AR { get; set; } + public WatchProviderData AT { get; set; } + public WatchProviderData AU { get; set; } + public WatchProviderData BE { get; set; } + public WatchProviderData BR { get; set; } + public WatchProviderData CA { get; set; } + public WatchProviderData CH { get; set; } + public WatchProviderData CL { get; set; } + public WatchProviderData CO { get; set; } + public WatchProviderData CZ { get; set; } + public WatchProviderData DE { get; set; } + public WatchProviderData DK { get; set; } + public WatchProviderData EC { get; set; } + public WatchProviderData EE { get; set; } + public WatchProviderData ES { get; set; } + public WatchProviderData FI { get; set; } + public WatchProviderData FR { get; set; } + public WatchProviderData GB { get; set; } + public WatchProviderData GR { get; set; } + public WatchProviderData HU { get; set; } + public WatchProviderData ID { get; set; } + public WatchProviderData IE { get; set; } + public WatchProviderData IN { get; set; } + public WatchProviderData IT { get; set; } + public WatchProviderData JP { get; set; } + public WatchProviderData KR { get; set; } + public WatchProviderData LT { get; set; } + public WatchProviderData LV { get; set; } + public WatchProviderData MX { get; set; } + public WatchProviderData MY { get; set; } + public WatchProviderData NL { get; set; } + public WatchProviderData NO { get; set; } + public WatchProviderData NZ { get; set; } + public WatchProviderData PE { get; set; } + public WatchProviderData PH { get; set; } + public WatchProviderData PL { get; set; } + public WatchProviderData PT { get; set; } + public WatchProviderData RU { get; set; } + public WatchProviderData SE { get; set; } + public WatchProviderData SG { get; set; } + public WatchProviderData TH { get; set; } + public WatchProviderData TR { get; set; } + public WatchProviderData US { get; set; } + public WatchProviderData VE { get; set; } + public WatchProviderData ZA { get; set; } + } + + public class WatchProviderData + { + public string link { get; set; } + [JsonProperty("flatrate")] + public List StreamInformation { get; set; } + } + + public class StreamData + { + public int display_priority { get; set; } + public string logo_path { get; set; } + public int provider_id { get; set; } + public string provider_name { get; set; } + } +} diff --git a/src/Ombi.TheMovieDbApi/TheMovieDbApi.cs b/src/Ombi.TheMovieDbApi/TheMovieDbApi.cs index c9deede55..f270ad3b2 100644 --- a/src/Ombi.TheMovieDbApi/TheMovieDbApi.cs +++ b/src/Ombi.TheMovieDbApi/TheMovieDbApi.cs @@ -10,6 +10,7 @@ using Nito.AsyncEx; using Ombi.Api.TheMovieDb.Models; using Ombi.Core.Settings; using Ombi.Core.Settings.Models.External; +using Ombi.Helpers; using Ombi.TheMovieDbApi.Models; namespace Ombi.Api.TheMovieDb @@ -24,7 +25,7 @@ namespace Ombi.Api.TheMovieDb } private const string ApiToken = "b8eabaf5608b88d0298aa189dd90bf00"; - private const string BaseUri ="http://api.themoviedb.org/3/"; + private const string BaseUri = "http://api.themoviedb.org/3/"; private IMapper Mapper { get; } private IApi Api { get; } private AsyncLazy Settings { get; } @@ -107,11 +108,15 @@ namespace Ombi.Api.TheMovieDb return result; } - public async Task> SearchTv(string searchTerm) + public async Task> SearchTv(string searchTerm, string year = default) { var request = new Request($"search/tv", BaseUri, HttpMethod.Get); request.AddQueryString("api_key", ApiToken); request.AddQueryString("query", searchTerm); + if (year.HasValue()) + { + request.AddQueryString("first_air_date_year", year); + } AddRetry(request); var result = await Api.Request>(request); @@ -126,7 +131,7 @@ namespace Ombi.Api.TheMovieDb return await Api.Request(request); } - + public async Task> SimilarMovies(int movieId, string langCode) { var request = new Request($"movie/{movieId}/similar", BaseUri, HttpMethod.Get); @@ -165,7 +170,7 @@ namespace Ombi.Api.TheMovieDb AddRetry(request); - var result = await Api.Request>(request); + var result = await Api.Request>(request); return Mapper.Map>(result.results); } @@ -299,6 +304,32 @@ namespace Ombi.Api.TheMovieDb return keyword == null || keyword.Id == 0 ? null : keyword; } + public Task> MultiSearch(string searchTerm, string languageCode, CancellationToken cancellationToken) + { + var request = new Request("search/multi", BaseUri, HttpMethod.Get); + request.AddQueryString("api_key", ApiToken); + request.AddQueryString("language", languageCode); + request.AddQueryString("query", searchTerm); + var result = Api.Request>(request, cancellationToken); + return result; + } + + public Task GetMovieWatchProviders(int theMoviedbId, CancellationToken token) + { + var request = new Request($"movie/{theMoviedbId}/watch/providers", BaseUri, HttpMethod.Get); + request.AddQueryString("api_key", ApiToken); + + return Api.Request(request, token); + } + + public Task GetTvWatchProviders(int theMoviedbId, CancellationToken token) + { + var request = new Request($"tv/{theMoviedbId}/watch/providers", BaseUri, HttpMethod.Get); + request.AddQueryString("api_key", ApiToken); + + return Api.Request(request, token); + } + private async Task AddDiscoverMovieSettings(Request request) { var settings = await Settings; @@ -309,17 +340,6 @@ namespace Ombi.Api.TheMovieDb } } - - public async Task> MultiSearch(string searchTerm, string languageCode, CancellationToken cancellationToken) - { - var request = new Request("search/multi", BaseUri, HttpMethod.Get); - request.AddQueryString("api_key", ApiToken); - request.AddQueryString("language", languageCode); - request.AddQueryString("query", searchTerm); - var result = await Api.Request>(request, cancellationToken); - return result; - } - private static void AddRetry(Request request) { request.Retry = true; diff --git a/src/Ombi/ClientApp/src/app/interfaces/IStreams.ts b/src/Ombi/ClientApp/src/app/interfaces/IStreams.ts new file mode 100644 index 000000000..b666e01f6 --- /dev/null +++ b/src/Ombi/ClientApp/src/app/interfaces/IStreams.ts @@ -0,0 +1,5 @@ +export interface IStreamingData { + order: number; + streamingProvider: string; + logo: string; +} diff --git a/src/Ombi/ClientApp/src/app/interfaces/IUser.ts b/src/Ombi/ClientApp/src/app/interfaces/IUser.ts index 4b823a5be..856d57f0a 100644 --- a/src/Ombi/ClientApp/src/app/interfaces/IUser.ts +++ b/src/Ombi/ClientApp/src/app/interfaces/IUser.ts @@ -17,6 +17,7 @@ export interface IUser { userAccessToken: string; language: string; userQualityProfiles: IUserQualityProfiles; + streamingCountry: string; // FOR UI episodeRequestQuota: IRemainingRequests | null; @@ -35,7 +36,7 @@ export interface IUserQualityProfiles { sonarrRootPath: number; sonarrQualityProfile: number; radarrRootPath: number; - radarrQualityProfile: number; + radarrQualityProfile: number; } export interface ICreateWizardUser { @@ -49,6 +50,10 @@ export interface IWizardUserResult { errors: string[]; } +export interface IStreamingCountries { + code: string; +} + export enum UserType { LocalUser = 1, PlexUser = 2, diff --git a/src/Ombi/ClientApp/src/app/media-details/components/movie/panels/movie-information-panel.component.html b/src/Ombi/ClientApp/src/app/media-details/components/movie/panels/movie-information-panel.component.html index 62a458c19..479644203 100644 --- a/src/Ombi/ClientApp/src/app/media-details/components/movie/panels/movie-information-panel.component.html +++ b/src/Ombi/ClientApp/src/app/media-details/components/movie/panels/movie-information-panel.component.html @@ -1,13 +1,27 @@
- + {{movie.voteAverage | number:'1.0-1'}}/10 - {{ratings.critics_score}}% + + {{ratings.critics_score}}% - {{ratings.audience_score}}% + + {{ratings.audience_score}}% +
+
+ {{'MediaDetails.StreamingOn' | translate }}: +
+ + + +
+

{{'MediaDetails.Status' | translate }}: @@ -59,48 +73,48 @@
{{'MediaDetails.TheatricalRelease' | translate }}: - {{movie.releaseDate | date: 'mediumDate'}} + {{movie.releaseDate | date: 'mediumDate'}} -
- {{'MediaDetails.DigitalRelease' | translate }}: - {{movie.digitalReleaseDate | date: 'mediumDate'}} -
- -
- {{'MediaDetails.Votes' | translate }}: - {{movie.voteCount | thousandShort: 1}} -
-
- {{'MediaDetails.Runtime' | translate }}: - {{'MediaDetails.Minutes' | translate:{runtime: movie.runtime} }} -
-
- {{'MediaDetails.Revenue' | translate }}: - {{movie.revenue | currency: 'USD'}} -
-
- {{'MediaDetails.Budget' | translate }}: - {{movie.budget | currency: 'USD'}} -
+
+ {{'MediaDetails.DigitalRelease' | translate }}: + {{movie.digitalReleaseDate | date: 'mediumDate'}} +
-
-
- {{'MediaDetails.Genres' | translate }}: -
- - - {{genre.name}} - - -
-
+
+ {{'MediaDetails.Votes' | translate }}: + {{movie.voteCount | thousandShort: 1}} +
+
+ {{'MediaDetails.Runtime' | translate }}: + {{'MediaDetails.Minutes' | translate:{runtime: movie.runtime} }} +
+
+ {{'MediaDetails.Revenue' | translate }}: + {{movie.revenue | currency: 'USD'}} +
+
+ {{'MediaDetails.Budget' | translate }}: + {{movie.budget | currency: 'USD'}} +
-
-
- {{'MediaDetails.Keywords' | translate }}: +
+
+ {{'MediaDetails.Genres' | translate }}: +
- - {{keyword.name}} + + {{genre.name}} -
\ No newline at end of file +
+
+ +
+
+ {{'MediaDetails.Keywords' | translate }}: + + + {{keyword.name}} + + +
\ No newline at end of file diff --git a/src/Ombi/ClientApp/src/app/media-details/components/movie/panels/movie-information-panel.component.ts b/src/Ombi/ClientApp/src/app/media-details/components/movie/panels/movie-information-panel.component.ts index 1df97372c..89d9c076c 100644 --- a/src/Ombi/ClientApp/src/app/media-details/components/movie/panels/movie-information-panel.component.ts +++ b/src/Ombi/ClientApp/src/app/media-details/components/movie/panels/movie-information-panel.component.ts @@ -4,6 +4,7 @@ import { IMovieRequests } from "../../../../interfaces"; import { SearchV2Service } from "../../../../services/searchV2.service"; import { IMovieRatings } from "../../../../interfaces/IRatings"; import { APP_BASE_HREF } from "@angular/common"; +import { IStreamingData } from "../../../../interfaces/IStreams"; @Component({ templateUrl: "./movie-information-panel.component.html", styleUrls: ["../../../media-details.component.scss"], @@ -19,9 +20,12 @@ export class MovieInformationPanelComponent implements OnInit { @Input() public advancedOptions: boolean; public ratings: IMovieRatings; + public streams: IStreamingData[]; public ngOnInit() { this.searchService.getRottenMovieRatings(this.movie.title, +this.movie.releaseDate.toString().substring(0,4)) .subscribe(x => this.ratings = x); + + this.searchService.getMovieStreams(this.movie.id).subscribe(x => this.streams = x); } } diff --git a/src/Ombi/ClientApp/src/app/media-details/components/tv/panels/tv-information-panel/tv-information-panel.component.html b/src/Ombi/ClientApp/src/app/media-details/components/tv/panels/tv-information-panel/tv-information-panel.component.html index b7d8f6872..777f4820e 100644 --- a/src/Ombi/ClientApp/src/app/media-details/components/tv/panels/tv-information-panel/tv-information-panel.component.html +++ b/src/Ombi/ClientApp/src/app/media-details/components/tv/panels/tv-information-panel/tv-information-panel.component.html @@ -5,7 +5,16 @@ {{ratings.score}}% - + +
+
+ {{'MediaDetails.StreamingOn' | translate }}: +
+ + + +
+

{{'MediaDetails.Status' | translate }}: diff --git a/src/Ombi/ClientApp/src/app/media-details/components/tv/panels/tv-information-panel/tv-information-panel.component.ts b/src/Ombi/ClientApp/src/app/media-details/components/tv/panels/tv-information-panel/tv-information-panel.component.ts index 5217586f5..350f76c26 100644 --- a/src/Ombi/ClientApp/src/app/media-details/components/tv/panels/tv-information-panel/tv-information-panel.component.ts +++ b/src/Ombi/ClientApp/src/app/media-details/components/tv/panels/tv-information-panel/tv-information-panel.component.ts @@ -2,6 +2,7 @@ import { Component, ViewEncapsulation, Input, OnInit } from "@angular/core"; import { ITvRequests } from "../../../../../interfaces"; import { ITvRatings } from "../../../../../interfaces/IRatings"; import { ISearchTvResultV2 } from "../../../../../interfaces/ISearchTvResultV2"; +import { IStreamingData } from "../../../../../interfaces/IStreams"; import { SearchV2Service } from "../../../../../services"; @Component({ @@ -19,6 +20,7 @@ export class TvInformationPanelComponent implements OnInit { @Input() public advancedOptions: boolean; public ratings: ITvRatings; + public streams: IStreamingData[]; public seasonCount: number; public totalEpisodes: number = 0; public nextEpisode: any; @@ -26,6 +28,8 @@ export class TvInformationPanelComponent implements OnInit { public ngOnInit(): void { this.searchService.getRottenTvRatings(this.tv.title, +this.tv.firstAired.toString().substring(0,4)) .subscribe(x => this.ratings = x); + + this.searchService.getTvStreams(+this.tv.theTvDbId, this.tv.id).subscribe(x => this.streams = x); this.tv.seasonRequests.forEach(season => { this.totalEpisodes = this.totalEpisodes + season.episodes.length; }); diff --git a/src/Ombi/ClientApp/src/app/media-details/media-details.component.scss b/src/Ombi/ClientApp/src/app/media-details/media-details.component.scss index 7466e26ca..41dd1d87e 100644 --- a/src/Ombi/ClientApp/src/app/media-details/media-details.component.scss +++ b/src/Ombi/ClientApp/src/app/media-details/media-details.component.scss @@ -230,4 +230,10 @@ .rating-small { width: 1.3em; +} +.stream-small { + width: 3em; + border-radius: 1em; + margin-right: 10px; + margin-top: 5px; } \ No newline at end of file diff --git a/src/Ombi/ClientApp/src/app/services/identity.service.ts b/src/Ombi/ClientApp/src/app/services/identity.service.ts index f25a21b73..27f777e51 100644 --- a/src/Ombi/ClientApp/src/app/services/identity.service.ts +++ b/src/Ombi/ClientApp/src/app/services/identity.service.ts @@ -4,7 +4,7 @@ import { Injectable, Inject } from "@angular/core"; import { HttpClient } from "@angular/common/http"; import { Observable } from "rxjs"; -import { ICheckbox, ICreateWizardUser, IIdentityResult, INotificationPreferences, IResetPasswordToken, IUpdateLocalUser, IUser, IUserDropdown, IWizardUserResult } from "../interfaces"; +import { ICheckbox, ICreateWizardUser, IIdentityResult, INotificationPreferences, IResetPasswordToken, IStreamingCountries, IUpdateLocalUser, IUser, IUserDropdown, IWizardUserResult } from "../interfaces"; import { ServiceHelpers } from "./service.helpers"; @Injectable() @@ -83,8 +83,16 @@ export class IdentityService extends ServiceHelpers { public getNotificationPreferencesForUser(userId: string): Observable { return this.http.get(`${this.url}notificationpreferences/${userId}`, {headers: this.headers}); } - + public updateLanguage(lang: string): Observable { return this.http.post(`${this.url}language`, {lang: lang}, {headers: this.headers}); } + + public getSupportedStreamingCountries(): Observable { + return this.http.get(`${this.url}streamingcountry`, {headers: this.headers}); + } + + public updateStreamingCountry(code: string): Observable { + return this.http.post(`${this.url}streamingcountry`, {code: code}, {headers: this.headers}); + } } diff --git a/src/Ombi/ClientApp/src/app/services/searchV2.service.ts b/src/Ombi/ClientApp/src/app/services/searchV2.service.ts index 07a846185..fa970313f 100644 --- a/src/Ombi/ClientApp/src/app/services/searchV2.service.ts +++ b/src/Ombi/ClientApp/src/app/services/searchV2.service.ts @@ -12,6 +12,7 @@ import { ISearchTvResultV2, IMovieCollectionsViewModel, IActorCredits } from ".. import { IArtistSearchResult, IAlbumArt } from "../interfaces/IMusicSearchResultV2"; import { SearchFilter } from "../my-nav/SearchFilter"; import { IMovieRatings, ITvRatings } from "../interfaces/IRatings"; +import { IStreamingData } from "../interfaces/IStreams"; @Injectable() export class SearchV2Service extends ServiceHelpers { @@ -131,4 +132,12 @@ export class SearchV2Service extends ServiceHelpers { return this.http.get(`${this.url}/ratings/tv/${name}/${year}`); } + public getMovieStreams(theMovieDbId: number): Observable { + return this.http.get(`${this.url}/stream/movie/${theMovieDbId}`); + } + + public getTvStreams(theTvDbId: number, tvMaze: number): Observable { + return this.http.get(`${this.url}/stream/tv/${theTvDbId}/${tvMaze}`); + } + } diff --git a/src/Ombi/ClientApp/src/app/shared/shared.module.ts b/src/Ombi/ClientApp/src/app/shared/shared.module.ts index 543027bfd..ed93fa375 100644 --- a/src/Ombi/ClientApp/src/app/shared/shared.module.ts +++ b/src/Ombi/ClientApp/src/app/shared/shared.module.ts @@ -75,7 +75,7 @@ import { EpisodeRequestComponent } from "./episode-request/episode-request.compo MatSnackBarModule, ], entryComponents: [ - EpisodeRequestComponent + EpisodeRequestComponent, ], exports: [ TranslateModule, diff --git a/src/Ombi/ClientApp/src/app/user-preferences/components/user-preference/user-preference.component.html b/src/Ombi/ClientApp/src/app/user-preferences/components/user-preference/user-preference.component.html index 9971775eb..402c683f1 100644 --- a/src/Ombi/ClientApp/src/app/user-preferences/components/user-preference/user-preference.component.html +++ b/src/Ombi/ClientApp/src/app/user-preferences/components/user-preference/user-preference.component.html @@ -3,24 +3,50 @@
-
-
+
+
- - - - - {{lang.display}} - - - -
-
- -
+ {{'UserPreferences.LanguageDescription' | translate}} +
+ + + + + {{lang.display}} + + + +
+
+ +
-
+
+
+ +
+ +
+
+ {{'UserPreferences.StreamingCountryDescription' | translate}} +
+ + + + + {{value}} + + + +
+
+ +
+
+ + +
\ No newline at end of file diff --git a/src/Ombi/ClientApp/src/app/user-preferences/components/user-preference/user-preference.component.ts b/src/Ombi/ClientApp/src/app/user-preferences/components/user-preference/user-preference.component.ts index 3fe4359eb..3e4163ea0 100644 --- a/src/Ombi/ClientApp/src/app/user-preferences/components/user-preference/user-preference.component.ts +++ b/src/Ombi/ClientApp/src/app/user-preferences/components/user-preference/user-preference.component.ts @@ -3,7 +3,7 @@ import { AuthService } from "../../../auth/auth.service"; import { TranslateService } from "@ngx-translate/core"; import { AvailableLanguages, ILanguage } from "./user-preference.constants"; import { StorageService } from "../../../shared/storage/storage-service"; -import { IdentityService, SettingsService } from "../../../services"; +import { IdentityService, NotificationService, SettingsService } from "../../../services"; import { IUser } from "../../../interfaces"; @Component({ @@ -17,12 +17,14 @@ export class UserPreferenceComponent implements OnInit { public availableLanguages = AvailableLanguages; public qrCode: string; public qrCodeEnabled: boolean; + public countries: string[]; + public selectedCountry: string; private user: IUser; constructor(private authService: AuthService, private readonly translate: TranslateService, - private storage: StorageService, + private readonly notification: NotificationService, private readonly identityService: IdentityService, private readonly settingsService: SettingsService) { } @@ -33,6 +35,8 @@ export class UserPreferenceComponent implements OnInit { } const customization = await this.settingsService.getCustomization().toPromise(); + this.selectedLang = this.translate.currentLang; + const accessToken = await this.identityService.getAccessToken().toPromise(); this.qrCode = `${customization.applicationUrl}|${accessToken}`; @@ -43,14 +47,18 @@ export class UserPreferenceComponent implements OnInit { } this.user = await this.identityService.getUser().toPromise(); - if (this.user.language) { - this.selectedLang = this.user.language; - } + this.selectedCountry = this.user.streamingCountry; + this.identityService.getSupportedStreamingCountries().subscribe(x => this.countries = x); + } public languageSelected() { - this.identityService.updateLanguage(this.selectedLang).subscribe(); + this.identityService.updateLanguage(this.selectedLang).subscribe(x => this.notification.success(this.translate.instant("UserPreferences.Updated"))); this.translate.use(this.selectedLang); } + public countrySelected() { + this.identityService.updateStreamingCountry(this.selectedCountry).subscribe(x => this.notification.success(this.translate.instant("UserPreferences.Updated"))); + } + } diff --git a/src/Ombi/ClientApp/src/app/usermanagement/usermanagement-user.component.html b/src/Ombi/ClientApp/src/app/usermanagement/usermanagement-user.component.html index d03bb9d2e..64f5d76d2 100644 --- a/src/Ombi/ClientApp/src/app/usermanagement/usermanagement-user.component.html +++ b/src/Ombi/ClientApp/src/app/usermanagement/usermanagement-user.component.html @@ -18,6 +18,14 @@
+ + + + + {{value}} + + +
diff --git a/src/Ombi/ClientApp/src/app/usermanagement/usermanagement-user.component.ts b/src/Ombi/ClientApp/src/app/usermanagement/usermanagement-user.component.ts index db0403a01..486f456d0 100644 --- a/src/Ombi/ClientApp/src/app/usermanagement/usermanagement-user.component.ts +++ b/src/Ombi/ClientApp/src/app/usermanagement/usermanagement-user.component.ts @@ -1,5 +1,5 @@ import { Location } from "@angular/common"; -import { Component, OnInit } from "@angular/core"; +import { AfterViewInit, Component, OnInit } from "@angular/core"; import { ActivatedRoute, Router } from "@angular/router"; import { ICheckbox, INotificationAgent, INotificationPreferences, IRadarrProfile, IRadarrRootFolder, ISonarrProfile, ISonarrRootFolder, IUser, UserType } from "../interfaces"; @@ -25,6 +25,8 @@ export class UserManagementUserComponent implements OnInit { public NotificationAgent = INotificationAgent; public edit: boolean; + public countries: string[]; + constructor(private identityService: IdentityService, private notificationService: MessageService, private router: Router, @@ -45,6 +47,8 @@ export class UserManagementUserComponent implements OnInit { } public ngOnInit() { + + this.identityService.getSupportedStreamingCountries().subscribe(x => this.countries = x); this.identityService.getAllAvailableClaims().subscribe(x => this.availableClaims = x); if(this.edit) { this.identityService.getNotificationPreferencesForUser(this.userId).subscribe(x => this.notificationPreferences = x); @@ -74,6 +78,7 @@ export class UserManagementUserComponent implements OnInit { episodeRequestQuota: null, movieRequestQuota: null, language: null, + streamingCountry: "US", userQualityProfiles: { radarrQualityProfile: 0, radarrRootPath: 0, @@ -172,7 +177,7 @@ export class UserManagementUserComponent implements OnInit { } }); } - + public back() { this.location.back(); } diff --git a/src/Ombi/Controllers/V1/IdentityController.cs b/src/Ombi/Controllers/V1/IdentityController.cs index 2300c0482..500cd4610 100644 --- a/src/Ombi/Controllers/V1/IdentityController.cs +++ b/src/Ombi/Controllers/V1/IdentityController.cs @@ -10,6 +10,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; using Ombi.Api.Plex; +using Ombi.Api.TheMovieDb.Models; using Ombi.Attributes; using Ombi.Core.Authentication; using Ombi.Core.Engine; @@ -159,7 +160,8 @@ namespace Ombi.Controllers.V1 UserName = plexUser.user.username, UserType = UserType.PlexUser, Email = plexUser.user.email, - ProviderUserId = plexUser.user.id + ProviderUserId = plexUser.user.id, + StreamingCountry = "US" // Default }; await _userManagementSettings.SaveSettingsAsync(new UserManagementSettings @@ -173,7 +175,8 @@ namespace Ombi.Controllers.V1 var userToCreate = new OmbiUser { UserName = user.Username, - UserType = UserType.LocalUser + UserType = UserType.LocalUser, + StreamingCountry = "US" }; return await SaveWizardUser(user, userToCreate); @@ -329,6 +332,32 @@ namespace Ombi.Controllers.V1 return Ok(); } + /// + /// Returns the supported country codes that we have streaming data for + /// + [HttpGet("streamingcountry")] + [Authorize] + public IActionResult GetSupportedStreamingCountries() + { + var resultsProp = typeof(Results).GetProperties(); + return Json(resultsProp.Select(x => x.Name)); + } + + /// + /// Sets the current users country streaming preference + /// + [HttpPost("streamingcountry")] + [Authorize] + public async Task SetCurrentUserCountryStreaming([FromBody] CountryStreamingPreference model) + { + var username = User.Identity.Name.ToUpper(); + var user = await UserManager.Users.FirstOrDefaultAsync(x => x.NormalizedUserName == username); + user.StreamingCountry = model.Code; + + await UserManager.UpdateAsync(user); + return Ok(); + } + /// /// Gets the user by the user id. /// @@ -358,7 +387,8 @@ namespace Ombi.Controllers.V1 EpisodeRequestLimit = user.EpisodeRequestLimit ?? 0, MovieRequestLimit = user.MovieRequestLimit ?? 0, MusicRequestLimit = user.MusicRequestLimit ?? 0, - Language = user.Language + Language = user.Language, + StreamingCountry = user.StreamingCountry }; foreach (var role in userRoles) @@ -437,6 +467,7 @@ namespace Ombi.Controllers.V1 EpisodeRequestLimit = user.EpisodeRequestLimit, MusicRequestLimit = user.MusicRequestLimit, UserAccessToken = Guid.NewGuid().ToString("N"), + StreamingCountry = user.StreamingCountry.HasValue() ? user.StreamingCountry : "US" }; var userResult = await UserManager.CreateAsync(ombiUser, user.Password); @@ -594,6 +625,10 @@ namespace Ombi.Controllers.V1 user.MovieRequestLimit = ui.MovieRequestLimit; user.EpisodeRequestLimit = ui.EpisodeRequestLimit; user.MusicRequestLimit = ui.MusicRequestLimit; + if (ui.StreamingCountry.HasValue()) + { + user.StreamingCountry = ui.StreamingCountry; + } var updateResult = await UserManager.UpdateAsync(user); if (!updateResult.Succeeded) { @@ -739,7 +774,7 @@ namespace Ombi.Controllers.V1 [HttpPost("reset")] [AllowAnonymous] [ApiExplorerSettings(IgnoreApi = true)] - public async Task SubmitResetPassword([FromBody]SubmitPasswordReset email) + public async Task SubmitResetPassword([FromBody] SubmitPasswordReset email) { // Check if account exists var user = await UserManager.FindByEmailAsync(email.Email); @@ -817,7 +852,7 @@ namespace Ombi.Controllers.V1 [HttpPost("resetpassword")] [AllowAnonymous] [ApiExplorerSettings(IgnoreApi = true)] - public async Task ResetPassword([FromBody]ResetPasswordToken token) + public async Task ResetPassword([FromBody] ResetPasswordToken token) { var user = await UserManager.FindByEmailAsync(token.Email); diff --git a/src/Ombi/Controllers/V2/SearchController.cs b/src/Ombi/Controllers/V2/SearchController.cs index af1378ee5..889dc288f 100644 --- a/src/Ombi/Controllers/V2/SearchController.cs +++ b/src/Ombi/Controllers/V2/SearchController.cs @@ -420,5 +420,20 @@ namespace Ombi.Controllers.V2 return _rottenTomatoesApi.GetTvRatings(name, year); } + [HttpGet("stream/movie/{movieDbId}")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesDefaultResponseType] + public Task> GetMovieStreams(int movieDBId) + { + return _movieEngineV2.GetStreamInformation(movieDBId, HttpContext.RequestAborted); + } + + [HttpGet("stream/tv/{tvdbId}/{tvMaze}")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesDefaultResponseType] + public Task> GetTvStreams(int tvdbId, int tvMaze) + { + return _tvEngineV2.GetStreamInformation(tvdbId, tvMaze, HttpContext.RequestAborted); + } } } \ No newline at end of file diff --git a/src/Ombi/Models/Identity/CountryStreamingPreference.cs b/src/Ombi/Models/Identity/CountryStreamingPreference.cs new file mode 100644 index 000000000..c2cc28798 --- /dev/null +++ b/src/Ombi/Models/Identity/CountryStreamingPreference.cs @@ -0,0 +1,7 @@ +namespace Ombi.Models.Identity +{ + public class CountryStreamingPreference + { + public string Code { get; set; } + } +} diff --git a/src/Ombi/wwwroot/translations/en.json b/src/Ombi/wwwroot/translations/en.json index ff1985637..d86cf652c 100644 --- a/src/Ombi/wwwroot/translations/en.json +++ b/src/Ombi/wwwroot/translations/en.json @@ -275,7 +275,8 @@ "SonarrConfiguration": "Sonarr Configuration", "RadarrConfiguration": "Radarr Configuration", "RequestOnBehalf": "Request on behalf of", - "PleaseSelectUser": "Please select a user" + "PleaseSelectUser": "Please select a user", + "StreamingOn": "Streaming On" }, "Discovery": { "PopularTab": "Popular", @@ -300,6 +301,11 @@ "UserPreferences": { "Welcome": "Welcome {{username}}!", "OmbiLanguage": "Language", - "DarkMode": "Dark Mode" + "DarkMode": "Dark Mode", + "Updated": "Successfully Updated", + "StreamingCountry":"Streaming Country", + "StreamingCountryDescription": "This is the country code that we will display streaming information for. If you are in the US please select US and you will have US related streaming information.", + "LanguageDescription": "This is the language you would like the Ombi interface to be displayed in.", + "MobileQRCode":"Mobile QR Code" } } \ No newline at end of file