Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emby server #3848

Merged
merged 2 commits into from
Nov 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Ombi.Core/Rule/Rules/Search/EmbyAvailabilityRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ public async Task<RuleResult> 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);
}
}

Expand Down
24 changes: 13 additions & 11 deletions src/Ombi.Helpers.Tests/EmbyHelperTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,28 @@ 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);
// 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)
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
{
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/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");
}
}

Expand All @@ -37,9 +39,9 @@ public static IEnumerable<TestCaseData> 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/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");
}
}
}
Expand Down
11 changes: 6 additions & 5 deletions src/Ombi.Helpers/EmbyHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,25 @@
{
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";
if (isJellyfin)
{
path = "itemdetails.html";
path = "details";
}
if (customerServerUrl.HasValue())
{
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
{
return $"https://app.emby.media/#!/{path}?id={mediaId}";
return $"https://app.emby.media/web/index.html#!/{path}?id={mediaId}&serverId={serverId}";
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Ombi.Schedule/Jobs/Emby/EmbyContentSync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
}
Expand Down Expand Up @@ -186,7 +186,7 @@ private async Task ProcessMovies(EmbyMovie movieInfo, ICollection<EmbyContent> 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,
});
}
Expand Down
1 change: 1 addition & 0 deletions src/Ombi.Settings/Settings/Models/External/EmbySettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
2 changes: 2 additions & 0 deletions src/Ombi/ClientApp/src/app/interfaces/ISettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export interface IEmbySettings extends ISettings {
}

export interface IEmbyServer extends IExternalSettings {
serverId: string;
name: string;
apiKey: string;
administratorId: string;
Expand All @@ -49,6 +50,7 @@ export interface IEmbyServer extends IExternalSettings {
}

export interface IPublicInfo {
id: string;
serverName: string;
isJellyfin: boolean;
}
Expand Down
13 changes: 9 additions & 4 deletions src/Ombi/ClientApp/src/app/settings/emby/emby.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,24 @@
<input matInput placeholder="Server Name" [(ngModel)]="server.name" value="{{server.name}}">
</mat-form-field>
</div>

<div class="md-form-field">
<mat-form-field appearance="outline" floatLabel=auto>
<mat-label>Hostname / IP</mat-label>
<input matInput placeholder="Hostname or IP" [(ngModel)]="server.ip" value="{{server.ip}}">
</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-label>Port</mat-label>
<input matInput placeholder="Port" [(ngModel)]="server.port" value="{{server.port}}">
</mat-form-field>

<mat-slide-toggle id="ssl" [(ngModel)]="server.ssl" [checked]="server.ssl">
SSL
</mat-slide-toggle>
Expand Down
3 changes: 2 additions & 1 deletion src/Ombi/ClientApp/src/app/settings/emby/emby.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Ombi/ClientApp/src/app/wizard/emby/emby.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class EmbyComponent implements OnInit {
ssl: false,
subDir: "",
serverHostname: "",

serverId: undefined
});
}

Expand Down
14 changes: 0 additions & 14 deletions src/Ombi/databasej.json

This file was deleted.