Merge pull request #3848 from tidusjar/emby-server-id

Emby server
pull/3856/head
Jamie 4 years ago committed by GitHub
commit e56e5d95c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -70,11 +70,11 @@ namespace Ombi.Core.Rule.Rules.Search
var server = s.Servers.FirstOrDefault(x => x.ServerHostname != null); var server = s.Servers.FirstOrDefault(x => x.ServerHostname != null);
if ((server?.ServerHostname ?? string.Empty).HasValue()) 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 else
{ {
obj.EmbyUrl = EmbyHelper.GetEmbyMediaUrl(item.EmbyId, null, s.IsJellyfin); obj.EmbyUrl = EmbyHelper.GetEmbyMediaUrl(item.EmbyId, server?.ServerId, null, s.IsJellyfin);
} }
} }

@ -9,15 +9,17 @@ namespace Ombi.Helpers.Tests
public class EmbyHelperTests public class EmbyHelperTests
{ {
[TestCaseSource(nameof(UrlData))] [TestCaseSource(nameof(UrlData))]
public string TestUrl(string mediaId, string url) public string TestUrl(string mediaId, string url, string serverId)
{ {
return EmbyHelper.GetEmbyMediaUrl(mediaId, url); // http://192.168.68.X:8096/web/index.html#!/item?id=17980&serverId=4e7a85e6ed0b49b9a6d6d15e739a566b
return EmbyHelper.GetEmbyMediaUrl(mediaId, serverId, url);
} }
[TestCaseSource(nameof(JellyfinUrlData))] [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); // http://192.168.68.X:8097/web/index.html#!/details?id=7ffe222498445d5ebfddb31bc4fa9a6d&serverId=50cce67f0baa425093d189b3017331fb
return EmbyHelper.GetEmbyMediaUrl(mediaId, serverId, url, true);
} }
public static IEnumerable<TestCaseData> UrlData public static IEnumerable<TestCaseData> UrlData
@ -25,10 +27,10 @@ namespace Ombi.Helpers.Tests
get get
{ {
var mediaId = 1; 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", "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/").Returns($"http://google.com/#!/item?id={mediaId}").SetName("EmbyHelper_GetMediaUrl_WithCustomDomain"); 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/").Returns($"https://google.com/#!/item?id={mediaId}").SetName("EmbyHelper_GetMediaUrl_WithCustomDomain_Https"); 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).Returns($"https://app.emby.media/#!/item?id={mediaId}").SetName("EmbyHelper_GetMediaUrl_WithOutCustomDomain"); 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 @@ namespace Ombi.Helpers.Tests
get get
{ {
var mediaId = 1; 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", "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/").Returns($"http://google.com/#!/itemdetails.html?id={mediaId}").SetName("EmbyHelperJellyfin_GetMediaUrl_WithCustomDomain"); 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/").Returns($"https://google.com/#!/itemdetails.html?id={mediaId}").SetName("EmbyHelperJellyfin_GetMediaUrl_WithCustomDomain_Https"); 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");
} }
} }
} }

@ -2,24 +2,25 @@
{ {
public class EmbyHelper 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)
{ {
//web/index.html#!/details|item
string path = "item"; string path = "item";
if (isJellyfin) if (isJellyfin)
{ {
path = "itemdetails.html"; path = "details";
} }
if (customerServerUrl.HasValue()) if (customerServerUrl.HasValue())
{ {
if (!customerServerUrl.EndsWith("/")) if (!customerServerUrl.EndsWith("/"))
{ {
return $"{customerServerUrl}/#!/{path}?id={mediaId}"; return $"{customerServerUrl}/web/index.html#!/{path}?id={mediaId}&serverId={serverId}";
} }
return $"{customerServerUrl}#!/{path}?id={mediaId}"; return $"{customerServerUrl}web/index.html#!/{path}?id={mediaId}&serverId={serverId}";
} }
else else
{ {
return $"https://app.emby.media/#!/{path}?id={mediaId}"; return $"https://app.emby.media/web/index.html#!/{path}?id={mediaId}&serverId={serverId}";
} }
} }
} }

@ -145,7 +145,7 @@ namespace Ombi.Schedule.Jobs.Emby
Title = tvShow.Name, Title = tvShow.Name,
Type = EmbyMediaType.Series, Type = EmbyMediaType.Series,
EmbyId = tvShow.Id, 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 AddedAt = DateTime.UtcNow
}); });
} }
@ -186,7 +186,7 @@ namespace Ombi.Schedule.Jobs.Emby
Title = movieInfo.Name, Title = movieInfo.Name,
Type = EmbyMediaType.Movie, Type = EmbyMediaType.Movie,
EmbyId = movieInfo.Id, EmbyId = movieInfo.Id,
Url = EmbyHelper.GetEmbyMediaUrl(movieInfo.Id, server.ServerHostname), Url = EmbyHelper.GetEmbyMediaUrl(movieInfo.Id, server?.ServerId, server.ServerHostname),
AddedAt = DateTime.UtcNow, AddedAt = DateTime.UtcNow,
}); });
} }

@ -12,6 +12,7 @@ namespace Ombi.Core.Settings.Models.External
public class EmbyServers : ExternalSettings public class EmbyServers : ExternalSettings
{ {
public string ServerId { get; set; }
public string Name { get; set; } public string Name { get; set; }
public string ApiKey { get; set; } public string ApiKey { get; set; }
public string AdministratorId { get; set; } public string AdministratorId { get; set; }

@ -41,6 +41,7 @@ export interface IEmbySettings extends ISettings {
} }
export interface IEmbyServer extends IExternalSettings { export interface IEmbyServer extends IExternalSettings {
serverId: string;
name: string; name: string;
apiKey: string; apiKey: string;
administratorId: string; administratorId: string;
@ -49,6 +50,7 @@ export interface IEmbyServer extends IExternalSettings {
} }
export interface IPublicInfo { export interface IPublicInfo {
id: string;
serverName: string; serverName: string;
isJellyfin: boolean; isJellyfin: boolean;
} }

@ -37,7 +37,12 @@
<input matInput placeholder="Hostname or IP" [(ngModel)]="server.ip" value="{{server.ip}}"> <input matInput placeholder="Hostname or IP" [(ngModel)]="server.ip" value="{{server.ip}}">
</mat-form-field> </mat-form-field>
<div class="md-form-field">
<mat-form-field appearance="outline" floatLabel=auto>
<mat-label>Server ID</mat-label>
<input disabled matInput placeholder="Server Id" [(ngModel)]="server.serverId" value="{{server.serverId}}">
</mat-form-field>
</div>
<mat-form-field appearance="outline" floatLabel=auto> <mat-form-field appearance="outline" floatLabel=auto>
<mat-label>Port</mat-label> <mat-label>Port</mat-label>
<input matInput placeholder="Port" [(ngModel)]="server.port" value="{{server.port}}"> <input matInput placeholder="Port" [(ngModel)]="server.port" value="{{server.port}}">

@ -2,7 +2,7 @@
import { IEmbyServer, IEmbySettings } from "../../interfaces"; import { IEmbyServer, IEmbySettings } from "../../interfaces";
import { EmbyService, JobService, NotificationService, SettingsService, TesterService } from "../../services"; 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'; import {FormControl} from '@angular/forms';
@Component({ @Component({
@ -29,6 +29,7 @@ export class EmbyComponent implements OnInit {
const result = await this.embyService.getPublicInfo(server).toPromise(); const result = await this.embyService.getPublicInfo(server).toPromise();
this.settings.isJellyfin = result.isJellyfin; this.settings.isJellyfin = result.isJellyfin;
server.name = result.serverName; server.name = result.serverName;
server.serverId = result.id;
this.hasDiscoveredOrDirty = true; this.hasDiscoveredOrDirty = true;
} }

@ -35,7 +35,7 @@ export class EmbyComponent implements OnInit {
ssl: false, ssl: false,
subDir: "", subDir: "",
serverHostname: "", serverHostname: "",
serverId: undefined
}); });
} }

@ -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"
}
}
Loading…
Cancel
Save