From 96abeb586183fe09d4bad1d62d9ab6982ee67500 Mon Sep 17 00:00:00 2001 From: tidusjar Date: Mon, 2 Nov 2020 19:02:27 +0000 Subject: [PATCH 1/2] 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 @@ public async Task Execute(SearchViewModel obj) 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 @@ public static IEnumerable UrlData 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 @@ public static IEnumerable JellyfinUrlData 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 @@ public static string GetEmbyMediaUrl(string mediaId, string customerServerUrl = { 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 @@ private async Task StartServerCache(EmbyServers server, EmbySettings settings) 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 @@ private async Task ProcessMovies(EmbyMovie movieInfo, ICollection c 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 @@ public sealed class EmbySettings : Ombi.Settings.Settings.Models.Settings 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 From 7f9652ba4eedfdf0b69d6af62f6d70a0b867b51f Mon Sep 17 00:00:00 2001 From: Jamie Rees Date: Mon, 2 Nov 2020 21:05:26 +0000 Subject: [PATCH 2/2] Fixed #3476 --- src/Ombi.Helpers.Tests/EmbyHelperTests.cs | 16 +++++++++------- src/Ombi.Helpers/EmbyHelper.cs | 9 +++++---- .../src/app/settings/emby/emby.component.html | 12 ++++++------ 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/Ombi.Helpers.Tests/EmbyHelperTests.cs b/src/Ombi.Helpers.Tests/EmbyHelperTests.cs index 62563e37e..261ba87cc 100644 --- a/src/Ombi.Helpers.Tests/EmbyHelperTests.cs +++ b/src/Ombi.Helpers.Tests/EmbyHelperTests.cs @@ -11,12 +11,14 @@ public class EmbyHelperTests [TestCaseSource(nameof(UrlData))] public string TestUrl(string mediaId, string url, string serverId) { + // http://192.168.68.X:8096/web/index.html#!/item?id=17980&serverId=4e7a85e6ed0b49b9a6d6d15e739a566b return EmbyHelper.GetEmbyMediaUrl(mediaId, serverId, url); } [TestCaseSource(nameof(JellyfinUrlData))] public string TestJellyfinUrl(string mediaId, string url, string serverId) { + // http://192.168.68.X:8097/web/index.html#!/details?id=7ffe222498445d5ebfddb31bc4fa9a6d&serverId=50cce67f0baa425093d189b3017331fb return EmbyHelper.GetEmbyMediaUrl(mediaId, serverId, url, true); } @@ -25,10 +27,10 @@ public static IEnumerable UrlData get { var mediaId = 1; - 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"); + yield return new TestCaseData(mediaId.ToString(), "http://google.com", "1").Returns($"http://google.com/web/index.html#!/item?id={mediaId}&serverId=1").SetName("EmbyHelper_GetMediaUrl_WithCustomDomain_WithoutTrailingSlash"); + yield return new TestCaseData(mediaId.ToString(), "http://google.com/", "1").Returns($"http://google.com/web/index.html#!/item?id={mediaId}&serverId=1").SetName("EmbyHelper_GetMediaUrl_WithCustomDomain"); + yield return new TestCaseData(mediaId.ToString(), "https://google.com/", "1").Returns($"https://google.com/web/index.html#!/item?id={mediaId}&serverId=1").SetName("EmbyHelper_GetMediaUrl_WithCustomDomain_Https"); + yield return new TestCaseData(mediaId.ToString(), string.Empty, "1").Returns($"https://app.emby.media/web/index.html#!/item?id={mediaId}&serverId=1").SetName("EmbyHelper_GetMediaUrl_WithOutCustomDomain"); } } @@ -37,9 +39,9 @@ public static IEnumerable JellyfinUrlData get { var mediaId = 1; - 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"); + yield return new TestCaseData(mediaId.ToString(), "http://google.com", "1").Returns($"http://google.com/web/index.html#!/details?id={mediaId}&serverId=1").SetName("EmbyHelperJellyfin_GetMediaUrl_WithCustomDomain_WithoutTrailingSlash"); + yield return new TestCaseData(mediaId.ToString(), "http://google.com/", "1").Returns($"http://google.com/web/index.html#!/details?id={mediaId}&serverId=1").SetName("EmbyHelperJellyfin_GetMediaUrl_WithCustomDomain"); + yield return new TestCaseData(mediaId.ToString(), "https://google.com/", "1").Returns($"https://google.com/web/index.html#!/details?id={mediaId}&serverId=1").SetName("EmbyHelperJellyfin_GetMediaUrl_WithCustomDomain_Https"); } } } diff --git a/src/Ombi.Helpers/EmbyHelper.cs b/src/Ombi.Helpers/EmbyHelper.cs index 7f30655fa..4d2bcfc57 100644 --- a/src/Ombi.Helpers/EmbyHelper.cs +++ b/src/Ombi.Helpers/EmbyHelper.cs @@ -4,22 +4,23 @@ public class EmbyHelper { public static string GetEmbyMediaUrl(string mediaId, string serverId, string customerServerUrl = null, bool isJellyfin = false) { + //web/index.html#!/details|item string path = "item"; if (isJellyfin) { - path = "itemdetails.html"; + path = "details"; } if (customerServerUrl.HasValue()) { if (!customerServerUrl.EndsWith("/")) { - return $"{customerServerUrl}/#!/{path}?id={mediaId}&serverId={serverId}"; + return $"{customerServerUrl}/web/index.html#!/{path}?id={mediaId}&serverId={serverId}"; } - return $"{customerServerUrl}#!/{path}?id={mediaId}&serverId={serverId}"; + return $"{customerServerUrl}web/index.html#!/{path}?id={mediaId}&serverId={serverId}"; } else { - return $"https://app.emby.media/#!/{path}?id={mediaId}&serverId={serverId}"; + return $"https://app.emby.media/web/index.html#!/{path}?id={mediaId}&serverId={serverId}"; } } } 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 6ebfc5aaf..e6d35b1c1 100644 --- a/src/Ombi/ClientApp/src/app/settings/emby/emby.component.html +++ b/src/Ombi/ClientApp/src/app/settings/emby/emby.component.html @@ -30,12 +30,6 @@
-
- - Server ID - - -
@@ -43,6 +37,12 @@ +
+ + Server ID + + +
Port