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?.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.");
return false;
if (server?.Ip == null || string.IsNullOrEmpty(server?.ApiKey))
{
//Log.Warn("A setting is null, Ensure Emby is configured correctly, and we have a Emby Auth token.");
return false;
}
}
}
return emby.Enable;

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

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

@ -2,63 +2,87 @@
<settings-menu></settings-menu>
<div *ngIf="settings">
<fieldset>
<legend>Emby Configuration
<b>(UNDER CONSTRUCTION <i class="fa fa-smile-o"></i>)</b>
<legend>
Emby Configuration
</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">
<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)]="settings.ip" value="{{settings.ip}}">
<div class="row">
<div class="form-group col-md-3">
<div class="checkbox">
<input type="checkbox" id="enable" [(ngModel)]="settings.enable" [checked]="settings.enable">
<label for="enable">Enable</label>
</div>
</div>
</div>
<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 class="col-md-2 col-md-push-7">
<button type="submit" (click)="addTab()" class="btn btn-success-outline">Add Server</button>
</div>
</div>
<div class="form-group">
<div class="checkbox">
<input type="checkbox" id="ssl" [(ngModel)]="settings.ssl" ng-checked="settings.ssl">
<label for="ssl">SSL</label>
</div>
</div>
<ngb-tabset>
<div *ngFor="let server of settings.servers">
<ngb-tab [id]="server.id" [title]="server.name">
<ng-template ngbTabContent>
<br />
<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="checkbox">
<div class="form-group">
<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">
<label for="EnableTvEpisodeSearching">Enable Episode Searching</label>
<div class="form-group">
<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">
<label for="authToken" class="control-label">Emby Api Key</label>
<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>
</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>

@ -1,6 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { IEmbySettings } from '../../interfaces/ISettings'
import { IEmbySettings, IEmbyServer } from '../../interfaces/ISettings'
import { SettingsService } from '../../services/settings.service';
import { NotificationService } from "../../services/notification.service";
@ -18,6 +18,13 @@ export class EmbyComponent implements OnInit {
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() {
// TODO Emby Service
}

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

@ -4,36 +4,40 @@
<div class="media">
<div id="contentBody" class="media-body">
<h4 class="media-heading landing-title">Emby Authentication</h4>
<div *ngIf="embySettings">
<div class="form-group">
<label for="Ip" class="control-label">Emby Hostname or IP Address</label>
<div>
<input type="text" [(ngModel)]="embySettings.ip" class="form-control form-control-custom " id="Ip" name="Ip" placeholder="192.168.1.1">
</div>
</div>
<div *ngIf="embySettings">
<div *ngIf="embySettings.servers">
<div *ngFor="let server of embySettings.servers">
<div class="form-group">
<label for="Ip" class="control-label">Emby Hostname or IP Address</label>
<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">
<label for="portNumber" class="control-label">Port</label>
<div class="form-group">
<label for="portNumber" class="control-label">Port</label>
<div>
<input type="text" [(ngModel)]="embySettings.port" class="form-control form-control-custom " id="portNumber" name="Port" value="{{embySettings.port}}">
</div>
</div>
<div class="form-group">
<div class="checkbox">
<input type="checkbox" [(ngModel)]="embySettings.ssl" id="Ssl" name="Ssl"><label for="Ssl">SSL</label>
<div>
<input type="text" [(ngModel)]="server.port" class="form-control form-control-custom " id="portNumber" name="Port" value="{{server.port}}">
</div>
</div>
<div class="form-group">
<div class="checkbox">
<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 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>

@ -19,16 +19,22 @@ export class EmbyComponent implements OnInit {
ngOnInit(): void {
this.embySettings = {
administratorId: "",
apiKey: "",
servers: [],
id:0,
enable: true,
enableEpisodeSearching: true,
id: 0,
}
this.embySettings.servers.push({
ip: "",
administratorId: "",
id: 0,
apiKey: "",
enableEpisodeSearching: false,
name: "Default",
port: 8096,
ssl: false,
subDir:""
}
subDir: "",
})
}
private embySettings: IEmbySettings;
@ -36,7 +42,7 @@ export class EmbyComponent implements OnInit {
save() {
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.");
return;
}

@ -41,15 +41,16 @@ namespace Ombi.Controllers.External
{
// Check if settings exist since we allow anon...
var settings = await EmbySettings.GetSettingsAsync();
if (!string.IsNullOrEmpty(settings?.ApiKey)) return null;
if (settings?.Servers?.Any() ?? false) return null;
request.Enable = true;
var firstServer = request.Servers.FirstOrDefault();
// 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())
{
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);
return request;

Loading…
Cancel
Save