Added multiple emby server support and enabled it for Plex #865

pull/1488/head
tidusjar 7 years ago
parent 1c27be1288
commit 8b3c57431c

@ -16,10 +16,13 @@ namespace Ombi.Schedule.Jobs.Emby
{ {
if (emby.Enable) if (emby.Enable)
{ {
if (emby?.Ip == null || string.IsNullOrEmpty(emby?.ApiKey)) foreach (var server in emby.Servers)
{ {
//Log.Warn("A setting is null, Ensure Emby is configured correctly, and we have a Emby Auth token."); if (server?.Ip == null || string.IsNullOrEmpty(server?.ApiKey))
return false; {
//Log.Warn("A setting is null, Ensure Emby is configured correctly, and we have a Emby Auth token.");
return false;
}
} }
} }
return emby.Enable; return emby.Enable;

@ -10,6 +10,7 @@ namespace Ombi.Core.Settings.Models.External
public class EmbyServers : ExternalSettings public class EmbyServers : ExternalSettings
{ {
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; }
public bool EnableEpisodeSearching { get; set; } public bool EnableEpisodeSearching { get; set; }

@ -25,6 +25,7 @@ export interface IEmbySettings extends ISettings {
} }
export interface IEmbyServer extends IExternalSettings { export interface IEmbyServer extends IExternalSettings {
name:string,
apiKey: string, apiKey: string,
administratorId: string, administratorId: string,
enableEpisodeSearching: boolean, enableEpisodeSearching: boolean,

@ -2,63 +2,87 @@
<settings-menu></settings-menu> <settings-menu></settings-menu>
<div *ngIf="settings"> <div *ngIf="settings">
<fieldset> <fieldset>
<legend>Emby Configuration <legend>
<b>(UNDER CONSTRUCTION <i class="fa fa-smile-o"></i>)</b> Emby Configuration
</legend> </legend>
<div class="form-group">
<div class="checkbox">
<input type="checkbox" id="enable" [(ngModel)]="settings.enable" ng-checked="settings.enable">
<label for="enable">Enable</label>
</div>
</div>
<div class="form-group"> <div class="row">
<label for="Ip" class="control-label">Hostname or IP</label> <div class="form-group col-md-3">
<div> <div class="checkbox">
<input type="text" class="form-control form-control-custom " id="Ip" name="Ip" placeholder="localhost" [(ngModel)]="settings.ip" value="{{settings.ip}}"> <input type="checkbox" id="enable" [(ngModel)]="settings.enable" [checked]="settings.enable">
<label for="enable">Enable</label>
</div>
</div> </div>
</div> <div class="col-md-2 col-md-push-7">
<button type="submit" (click)="addTab()" class="btn btn-success-outline">Add Server</button>
<div class="form-group">
<label for="portNumber" class="control-label">Port</label>
<div>
<input type="text" [(ngModel)]="settings.port" class="form-control form-control-custom " id="portNumber" name="Port" placeholder="Port Number" value="{{settings.port}}">
</div> </div>
</div> </div>
<div class="form-group"> <ngb-tabset>
<div class="checkbox"> <div *ngFor="let server of settings.servers">
<input type="checkbox" id="ssl" [(ngModel)]="settings.ssl" ng-checked="settings.ssl"> <ngb-tab [id]="server.id" [title]="server.name">
<label for="ssl">SSL</label> <ng-template ngbTabContent>
</div> <br />
</div> <br />
<div class="col-md-12 col-md-push-10" style="float: right;">
<button type="submit" (click)="removeServer(server)" class="btn btn-danger-outline">Remove Server</button>
</div>
<br />
<br />
<div class="form-group">
<label for="name" class="control-label">Server name</label>
<div>
<input type="text" class="form-control form-control-custom " id="name" name="name" placeholder="Server" [(ngModel)]="server.name" value="{{server.name}}">
</div>
</div>
<div class="form-group">
<label for="Ip" class="control-label">Hostname or IP</label>
<div>
<input type="text" class="form-control form-control-custom " id="Ip" name="Ip" placeholder="localhost" [(ngModel)]="server.ip" value="{{server.ip}}">
</div>
</div>
<div class="form-group"> <div class="form-group">
<div class="checkbox"> <label for="portNumber" class="control-label">Port</label>
<div>
<input type="text" [(ngModel)]="server.port" class="form-control form-control-custom " id="portNumber" name="Port" placeholder="Port Number" value="{{server.port}}">
</div>
</div>
<div class="form-group">
<div class="checkbox">
<input type="checkbox" id="ssl" [(ngModel)]="server.ssl" ng-checked="server.ssl">
<label for="ssl">SSL</label>
</div>
</div>
<input type="checkbox" id="EnableTvEpisodeSearching" [(ngModel)]="settings.enableEpisodeSearching" ng-checked="settings.enableEpisodeSearching"> <div class="form-group">
<label for="EnableTvEpisodeSearching">Enable Episode Searching</label> <div class="checkbox">
</div>
</div>
<input type="checkbox" id="EnableTvEpisodeSearching" [(ngModel)]="server.enableEpisodeSearching" ng-checked="server.enableEpisodeSearching">
<label for="EnableTvEpisodeSearching">Enable Episode Searching</label>
<div class="form-group"> </div>
<label for="authToken" class="control-label">Emby Api Key</label> </div>
<div class="">
<input type="text" class="form-control-custom form-control" id="authToken" [(ngModel)]="settings.apiKey" placeholder="Emby Api Key" value="{{settings.apiKey}}">
</div>
</div>
<div class="form-group">
<div>
<button id="testPlex" type="submit" (click)="test()" class="btn btn-primary-outline">Test Connectivity <div id="spinner"></div></button>
</div>
</div>
<div class="form-group">
<label for="authToken" class="control-label">Emby Api Key</label>
<div class="">
<input type="text" class="form-control-custom form-control" id="authToken" [(ngModel)]="server.apiKey" placeholder="Emby Api Key" value="{{server.apiKey}}">
</div>
</div>
<div class="form-group">
<div>
<button id="testPlex" type="submit" (click)="test()" class="btn btn-primary-outline">Test Connectivity <div id="spinner"></div></button>
</div>
</div>
</ng-template>
</ngb-tab>
</div>
</ngb-tabset>
<div class="form-group"> <div class="form-group">
<div> <div>

@ -1,6 +1,6 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { IEmbySettings } from '../../interfaces/ISettings' import { IEmbySettings, IEmbyServer } from '../../interfaces/ISettings'
import { SettingsService } from '../../services/settings.service'; import { SettingsService } from '../../services/settings.service';
import { NotificationService } from "../../services/notification.service"; import { NotificationService } from "../../services/notification.service";
@ -18,6 +18,13 @@ export class EmbyComponent implements OnInit {
this.settingsService.getEmby().subscribe(x => this.settings = x); this.settingsService.getEmby().subscribe(x => this.settings = x);
} }
addTab() {
if (this.settings.servers == null) {
this.settings.servers = [];
}
this.settings.servers.push(<IEmbyServer>{ name: "New*", id: Math.floor(Math.random() * (99999 - 0 + 1) + 1), apiKey: "", administratorId: "", enableEpisodeSearching: false, ip: "", port: 0, ssl: false, subDir: "" });
}
test() { test() {
// TODO Emby Service // TODO Emby Service
} }

@ -62,10 +62,9 @@ export class PlexComponent implements OnInit, OnDestroy {
addTab() { addTab() {
if (this.settings.servers == null) { if (this.settings.servers == null) {
this.settings.servers = []; this.settings.servers = [];
this.settings.servers.push(<IPlexServer>{ name: "New*", id: Math.floor(Math.random() * (99999 - 0 + 1) + 1) }); }
} else { this.settings.servers.push(<IPlexServer>{ name: "New*", id: Math.floor(Math.random() * (99999 - 0 + 1) + 1) });
this.notificationService.warning("Disabled", "Support for multiple servers is not available yet");
}
} }
removeServer(server: IPlexServer) { removeServer(server: IPlexServer) {

@ -4,36 +4,40 @@
<div class="media"> <div class="media">
<div id="contentBody" class="media-body"> <div id="contentBody" class="media-body">
<h4 class="media-heading landing-title">Emby Authentication</h4> <h4 class="media-heading landing-title">Emby Authentication</h4>
<div *ngIf="embySettings"> <div *ngIf="embySettings">
<div class="form-group"> <div *ngIf="embySettings.servers">
<label for="Ip" class="control-label">Emby Hostname or IP Address</label> <div *ngFor="let server of embySettings.servers">
<div> <div class="form-group">
<input type="text" [(ngModel)]="embySettings.ip" class="form-control form-control-custom " id="Ip" name="Ip" placeholder="192.168.1.1"> <label for="Ip" class="control-label">Emby Hostname or IP Address</label>
</div> <div>
</div> <input type="text" [(ngModel)]="server.ip" class="form-control form-control-custom " id="Ip" name="Ip" placeholder="192.168.1.1">
</div>
</div>
<div class="form-group"> <div class="form-group">
<label for="portNumber" class="control-label">Port</label> <label for="portNumber" class="control-label">Port</label>
<div> <div>
<input type="text" [(ngModel)]="embySettings.port" class="form-control form-control-custom " id="portNumber" name="Port" value="{{embySettings.port}}"> <input type="text" [(ngModel)]="server.port" class="form-control form-control-custom " id="portNumber" name="Port" value="{{server.port}}">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="checkbox"> <div class="checkbox">
<input type="checkbox" [(ngModel)]="embySettings.ssl" id="Ssl" name="Ssl"><label for="Ssl">SSL</label> <input type="checkbox" [(ngModel)]="server.ssl" id="Ssl" name="Ssl"><label for="Ssl">SSL</label>
</div>
</div>
<div class="form-group">
<label for="username" class="control-label">Api Key</label>
<div>
<input type="text" [(ngModel)]="server.apiKey" class="form-control form-control-custom" id="apiKey" name="ApiKey" placeholder="ApiKey">
</div>
</div>
<div style="text-align: center; margin-top: 20px">
<a (click)="save()" id="embyApiKeySave" class="btn btn-primary-outline">Next <div id="spinner"></div></a>
</div>
</div>
</div> </div>
</div> </div>
<div class="form-group">
<label for="username" class="control-label">Api Key</label>
<div>
<input type="text" [(ngModel)]="embySettings.apiKey" class="form-control form-control-custom" id="apiKey" name="ApiKey" placeholder="ApiKey">
</div>
</div>
<div style="text-align: center; margin-top: 20px">
<a (click)="save()" id="embyApiKeySave" class="btn btn-primary-outline">Next <div id="spinner"></div></a>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>

@ -19,16 +19,22 @@ export class EmbyComponent implements OnInit {
ngOnInit(): void { ngOnInit(): void {
this.embySettings = { this.embySettings = {
administratorId: "", servers: [],
apiKey: "", id:0,
enable: true, enable: true,
enableEpisodeSearching: true, }
id: 0, this.embySettings.servers.push({
ip: "", ip: "",
administratorId: "",
id: 0,
apiKey: "",
enableEpisodeSearching: false,
name: "Default",
port: 8096, port: 8096,
ssl: false, ssl: false,
subDir:"" subDir: "",
}
})
} }
private embySettings: IEmbySettings; private embySettings: IEmbySettings;
@ -36,7 +42,7 @@ export class EmbyComponent implements OnInit {
save() { save() {
this.embyService.logIn(this.embySettings).subscribe(x => { this.embyService.logIn(this.embySettings).subscribe(x => {
if (x == null || !x.apiKey) { if (x == null || !x.servers[0].apiKey) {
this.notificationService.error("Could Not Authenticate", "Username or password was incorrect. Could not authenticate with Emby."); this.notificationService.error("Could Not Authenticate", "Username or password was incorrect. Could not authenticate with Emby.");
return; return;
} }

@ -41,15 +41,16 @@ namespace Ombi.Controllers.External
{ {
// Check if settings exist since we allow anon... // Check if settings exist since we allow anon...
var settings = await EmbySettings.GetSettingsAsync(); var settings = await EmbySettings.GetSettingsAsync();
if (!string.IsNullOrEmpty(settings?.ApiKey)) return null; if (settings?.Servers?.Any() ?? false) return null;
request.Enable = true; request.Enable = true;
var firstServer = request.Servers.FirstOrDefault();
// Test that we can connect // Test that we can connect
var result = await EmbyApi.GetUsers(request.FullUri, request.ApiKey); var result = await EmbyApi.GetUsers(firstServer.FullUri, firstServer.ApiKey);
if (result != null && result.Any()) if (result != null && result.Any())
{ {
request.AdministratorId = result.FirstOrDefault(x => x.Policy.IsAdministrator)?.Id ?? string.Empty; firstServer.AdministratorId = result.FirstOrDefault(x => x.Policy.IsAdministrator)?.Id ?? string.Empty;
await EmbySettings.SaveSettingsAsync(request); await EmbySettings.SaveSettingsAsync(request);
return request; return request;

Loading…
Cancel
Save