diff --git a/Ombi/Ombi.Api.Plex/Models/Metadata.cs b/Ombi/Ombi.Api.Plex/Models/Metadata.cs index a4f36c9a1..0d803901f 100644 --- a/Ombi/Ombi.Api.Plex/Models/Metadata.cs +++ b/Ombi/Ombi.Api.Plex/Models/Metadata.cs @@ -18,7 +18,7 @@ namespace Ombi.Api.Plex.Models public string art { get; set; } public string banner { get; set; } public string theme { get; set; } - public int duration { get; set; } + public string duration { get; set; } public string originallyAvailableAt { get; set; } public int leafCount { get; set; } public int viewedLeafCount { get; set; } diff --git a/Ombi/Ombi.Api.Plex/Models/Part.cs b/Ombi/Ombi.Api.Plex/Models/Part.cs index 6116366da..a3538574c 100644 --- a/Ombi/Ombi.Api.Plex/Models/Part.cs +++ b/Ombi/Ombi.Api.Plex/Models/Part.cs @@ -4,9 +4,9 @@ { public int id { get; set; } public string key { get; set; } - public int duration { get; set; } + public string duration { get; set; } public string file { get; set; } - public int size { get; set; } + public string size { get; set; } public string audioProfile { get; set; } public string container { get; set; } public string videoProfile { get; set; } diff --git a/Ombi/Ombi.Api.Plex/PlexApi.cs b/Ombi/Ombi.Api.Plex/PlexApi.cs index 64b29cc82..bf6b1d4dd 100644 --- a/Ombi/Ombi.Api.Plex/PlexApi.cs +++ b/Ombi/Ombi.Api.Plex/PlexApi.cs @@ -64,14 +64,14 @@ namespace Ombi.Api.Plex public async Task GetLibrarySections(string authToken, string plexFullHost) { - var request = new Request(plexFullHost, "library/sections", HttpMethod.Get); + var request = new Request("library/sections", plexFullHost, HttpMethod.Get); AddHeaders(request, authToken); return await Api.Request(request); } public async Task GetLibrary(string authToken, string plexFullHost, string libraryId) { - var request = new Request(plexFullHost, $"library/sections/{libraryId}/all", HttpMethod.Get); + var request = new Request($"library/sections/{libraryId}/all", plexFullHost, HttpMethod.Get); AddHeaders(request, authToken); return await Api.Request(request); } @@ -89,21 +89,21 @@ namespace Ombi.Api.Plex /// public async Task GetEpisodeMetaData(string authToken, string plexFullHost, string ratingKey) { - var request = new Request(plexFullHost, $"/library/metadata/{ratingKey}", HttpMethod.Get); + var request = new Request($"/library/metadata/{ratingKey}", plexFullHost, HttpMethod.Get); AddHeaders(request, authToken); return await Api.Request(request); } public async Task GetMetadata(string authToken, string plexFullHost, string itemId) { - var request = new Request(plexFullHost, $"library/metadata/{itemId}", HttpMethod.Get); + var request = new Request($"library/metadata/{itemId}", plexFullHost, HttpMethod.Get); AddHeaders(request, authToken); return await Api.Request(request); } public async Task GetSeasons(string authToken, string plexFullHost, string ratingKey) { - var request = new Request(plexFullHost, $"library/metadata/{ratingKey}/children", HttpMethod.Get); + var request = new Request($"library/metadata/{ratingKey}/children", plexFullHost, HttpMethod.Get); AddHeaders(request, authToken); return await Api.Request(request); } diff --git a/Ombi/Ombi.DependencyInjection/IocExtensions.cs b/Ombi/Ombi.DependencyInjection/IocExtensions.cs index d3dcbf7ff..bf41f6350 100644 --- a/Ombi/Ombi.DependencyInjection/IocExtensions.cs +++ b/Ombi/Ombi.DependencyInjection/IocExtensions.cs @@ -70,6 +70,7 @@ namespace Ombi.DependencyInjection services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddTransient(typeof(ISettingsService<>), typeof(SettingsServiceV2<>)); return services; } diff --git a/Ombi/Ombi.Schedule/Jobs/PlexContentCacher.cs b/Ombi/Ombi.Schedule/Jobs/PlexContentCacher.cs index 39b0ce005..9459bb657 100644 --- a/Ombi/Ombi.Schedule/Jobs/PlexContentCacher.cs +++ b/Ombi/Ombi.Schedule/Jobs/PlexContentCacher.cs @@ -28,26 +28,32 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; using Microsoft.Extensions.Logging; using Ombi.Api.Plex; using Ombi.Api.Plex.Models; using Ombi.Core.Settings; using Ombi.Core.Settings.Models.External; +using Ombi.Helpers; +using Ombi.Store.Entities; +using Ombi.Store.Repository; namespace Ombi.Schedule.Jobs { public partial class PlexContentCacher : IPlexContentCacher { - public PlexContentCacher(ISettingsService plex, IPlexApi plexApi, ILogger logger) + public PlexContentCacher(ISettingsService plex, IPlexApi plexApi, ILogger logger, IPlexContentRepository repo) { Plex = plex; PlexApi = plexApi; Logger = logger; + Repo = repo; } private ISettingsService Plex { get; } private IPlexApi PlexApi { get; } private ILogger Logger { get; } + private IPlexContentRepository Repo { get; } public void CacheContent() { @@ -63,7 +69,7 @@ namespace Ombi.Schedule.Jobs Logger.LogInformation("Starting Plex Content Cacher"); //TODO - //var libraries = CachedLibraries(plexSettings); + StartTheCache(plexSettings).Wait(); //if (libraries == null || !libraries.Any()) //{ @@ -95,7 +101,7 @@ namespace Ombi.Schedule.Jobs // t1.seasons.AddRange(filtered); // } - // var providerId = PlexHelper.GetProviderIdFromPlexGuid(metaData.MediaContainer.); + // var providerId = PlexHelper.GetProviderIdFromPlexGuid(metaData.MediaContainer); // t1.providerId = providerId; // } // foreach (Video t1 in t.Video) @@ -110,19 +116,103 @@ namespace Ombi.Schedule.Jobs //} - private List GetLibraries(PlexSettings plexSettings) + private async Task StartTheCache(PlexSettings plexSettings) + { + var allContent = GetAllContent(plexSettings); + + // Let's now process this. + + foreach (var content in allContent) + { + var contentToAdd = new List(); + if (content.viewGroup.Equals(PlexMediaType.Show.ToString(), StringComparison.CurrentCultureIgnoreCase)) + { + // Process Shows + foreach (var metadata in content.Metadata) + { + var seasonList = await PlexApi.GetSeasons(plexSettings.PlexAuthToken, plexSettings.FullUri, + metadata.ratingKey); + var seasonsContent = new List(); + foreach (var season in seasonList.MediaContainer.Metadata) + { + seasonsContent.Add(new SeasonsContent + { + ParentKey = int.Parse(season.parentRatingKey), + SeasonKey = int.Parse(season.ratingKey), + SeasonNumber = season.index + }); + } + + // Do we already have this item? + var existingContent = await Repo.GetByKey(metadata.key); + if (existingContent != null) + { + // Ok so we have it, let's check if there are any new seasons + var seasonDifference = seasonsContent.Except(existingContent.Seasons).ToList(); + if (seasonDifference.Any()) + { + // We have new seasons on Plex, let's add them back into the entity + existingContent.Seasons.AddRange(seasonDifference); + await Repo.Update(existingContent); + continue; + } + else + { + // No changes, no need to do anything + continue; + } + } + + // Get the show metadata... This sucks since the `metadata` var contains all information about the show + // But it does not contain the `guid` property that we need to pull out thetvdb id... + var showMetadata = await PlexApi.GetMetadata(plexSettings.PlexAuthToken, plexSettings.FullUri, + metadata.ratingKey); + var item = new PlexContent + { + AddedAt = DateTime.Now, + Key = metadata.ratingKey, + ProviderId = PlexHelper.GetProviderIdFromPlexGuid(showMetadata.MediaContainer.Metadata + .FirstOrDefault() + .guid), + ReleaseYear = metadata.year.ToString(), + Type = PlexMediaTypeEntity.Show, + Title = metadata.title, + Url = PlexHelper.GetPlexMediaUrl(plexSettings.MachineIdentifier, metadata.ratingKey), + Seasons = new List() + }; + + + item.Seasons.AddRange(seasonsContent); + + contentToAdd.Add(item); + } + } + } + } + + private List GetAllContent(PlexSettings plexSettings) { var sections = PlexApi.GetLibrarySections(plexSettings.PlexAuthToken, plexSettings.FullUri).Result; - var libs = new List(); + var libs = new List(); if (sections != null) { foreach (var dir in sections.MediaContainer.Directory ?? new List()) { + if (plexSettings.PlexSelectedLibraries.Any()) + { + // Only get the enabled libs + var keys = plexSettings.PlexSelectedLibraries.Where(x => x.Enabled).Select(x => x.Key.ToString()).ToList(); + if (!keys.Contains(dir.key)) + { + // We are not monitoring this lib + continue; + } + } var lib = PlexApi.GetLibrary(plexSettings.PlexAuthToken, plexSettings.FullUri, dir.key).Result; if (lib != null) { - libs.Add(lib); + libs.Add(lib.MediaContainer); } } } diff --git a/Ombi/Ombi.Schedule/Jobs/PlexMediaType.cs b/Ombi/Ombi.Schedule/Jobs/PlexMediaType.cs index e8949e2e1..14fd8b228 100644 --- a/Ombi/Ombi.Schedule/Jobs/PlexMediaType.cs +++ b/Ombi/Ombi.Schedule/Jobs/PlexMediaType.cs @@ -32,9 +32,8 @@ namespace Ombi.Schedule.Jobs { public enum PlexMediaType { - Movie, - Show, - Artist + Movie = 0, + Show = 1 } } } \ No newline at end of file diff --git a/Ombi/Ombi.Settings/Settings/Models/External/PlexSettings.cs b/Ombi/Ombi.Settings/Settings/Models/External/PlexSettings.cs index 80c57af3b..d8691e1cf 100644 --- a/Ombi/Ombi.Settings/Settings/Models/External/PlexSettings.cs +++ b/Ombi/Ombi.Settings/Settings/Models/External/PlexSettings.cs @@ -1,4 +1,6 @@ -namespace Ombi.Core.Settings.Models.External +using System.Collections.Generic; + +namespace Ombi.Core.Settings.Models.External { public sealed class PlexSettings : ExternalSettings { @@ -8,5 +10,14 @@ public string PlexAuthToken { get; set; } public string MachineIdentifier { get; set; } + + public List PlexSelectedLibraries { get; set; } + } + + public class PlexSelectedLibraries + { + public int Key { get; set; } + public string Title { get; set; } // Name is for display purposes + public bool Enabled { get; set; } } } \ No newline at end of file diff --git a/Ombi/Ombi.Store/Context/IOmbiContext.cs b/Ombi/Ombi.Store/Context/IOmbiContext.cs index ae6705c5c..9b157a3bb 100644 --- a/Ombi/Ombi.Store/Context/IOmbiContext.cs +++ b/Ombi/Ombi.Store/Context/IOmbiContext.cs @@ -13,6 +13,7 @@ namespace Ombi.Store.Context Task SaveChangesAsync(CancellationToken cancellationToken = default(CancellationToken)); DbSet Requests { get; set; } DbSet Settings { get; set; } + DbSet PlexContent { get; set; } DbSet Users { get; set; } EntityEntry Entry(GlobalSettings settings); EntityEntry Attach(TEntity entity) where TEntity : class; diff --git a/Ombi/Ombi.Store/Context/OmbiContext.cs b/Ombi/Ombi.Store/Context/OmbiContext.cs index b6c72264b..ab069feb9 100644 --- a/Ombi/Ombi.Store/Context/OmbiContext.cs +++ b/Ombi/Ombi.Store/Context/OmbiContext.cs @@ -17,9 +17,13 @@ namespace Ombi.Store.Context } + public DbSet Requests { get; set; } public DbSet Settings { get; set; } public DbSet Users { get; set; } + public DbSet PlexContent { get; set; } + + public EntityEntry Entry(GlobalSettings settings) { return Entry(settings); diff --git a/Ombi/Ombi.Store/Entities/PlexContent.cs b/Ombi/Ombi.Store/Entities/PlexContent.cs new file mode 100644 index 000000000..0a32433ea --- /dev/null +++ b/Ombi/Ombi.Store/Entities/PlexContent.cs @@ -0,0 +1,68 @@ +#region Copyright +// /************************************************************************ +// Copyright (c) 2017 Jamie Rees +// File: PlexContent.cs +// Created By: Jamie Rees +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// ************************************************************************/ +#endregion + +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Ombi.Store.Entities +{ + [Table("PlexContent")] + public class PlexContent : Entity + { + public string Title { get; set; } + public string ReleaseYear { get; set; } + public string ProviderId { get; set; } + public PlexMediaTypeEntity Type { get; set; } + + public string Url { get; set; } + + /// + /// Only used for TV Shows + /// + public List Seasons { get; set; } + + /// + /// Plex's internal ID for this item + /// + public string Key { get; set; } + public DateTime AddedAt { get; set; } + } + + public class SeasonsContent : Entity + { + public int SeasonNumber { get; set; } + public int SeasonKey { get; set; } + public int ParentKey { get; set; } + } + + public enum PlexMediaTypeEntity + { + Movie = 0, + Show = 1 + } +} \ No newline at end of file diff --git a/Ombi/Ombi.Store/Ombi.Store.csproj b/Ombi/Ombi.Store/Ombi.Store.csproj index ffc1d529a..c3bae1c70 100644 --- a/Ombi/Ombi.Store/Ombi.Store.csproj +++ b/Ombi/Ombi.Store/Ombi.Store.csproj @@ -2,11 +2,11 @@ netstandard1.6 - + diff --git a/Ombi/Ombi.Store/Repository/IPlexContentRepository.cs b/Ombi/Ombi.Store/Repository/IPlexContentRepository.cs new file mode 100644 index 000000000..8cd1211ed --- /dev/null +++ b/Ombi/Ombi.Store/Repository/IPlexContentRepository.cs @@ -0,0 +1,16 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Ombi.Store.Entities; + +namespace Ombi.Store.Repository +{ + public interface IPlexContentRepository + { + Task Add(PlexContent content); + Task ContentExists(string providerId); + Task> GetAll(); + Task Get(string providerId); + Task GetByKey(string key); + Task Update(PlexContent existingContent); + } +} \ No newline at end of file diff --git a/Ombi/Ombi.Store/Repository/PlexContentRepository.cs b/Ombi/Ombi.Store/Repository/PlexContentRepository.cs new file mode 100644 index 000000000..76ba16200 --- /dev/null +++ b/Ombi/Ombi.Store/Repository/PlexContentRepository.cs @@ -0,0 +1,79 @@ +#region Copyright +// /************************************************************************ +// Copyright (c) 2017 Jamie Rees +// File: PlexContentRepository.cs +// Created By: Jamie Rees +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// ************************************************************************/ +#endregion + +using System.Collections.Generic; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; +using Ombi.Store.Context; +using Ombi.Store.Entities; + +namespace Ombi.Store.Repository +{ + public class PlexContentRepository : IPlexContentRepository + { + + public PlexContentRepository(IOmbiContext db) + { + Db = db; + } + + private IOmbiContext Db { get; } + + public async Task> GetAll() + { + return await Db.PlexContent.ToListAsync(); + } + + public async Task ContentExists(string providerId) + { + return await Db.PlexContent.AnyAsync(x => x.ProviderId == providerId); + } + + public async Task Add(PlexContent content) + { + await Db.PlexContent.AddAsync(content); + await Db.SaveChangesAsync(); + return content; + } + + public async Task Get(string providerId) + { + return await Db.PlexContent.FirstOrDefaultAsync(x => x.ProviderId == providerId); + } + + public async Task GetByKey(string key) + { + return await Db.PlexContent.FirstOrDefaultAsync(x => x.Key == key); + } + + public async Task Update(PlexContent existingContent) + { + Db.PlexContent.Update(existingContent); + await Db.SaveChangesAsync(); + } + } +} \ No newline at end of file diff --git a/Ombi/Ombi/.gitignore b/Ombi/Ombi/.gitignore index 6c6136a36..460a72440 100644 --- a/Ombi/Ombi/.gitignore +++ b/Ombi/Ombi/.gitignore @@ -18,3 +18,4 @@ npm-debug.log testem.log #/typings /systemjs.config.js* +/Logs/** diff --git a/Ombi/Ombi/Controllers/External/PlexController.cs b/Ombi/Ombi/Controllers/External/PlexController.cs index 62ce2c9e7..42d125199 100644 --- a/Ombi/Ombi/Controllers/External/PlexController.cs +++ b/Ombi/Ombi/Controllers/External/PlexController.cs @@ -49,6 +49,14 @@ namespace Ombi.Controllers.External return result; } + [HttpPost("Libraries")] + public async Task GetPlexLibraries([FromBody] PlexSettings settings) + { + var libs = await PlexApi.GetLibrarySections(settings.PlexAuthToken, settings.FullUri); + + return libs; + } + } } diff --git a/Ombi/Ombi/Ombi.csproj b/Ombi/Ombi/Ombi.csproj index ca485e117..33e0d2754 100644 --- a/Ombi/Ombi/Ombi.csproj +++ b/Ombi/Ombi/Ombi.csproj @@ -21,7 +21,7 @@ - + diff --git a/Ombi/Ombi/Startup.cs b/Ombi/Ombi/Startup.cs index 326a4cdca..1a57e7420 100644 --- a/Ombi/Ombi/Startup.cs +++ b/Ombi/Ombi/Startup.cs @@ -59,10 +59,10 @@ namespace Ombi // Add framework services. services.AddMvc(); services.AddOmbiMappingProfile(); - //services.AddAutoMapper(expression => - //{ - // expression.AddCollectionMappers(); - //}); + services.AddAutoMapper(expression => + { + expression.AddCollectionMappers(); + }); services.RegisterDependencies(); // Ioc and EF services.AddSingleton(); diff --git a/Ombi/Ombi/wwwroot/app/interfaces/IPlex.ts b/Ombi/Ombi/wwwroot/app/interfaces/IPlex.ts index 301f3e6df..0e3b317a1 100644 --- a/Ombi/Ombi/wwwroot/app/interfaces/IPlex.ts +++ b/Ombi/Ombi/wwwroot/app/interfaces/IPlex.ts @@ -10,3 +10,16 @@ export interface IPlexUser { title: string, authentication_token: string, } + +export interface IPlexLibraries { + mediaContainer:IMediaContainer; +} + +export interface IMediaContainer { + directory:IDirectory[]; +} + +export interface IDirectory { + key: string, + title: string, +} diff --git a/Ombi/Ombi/wwwroot/app/interfaces/ISettings.ts b/Ombi/Ombi/wwwroot/app/interfaces/ISettings.ts index 8b19af2e8..3a901ad2d 100644 --- a/Ombi/Ombi/wwwroot/app/interfaces/ISettings.ts +++ b/Ombi/Ombi/wwwroot/app/interfaces/ISettings.ts @@ -7,7 +7,7 @@ export interface IExternalSettings extends ISettings { enable:boolean, subDir: string, ip: string, - port:number + port:number, } export interface IOmbiSettings extends ISettings { @@ -21,13 +21,20 @@ export interface IOmbiSettings extends ISettings { export interface IEmbySettings extends IExternalSettings { apiKey: string, administratorId: string, - enableEpisodeSearching:boolean + enableEpisodeSearching:boolean, } export interface IPlexSettings extends IExternalSettings { enableEpisodeSearching: boolean, plexAuthToken: string, - machineIdentifier: string + machineIdentifier: string, + plexSelectedLibraries : IPlexLibraries[], +} + +export interface IPlexLibraries { + key: string, + title: string, + enabled:boolean, } export interface ISonarrSettings extends IExternalSettings { @@ -35,7 +42,7 @@ export interface ISonarrSettings extends IExternalSettings { qualityProfile: string, seasonFolders: boolean, rootPath: string, - fullRootPath:string + fullRootPath:string, } export interface ILandingPageSettings extends ISettings { @@ -52,5 +59,5 @@ export interface ILandingPageSettings extends ISettings { export interface ICustomizationSettings extends ISettings { applicationName: string, - logo:string + logo:string, } \ No newline at end of file diff --git a/Ombi/Ombi/wwwroot/app/services/applications/plex.service.ts b/Ombi/Ombi/wwwroot/app/services/applications/plex.service.ts index 0cfbd046e..9fa58fe28 100644 --- a/Ombi/Ombi/wwwroot/app/services/applications/plex.service.ts +++ b/Ombi/Ombi/wwwroot/app/services/applications/plex.service.ts @@ -1,20 +1,27 @@ import { Injectable } from '@angular/core'; -import { Http } from '@angular/http'; +import { Http } from '@angular/http' + +import { AuthHttp } from 'angular2-jwt';; import { Observable } from 'rxjs/Rx'; -import { ServiceHelpers } from '../service.helpers'; +import { ServiceAuthHelpers } from '../service.helpers'; -import { IPlexAuthentication } from '../../interfaces/IPlex' +import { IPlexAuthentication, IPlexLibraries} from '../../interfaces/IPlex'; +import { IPlexSettings } from '../../interfaces/ISettings'; @Injectable() -export class PlexService extends ServiceHelpers { - constructor(http: Http) { +export class PlexService extends ServiceAuthHelpers { + constructor(http: AuthHttp, private regularHttp: Http) { super(http, '/api/v1/Plex/'); } logIn(login: string, password: string): Observable { - return this.http.post(`${this.url}/`, JSON.stringify({ login: login, password:password}), { headers: this.headers }).map(this.extractData); + return this.regularHttp.post(`${this.url}`, JSON.stringify({ login: login, password:password}), { headers: this.headers }).map(this.extractData); + } + + getLibraries(plexSettings: IPlexSettings): Observable { + return this.http.post(`${this.url}Libraries`, JSON.stringify(plexSettings), { headers: this.headers }).map(this.extractData); } } \ No newline at end of file diff --git a/Ombi/Ombi/wwwroot/app/settings/plex/plex.component.html b/Ombi/Ombi/wwwroot/app/settings/plex/plex.component.html index 75dbacb6d..71d9aca68 100644 --- a/Ombi/Ombi/wwwroot/app/settings/plex/plex.component.html +++ b/Ombi/Ombi/wwwroot/app/settings/plex/plex.component.html @@ -3,36 +3,36 @@
Plex Configuration - +
- +
- +
- +
-
- +
+
- +
@@ -46,22 +46,22 @@ Please be aware that this is a very resource intensive process and while the Plex Episode Cacher job is running the application may appear slow (Depending on the size of your Plex library).
- - + +
- +
- +
- +
- +
@@ -69,7 +69,7 @@

- +
@@ -77,6 +77,24 @@
+ + +
+
+ +
+
+
+
+
+
+ + +
+
+ +
+
@@ -84,7 +102,7 @@
- +
diff --git a/Ombi/Ombi/wwwroot/app/settings/plex/plex.component.ts b/Ombi/Ombi/wwwroot/app/settings/plex/plex.component.ts index 76d92ae38..4a9a8dd9e 100644 --- a/Ombi/Ombi/wwwroot/app/settings/plex/plex.component.ts +++ b/Ombi/Ombi/wwwroot/app/settings/plex/plex.component.ts @@ -1,7 +1,10 @@ import { Component, OnInit } from '@angular/core'; -import { IPlexSettings } from '../../interfaces/ISettings' +import { IPlexSettings, IPlexLibraries } from '../../interfaces/ISettings' + + import { SettingsService } from '../../services/settings.service'; +import { PlexService } from '../../services/applications/plex.service'; import { NotificationService } from "../../services/notification.service"; @Component({ @@ -11,11 +14,11 @@ import { NotificationService } from "../../services/notification.service"; }) export class PlexComponent implements OnInit { - constructor(private settingsService: SettingsService, private notificationService: NotificationService) { } + constructor(private settingsService: SettingsService, private notificationService: NotificationService, private plexService: PlexService) { } settings: IPlexSettings; username: string; - password:string; + password: string; ngOnInit(): void { this.settingsService.getPlex().subscribe(x => this.settings = x); @@ -29,6 +32,22 @@ export class PlexComponent implements OnInit { // TODO Plex Service } + loadLibraries() { + this.plexService.getLibraries(this.settings).subscribe(x => { + + this.settings.plexSelectedLibraries = []; + x.mediaContainer.directory.forEach((item, index) => { + var lib: IPlexLibraries = { + key: item.key, + title: item.title, + enabled: false + }; + this.settings.plexSelectedLibraries.push(lib); + + }); + }); + } + save() { this.settingsService.savePlex(this.settings).subscribe(x => { if (x) {