From 96abeb586183fe09d4bad1d62d9ab6982ee67500 Mon Sep 17 00:00:00 2001 From: tidusjar Date: Mon, 2 Nov 2020 19:02:27 +0000 Subject: [PATCH] wip --- .../Rule/Rules/Search/EmbyAvailabilityRule.cs | 4 ++-- src/Ombi.Helpers.Tests/EmbyHelperTests.cs | 22 +++++++++---------- src/Ombi.Helpers/EmbyHelper.cs | 8 +++---- .../Jobs/Emby/EmbyContentSync.cs | 4 ++-- .../Settings/Models/External/EmbySettings.cs | 1 + .../ClientApp/src/app/interfaces/ISettings.ts | 2 ++ .../src/app/settings/emby/emby.component.html | 13 +++++++---- .../src/app/settings/emby/emby.component.ts | 3 ++- .../src/app/wizard/emby/emby.component.ts | 2 +- src/Ombi/databasej.json | 14 ------------ 10 files changed, 34 insertions(+), 39 deletions(-) delete mode 100644 src/Ombi/databasej.json diff --git a/src/Ombi.Core/Rule/Rules/Search/EmbyAvailabilityRule.cs b/src/Ombi.Core/Rule/Rules/Search/EmbyAvailabilityRule.cs index 343681e29..75b6633bb 100644 --- a/src/Ombi.Core/Rule/Rules/Search/EmbyAvailabilityRule.cs +++ b/src/Ombi.Core/Rule/Rules/Search/EmbyAvailabilityRule.cs @@ -70,11 +70,11 @@ namespace Ombi.Core.Rule.Rules.Search var server = s.Servers.FirstOrDefault(x => x.ServerHostname != null); if ((server?.ServerHostname ?? string.Empty).HasValue()) { - obj.EmbyUrl = EmbyHelper.GetEmbyMediaUrl(item.EmbyId, server?.ServerHostname, s.IsJellyfin); + obj.EmbyUrl = EmbyHelper.GetEmbyMediaUrl(item.EmbyId, server?.ServerId, server?.ServerHostname, s.IsJellyfin); } else { - obj.EmbyUrl = EmbyHelper.GetEmbyMediaUrl(item.EmbyId, null, s.IsJellyfin); + obj.EmbyUrl = EmbyHelper.GetEmbyMediaUrl(item.EmbyId, server?.ServerId, null, s.IsJellyfin); } } diff --git a/src/Ombi.Helpers.Tests/EmbyHelperTests.cs b/src/Ombi.Helpers.Tests/EmbyHelperTests.cs index 746bd1d5f..62563e37e 100644 --- a/src/Ombi.Helpers.Tests/EmbyHelperTests.cs +++ b/src/Ombi.Helpers.Tests/EmbyHelperTests.cs @@ -9,15 +9,15 @@ namespace Ombi.Helpers.Tests public class EmbyHelperTests { [TestCaseSource(nameof(UrlData))] - public string TestUrl(string mediaId, string url) + public string TestUrl(string mediaId, string url, string serverId) { - return EmbyHelper.GetEmbyMediaUrl(mediaId, url); + return EmbyHelper.GetEmbyMediaUrl(mediaId, serverId, url); } [TestCaseSource(nameof(JellyfinUrlData))] - public string TestJellyfinUrl(string mediaId, string url) + public string TestJellyfinUrl(string mediaId, string url, string serverId) { - return EmbyHelper.GetEmbyMediaUrl(mediaId, url, true); + return EmbyHelper.GetEmbyMediaUrl(mediaId, serverId, url, true); } public static IEnumerable UrlData @@ -25,10 +25,10 @@ namespace Ombi.Helpers.Tests get { var mediaId = 1; - yield return new TestCaseData(mediaId.ToString(), "http://google.com").Returns($"http://google.com/#!/item?id={mediaId}").SetName("EmbyHelper_GetMediaUrl_WithCustomDomain_WithoutTrailingSlash"); - yield return new TestCaseData(mediaId.ToString(), "http://google.com/").Returns($"http://google.com/#!/item?id={mediaId}").SetName("EmbyHelper_GetMediaUrl_WithCustomDomain"); - yield return new TestCaseData(mediaId.ToString(), "https://google.com/").Returns($"https://google.com/#!/item?id={mediaId}").SetName("EmbyHelper_GetMediaUrl_WithCustomDomain_Https"); - yield return new TestCaseData(mediaId.ToString(), string.Empty).Returns($"https://app.emby.media/#!/item?id={mediaId}").SetName("EmbyHelper_GetMediaUrl_WithOutCustomDomain"); + yield return new TestCaseData(mediaId.ToString(), "http://google.com", "1").Returns($"http://google.com/#!/item?id={mediaId}&serverId=1").SetName("EmbyHelper_GetMediaUrl_WithCustomDomain_WithoutTrailingSlash"); + yield return new TestCaseData(mediaId.ToString(), "http://google.com/", "1").Returns($"http://google.com/#!/item?id={mediaId}&serverId=1").SetName("EmbyHelper_GetMediaUrl_WithCustomDomain"); + yield return new TestCaseData(mediaId.ToString(), "https://google.com/", "1").Returns($"https://google.com/#!/item?id={mediaId}&serverId=1").SetName("EmbyHelper_GetMediaUrl_WithCustomDomain_Https"); + yield return new TestCaseData(mediaId.ToString(), string.Empty, "1").Returns($"https://app.emby.media/#!/item?id={mediaId}&serverId=1").SetName("EmbyHelper_GetMediaUrl_WithOutCustomDomain"); } } @@ -37,9 +37,9 @@ namespace Ombi.Helpers.Tests get { var mediaId = 1; - yield return new TestCaseData(mediaId.ToString(), "http://google.com").Returns($"http://google.com/#!/itemdetails.html?id={mediaId}").SetName("EmbyHelperJellyfin_GetMediaUrl_WithCustomDomain_WithoutTrailingSlash"); - yield return new TestCaseData(mediaId.ToString(), "http://google.com/").Returns($"http://google.com/#!/itemdetails.html?id={mediaId}").SetName("EmbyHelperJellyfin_GetMediaUrl_WithCustomDomain"); - yield return new TestCaseData(mediaId.ToString(), "https://google.com/").Returns($"https://google.com/#!/itemdetails.html?id={mediaId}").SetName("EmbyHelperJellyfin_GetMediaUrl_WithCustomDomain_Https"); + yield return new TestCaseData(mediaId.ToString(), "http://google.com", "1").Returns($"http://google.com/#!/itemdetails.html?id={mediaId}&serverId=1").SetName("EmbyHelperJellyfin_GetMediaUrl_WithCustomDomain_WithoutTrailingSlash"); + yield return new TestCaseData(mediaId.ToString(), "http://google.com/", "1").Returns($"http://google.com/#!/itemdetails.html?id={mediaId}&serverId=1").SetName("EmbyHelperJellyfin_GetMediaUrl_WithCustomDomain"); + yield return new TestCaseData(mediaId.ToString(), "https://google.com/", "1").Returns($"https://google.com/#!/itemdetails.html?id={mediaId}&serverId=1").SetName("EmbyHelperJellyfin_GetMediaUrl_WithCustomDomain_Https"); } } } diff --git a/src/Ombi.Helpers/EmbyHelper.cs b/src/Ombi.Helpers/EmbyHelper.cs index 61716cd4b..7f30655fa 100644 --- a/src/Ombi.Helpers/EmbyHelper.cs +++ b/src/Ombi.Helpers/EmbyHelper.cs @@ -2,7 +2,7 @@ { public class EmbyHelper { - public static string GetEmbyMediaUrl(string mediaId, string customerServerUrl = null, bool isJellyfin = false) + public static string GetEmbyMediaUrl(string mediaId, string serverId, string customerServerUrl = null, bool isJellyfin = false) { string path = "item"; if (isJellyfin) @@ -13,13 +13,13 @@ { if (!customerServerUrl.EndsWith("/")) { - return $"{customerServerUrl}/#!/{path}?id={mediaId}"; + return $"{customerServerUrl}/#!/{path}?id={mediaId}&serverId={serverId}"; } - return $"{customerServerUrl}#!/{path}?id={mediaId}"; + return $"{customerServerUrl}#!/{path}?id={mediaId}&serverId={serverId}"; } else { - return $"https://app.emby.media/#!/{path}?id={mediaId}"; + return $"https://app.emby.media/#!/{path}?id={mediaId}&serverId={serverId}"; } } } diff --git a/src/Ombi.Schedule/Jobs/Emby/EmbyContentSync.cs b/src/Ombi.Schedule/Jobs/Emby/EmbyContentSync.cs index c886a3db3..f8bde2755 100644 --- a/src/Ombi.Schedule/Jobs/Emby/EmbyContentSync.cs +++ b/src/Ombi.Schedule/Jobs/Emby/EmbyContentSync.cs @@ -145,7 +145,7 @@ namespace Ombi.Schedule.Jobs.Emby Title = tvShow.Name, Type = EmbyMediaType.Series, EmbyId = tvShow.Id, - Url = EmbyHelper.GetEmbyMediaUrl(tvShow.Id, server.ServerHostname, settings.IsJellyfin), + Url = EmbyHelper.GetEmbyMediaUrl(tvShow.Id, server?.ServerId, server.ServerHostname, settings.IsJellyfin), AddedAt = DateTime.UtcNow }); } @@ -186,7 +186,7 @@ namespace Ombi.Schedule.Jobs.Emby Title = movieInfo.Name, Type = EmbyMediaType.Movie, EmbyId = movieInfo.Id, - Url = EmbyHelper.GetEmbyMediaUrl(movieInfo.Id, server.ServerHostname), + Url = EmbyHelper.GetEmbyMediaUrl(movieInfo.Id, server?.ServerId, server.ServerHostname), AddedAt = DateTime.UtcNow, }); } diff --git a/src/Ombi.Settings/Settings/Models/External/EmbySettings.cs b/src/Ombi.Settings/Settings/Models/External/EmbySettings.cs index 3ade5746b..b3ffce0e1 100644 --- a/src/Ombi.Settings/Settings/Models/External/EmbySettings.cs +++ b/src/Ombi.Settings/Settings/Models/External/EmbySettings.cs @@ -12,6 +12,7 @@ namespace Ombi.Core.Settings.Models.External public class EmbyServers : ExternalSettings { + public string ServerId { get; set; } public string Name { get; set; } public string ApiKey { get; set; } public string AdministratorId { get; set; } diff --git a/src/Ombi/ClientApp/src/app/interfaces/ISettings.ts b/src/Ombi/ClientApp/src/app/interfaces/ISettings.ts index 976a0f95f..0656bb1db 100644 --- a/src/Ombi/ClientApp/src/app/interfaces/ISettings.ts +++ b/src/Ombi/ClientApp/src/app/interfaces/ISettings.ts @@ -41,6 +41,7 @@ export interface IEmbySettings extends ISettings { } export interface IEmbyServer extends IExternalSettings { + serverId: string; name: string; apiKey: string; administratorId: string; @@ -49,6 +50,7 @@ export interface IEmbyServer extends IExternalSettings { } export interface IPublicInfo { + id: string; serverName: string; isJellyfin: boolean; } diff --git a/src/Ombi/ClientApp/src/app/settings/emby/emby.component.html b/src/Ombi/ClientApp/src/app/settings/emby/emby.component.html index 57f1a24e4..6ebfc5aaf 100644 --- a/src/Ombi/ClientApp/src/app/settings/emby/emby.component.html +++ b/src/Ombi/ClientApp/src/app/settings/emby/emby.component.html @@ -30,19 +30,24 @@ - +
+ + Server ID + + +
+
Hostname / IP - - + Port - + SSL diff --git a/src/Ombi/ClientApp/src/app/settings/emby/emby.component.ts b/src/Ombi/ClientApp/src/app/settings/emby/emby.component.ts index 895beb957..5db2d1120 100644 --- a/src/Ombi/ClientApp/src/app/settings/emby/emby.component.ts +++ b/src/Ombi/ClientApp/src/app/settings/emby/emby.component.ts @@ -2,7 +2,7 @@ import { IEmbyServer, IEmbySettings } from "../../interfaces"; import { EmbyService, JobService, NotificationService, SettingsService, TesterService } from "../../services"; -import { MatTabChangeEvent, MatTabGroup } from "@angular/material/tabs"; +import { MatTabChangeEvent } from "@angular/material/tabs"; import {FormControl} from '@angular/forms'; @Component({ @@ -29,6 +29,7 @@ export class EmbyComponent implements OnInit { const result = await this.embyService.getPublicInfo(server).toPromise(); this.settings.isJellyfin = result.isJellyfin; server.name = result.serverName; + server.serverId = result.id; this.hasDiscoveredOrDirty = true; } diff --git a/src/Ombi/ClientApp/src/app/wizard/emby/emby.component.ts b/src/Ombi/ClientApp/src/app/wizard/emby/emby.component.ts index 5e8f1b2ef..58d5dd3f6 100644 --- a/src/Ombi/ClientApp/src/app/wizard/emby/emby.component.ts +++ b/src/Ombi/ClientApp/src/app/wizard/emby/emby.component.ts @@ -35,7 +35,7 @@ export class EmbyComponent implements OnInit { ssl: false, subDir: "", serverHostname: "", - + serverId: undefined }); } diff --git a/src/Ombi/databasej.json b/src/Ombi/databasej.json deleted file mode 100644 index 7c77dd61a..000000000 --- a/src/Ombi/databasej.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "OmbiDatabase": { - "Type": "MySQL", - "ConnectionString": "Server=192.168.68.118;Database=app.ombi.io;User=ombi" - }, - "SettingsDatabase": { - "Type": "MySQL", - "ConnectionString": "Server=192.168.68.118;Database=app.ombi.io;User=ombi" - }, - "ExternalDatabase": { - "Type": "MySQL", - "ConnectionString": "Server=192.168.68.118;Database=app.ombi.io;User=ombi" - } - } \ No newline at end of file