From 890d74037a5dee57ead2b5d421bb394a25a7c062 Mon Sep 17 00:00:00 2001 From: tidusjar Date: Wed, 6 Apr 2022 20:02:52 +0100 Subject: [PATCH] wip: made a start on the import --- src/Ombi.Api.Plex/IPlexApi.cs | 2 ++ src/Ombi.Api.Plex/Models/PlexWatchlist.cs | 14 ++++++++++++ src/Ombi.Api.Plex/PlexApi.cs | 12 ++++++++++ .../Plex/Interfaces/IPlexWatchlistImport.cs | 6 +++++ .../Jobs/Plex/PlexWatchlistImport.cs | 22 +++++++++++++++++++ 5 files changed, 56 insertions(+) create mode 100644 src/Ombi.Api.Plex/Models/PlexWatchlist.cs create mode 100644 src/Ombi.Schedule/Jobs/Plex/Interfaces/IPlexWatchlistImport.cs create mode 100644 src/Ombi.Schedule/Jobs/Plex/PlexWatchlistImport.cs diff --git a/src/Ombi.Api.Plex/IPlexApi.cs b/src/Ombi.Api.Plex/IPlexApi.cs index a4597765e..445a7e6ce 100644 --- a/src/Ombi.Api.Plex/IPlexApi.cs +++ b/src/Ombi.Api.Plex/IPlexApi.cs @@ -1,4 +1,5 @@ using System; +using System.Threading; using System.Threading.Tasks; using Ombi.Api.Plex.Models; using Ombi.Api.Plex.Models.Friends; @@ -26,5 +27,6 @@ namespace Ombi.Api.Plex Task GetPin(int pinId); Task GetOAuthUrl(string code, string applicationUrl); Task AddUser(string emailAddress, string serverId, string authToken, int[] libs); + Task GetWatchlist(string plexToken, CancellationToken cancellationToken); } } \ No newline at end of file diff --git a/src/Ombi.Api.Plex/Models/PlexWatchlist.cs b/src/Ombi.Api.Plex/Models/PlexWatchlist.cs new file mode 100644 index 000000000..52ca82cf9 --- /dev/null +++ b/src/Ombi.Api.Plex/Models/PlexWatchlist.cs @@ -0,0 +1,14 @@ +using System.Collections.Generic; + +namespace Ombi.Api.Plex.Models +{ + public class PlexWatchlist + { + public string librarySectionID { get; set; } + public string librarySectionTitle { get; set; } + public int offset { get; set; } + public int totalSize { get; set; } + public int size { get; set; } + public List Metadata { get; set; } = new List(); + } +} \ No newline at end of file diff --git a/src/Ombi.Api.Plex/PlexApi.cs b/src/Ombi.Api.Plex/PlexApi.cs index 176af31ec..cee668236 100644 --- a/src/Ombi.Api.Plex/PlexApi.cs +++ b/src/Ombi.Api.Plex/PlexApi.cs @@ -1,5 +1,6 @@ using System; using System.Net.Http; +using System.Threading; using System.Threading.Tasks; using Newtonsoft.Json; using Ombi.Api.Plex.Models; @@ -66,6 +67,7 @@ namespace Ombi.Api.Plex private const string FriendsUri = "https://plex.tv/pms/friends/all"; private const string GetAccountUri = "https://plex.tv/users/account.json"; private const string ServerUri = "https://plex.tv/pms/servers.xml"; + private const string WatchlistUri = "https://metadata.provider.plex.tv/library/sections/watchlist/all"; /// /// Sign into the Plex API @@ -288,6 +290,16 @@ namespace Ombi.Api.Plex } } + public async Task GetWatchlist(string plexToken, CancellationToken cancellationToken) + { + var request = new Request(string.Empty, WatchlistUri, HttpMethod.Get); + await AddHeaders(request, plexToken); + + var result = await Api.Request(request, cancellationToken); + + return result; + } + /// /// Adds the required headers and also the authorization header diff --git a/src/Ombi.Schedule/Jobs/Plex/Interfaces/IPlexWatchlistImport.cs b/src/Ombi.Schedule/Jobs/Plex/Interfaces/IPlexWatchlistImport.cs new file mode 100644 index 000000000..2dd6d46e4 --- /dev/null +++ b/src/Ombi.Schedule/Jobs/Plex/Interfaces/IPlexWatchlistImport.cs @@ -0,0 +1,6 @@ +namespace Ombi.Schedule.Jobs.Plex +{ + public interface IPlexWatchlistImport : IBaseJob + { + } +} \ No newline at end of file diff --git a/src/Ombi.Schedule/Jobs/Plex/PlexWatchlistImport.cs b/src/Ombi.Schedule/Jobs/Plex/PlexWatchlistImport.cs new file mode 100644 index 000000000..d3626fc8d --- /dev/null +++ b/src/Ombi.Schedule/Jobs/Plex/PlexWatchlistImport.cs @@ -0,0 +1,22 @@ +using Quartz; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Ombi.Schedule.Jobs.Plex +{ + public class PlexWatchlistImport : IPlexWatchlistImport + { + public void Dispose() + { + throw new NotImplementedException(); + } + + public Task Execute(IJobExecutionContext context) + { + throw new NotImplementedException(); + } + } +}