Abstract media servers content into interfaces

This commit is contained in:
Florian Dupret 2022-01-10 17:23:26 +01:00
commit 0ad5083ac9
23 changed files with 128 additions and 147 deletions

View file

@ -929,7 +929,7 @@
<e p="EmbyConfiguration.cs" t="Include" />
<e p="EmbyConnectUser.cs" t="Include" />
<e p="EmbyItemContainer.cs" t="Include" />
<e p="EmbyMediaType.cs" t="Include" />
<e p="MediaType.cs" t="Include" />
<e p="EmbyPolicy.cs" t="Include" />
<e p="EmbySystemInfo.cs" t="Include" />
<e p="EmbyUser.cs" t="Include" />
@ -1876,7 +1876,7 @@
<e p="PlexAvailabilityChecker.cs" t="Include" />
<e p="PlexContentSync.cs" t="Include" />
<e p="PlexEpisodeSync.cs" t="Include" />
<e p="PlexMediaType.cs" t="Include" />
<e p="MediaType.cs" t="Include" />
<e p="PlexRecentlyAddedSync.cs" t="Include" />
<e p="PlexUserImporter.cs" t="Include" />
</e>

View file

@ -1,10 +0,0 @@
namespace Ombi.Api.Emby.Models
{
public enum EmbyMediaType
{
Movie = 0,
Series = 1,
Music = 2,
Episode = 3
}
}

View file

@ -1,10 +0,0 @@
namespace Ombi.Api.Jellyfin.Models
{
public enum JellyfinMediaType
{
Movie = 0,
Series = 1,
Music = 2,
Episode = 3
}
}

View file

@ -182,7 +182,7 @@ namespace Ombi.Core.Tests.Rule.Request
{
new PlexServerContent
{
Type = PlexMediaTypeEntity.Show,
Type = MediaType.Series,
TheMovieDbId = "1",
Title = "Test",
ReleaseYear = "2001",

View file

@ -30,26 +30,26 @@ namespace Ombi.Core.Engine
public IEnumerable<RecentlyAddedMovieModel> GetRecentlyAddedMovies(DateTime from, DateTime to)
{
var plexMovies = _plex.GetAll().Where(x => x.Type == PlexMediaTypeEntity.Movie && x.AddedAt > from && x.AddedAt < to);
var embyMovies = _emby.GetAll().Where(x => x.Type == EmbyMediaType.Movie && x.AddedAt > from && x.AddedAt < to);
var jellyfinMovies = _jellyfin.GetAll().Where(x => x.Type == JellyfinMediaType.Movie && x.AddedAt > from && x.AddedAt < to);
var plexMovies = _plex.GetAll().Where(x => x.Type == MediaType.Movie && x.AddedAt > from && x.AddedAt < to);
var embyMovies = _emby.GetAll().Where(x => x.Type == MediaType.Movie && x.AddedAt > from && x.AddedAt < to);
var jellyfinMovies = _jellyfin.GetAll().Where(x => x.Type == MediaType.Movie && x.AddedAt > from && x.AddedAt < to);
return GetRecentlyAddedMovies(plexMovies, embyMovies, jellyfinMovies).Take(30);
}
public IEnumerable<RecentlyAddedMovieModel> GetRecentlyAddedMovies()
{
var plexMovies = _plex.GetAll().Where(x => x.Type == PlexMediaTypeEntity.Movie);
var embyMovies = _emby.GetAll().Where(x => x.Type == EmbyMediaType.Movie);
var jellyfinMovies = _jellyfin.GetAll().Where(x => x.Type == JellyfinMediaType.Movie);
var plexMovies = _plex.GetAll().Where(x => x.Type == MediaType.Movie);
var embyMovies = _emby.GetAll().Where(x => x.Type == MediaType.Movie);
var jellyfinMovies = _jellyfin.GetAll().Where(x => x.Type == MediaType.Movie);
return GetRecentlyAddedMovies(plexMovies, embyMovies, jellyfinMovies);
}
public IEnumerable<RecentlyAddedTvModel> GetRecentlyAddedTv(DateTime from, DateTime to, bool groupBySeason)
{
var plexTv = _plex.GetAll().Include(x => x.Seasons).Include(x => x.Episodes).Where(x => x.Type == PlexMediaTypeEntity.Show && x.AddedAt > from && x.AddedAt < to);
var embyTv = _emby.GetAll().Include(x => x.Episodes).Where(x => x.Type == EmbyMediaType.Series && x.AddedAt > from && x.AddedAt < to);
var jellyfinTv = _jellyfin.GetAll().Include(x => x.Episodes).Where(x => x.Type == JellyfinMediaType.Series && x.AddedAt > from && x.AddedAt < to);
var plexTv = _plex.GetAll().Include(x => x.Seasons).Include(x => x.Episodes).Where(x => x.Type == MediaType.Series && x.AddedAt > from && x.AddedAt < to);
var embyTv = _emby.GetAll().Include(x => x.Episodes).Where(x => x.Type == MediaType.Series && x.AddedAt > from && x.AddedAt < to);
var jellyfinTv = _jellyfin.GetAll().Include(x => x.Episodes).Where(x => x.Type == MediaType.Series && x.AddedAt > from && x.AddedAt < to);
return GetRecentlyAddedTv(plexTv, embyTv, jellyfinTv, groupBySeason).Take(30);
}
@ -57,9 +57,9 @@ namespace Ombi.Core.Engine
public IEnumerable<RecentlyAddedTvModel> GetRecentlyAddedTv(bool groupBySeason)
{
var plexTv = _plex.GetAll().Include(x => x.Seasons).Include(x => x.Episodes).Where(x => x.Type == PlexMediaTypeEntity.Show);
var embyTv = _emby.GetAll().Include(x => x.Episodes).Where(x => x.Type == EmbyMediaType.Series);
var jellyfinTv = _jellyfin.GetAll().Include(x => x.Episodes).Where(x => x.Type == JellyfinMediaType.Series);
var plexTv = _plex.GetAll().Include(x => x.Seasons).Include(x => x.Episodes).Where(x => x.Type == MediaType.Series);
var embyTv = _emby.GetAll().Include(x => x.Episodes).Where(x => x.Type == MediaType.Series);
var jellyfinTv = _jellyfin.GetAll().Include(x => x.Episodes).Where(x => x.Type == MediaType.Series);
return GetRecentlyAddedTv(plexTv, embyTv, jellyfinTv, groupBySeason);
}
@ -76,7 +76,7 @@ namespace Ombi.Core.Engine
{
continue;
}
if (p.Type == PlexMediaTypeEntity.Movie)
if (p.Type == MediaType.Movie)
{
recentlyAddedLog.Add(new RecentlyAddedLog
{
@ -114,7 +114,7 @@ namespace Ombi.Core.Engine
{
continue;
}
if (e.Type == EmbyMediaType.Movie)
if (e.Type == MediaType.Movie)
{
recentlyAddedLog.Add(new RecentlyAddedLog
{
@ -152,7 +152,7 @@ namespace Ombi.Core.Engine
{
continue;
}
if (e.Type == JellyfinMediaType.Movie)
if (e.Type == MediaType.Movie)
{
recentlyAddedLog.Add(new RecentlyAddedLog
{

View file

@ -32,7 +32,7 @@ namespace Ombi.Core.Rule.Rules.Request
{
var tvRequest = (ChildRequests) obj;
var tvContent = _plexContent.GetAll().Include(x => x.Episodes).Where(x => x.Type == PlexMediaTypeEntity.Show);
var tvContent = _plexContent.GetAll().Include(x => x.Episodes).Where(x => x.Type == MediaType.Series);
// We need to do a check on the TVDBId
var anyMovieDbMatches = await tvContent.FirstOrDefaultAsync(x => x.TheMovieDbId.Length > 0 && x.TheMovieDbId == tvRequest.Id.ToString());
if (anyMovieDbMatches == null)

View file

@ -33,7 +33,7 @@ namespace Ombi.Core.Rule.Rules.Search
var useId = false;
var useTvDb = false;
PlexMediaTypeEntity type = ConvertType(obj.Type);
MediaType type = ConvertType(obj.Type);
if (obj.ImdbId.HasValue())
{
@ -115,12 +115,12 @@ namespace Ombi.Core.Rule.Rules.Search
return Success();
}
private PlexMediaTypeEntity ConvertType(RequestType type) =>
private MediaType ConvertType(RequestType type) =>
type switch
{
RequestType.Movie => PlexMediaTypeEntity.Movie,
RequestType.TvShow => PlexMediaTypeEntity.Show,
_ => PlexMediaTypeEntity.Movie,
RequestType.Movie => MediaType.Movie,
RequestType.TvShow => MediaType.Series,
_ => MediaType.Movie,
};
}
}

View file

@ -16,7 +16,7 @@ using Ombi.Schedule.Jobs.Ombi;
using Ombi.Store.Entities;
using Ombi.Store.Repository;
using Quartz;
using EmbyMediaType = Ombi.Store.Entities.EmbyMediaType;
using MediaType = Ombi.Store.Entities.MediaType;
namespace Ombi.Schedule.Jobs.Emby
{
@ -165,7 +165,7 @@ namespace Ombi.Schedule.Jobs.Emby
ImdbId = tvShow.ProviderIds?.Imdb,
TheMovieDbId = tvShow.ProviderIds?.Tmdb,
Title = tvShow.Name,
Type = EmbyMediaType.Series,
Type = MediaType.Series,
EmbyId = tvShow.Id,
Url = EmbyHelper.GetEmbyMediaUrl(tvShow.Id, server?.ServerId, server.ServerHostname),
AddedAt = DateTime.UtcNow
@ -255,7 +255,7 @@ namespace Ombi.Schedule.Jobs.Emby
ImdbId = movieInfo.ProviderIds.Imdb,
TheMovieDbId = movieInfo.ProviderIds?.Tmdb,
Title = movieInfo.Name,
Type = EmbyMediaType.Movie,
Type = MediaType.Movie,
EmbyId = movieInfo.Id,
Url = EmbyHelper.GetEmbyMediaUrl(movieInfo.Id, server?.ServerId, server.ServerHostname),
AddedAt = DateTime.UtcNow,

View file

@ -14,7 +14,7 @@ using Ombi.Schedule.Jobs.Ombi;
using Ombi.Store.Entities;
using Ombi.Store.Repository;
using Quartz;
using JellyfinMediaType = Ombi.Store.Entities.JellyfinMediaType;
using MediaType = Ombi.Store.Entities.MediaType;
namespace Ombi.Schedule.Jobs.Jellyfin
{
@ -143,7 +143,7 @@ namespace Ombi.Schedule.Jobs.Jellyfin
ImdbId = tvShow.ProviderIds?.Imdb,
TheMovieDbId = tvShow.ProviderIds?.Tmdb,
Title = tvShow.Name,
Type = JellyfinMediaType.Series,
Type = MediaType.Series,
JellyfinId = tvShow.Id,
Url = JellyfinHelper.GetJellyfinMediaUrl(tvShow.Id, server?.ServerId, server.ServerHostname),
AddedAt = DateTime.UtcNow
@ -223,7 +223,7 @@ namespace Ombi.Schedule.Jobs.Jellyfin
ImdbId = movieInfo.ProviderIds.Imdb,
TheMovieDbId = movieInfo.ProviderIds?.Tmdb,
Title = movieInfo.Name,
Type = JellyfinMediaType.Movie,
Type = MediaType.Movie,
JellyfinId = movieInfo.Id,
Url = JellyfinHelper.GetJellyfinMediaUrl(movieInfo.Id, server?.ServerId, server.ServerHostname),
AddedAt = DateTime.UtcNow,

View file

@ -145,9 +145,10 @@ namespace Ombi.Schedule.Jobs.Ombi
// Filter out the ones that we haven't sent yet
var plexContentLocalDataset = plexContent.Where(x => x.Type == PlexMediaTypeEntity.Movie && !string.IsNullOrEmpty(x.TheMovieDbId)).ToHashSet();
var embyContentLocalDataset = embyContent.Where(x => x.Type == EmbyMediaType.Movie && !string.IsNullOrEmpty(x.TheMovieDbId)).ToHashSet();
var jellyfinContentLocalDataset = jellyfinContent.Where(x => x.Type == JellyfinMediaType.Movie && !string.IsNullOrEmpty(x.TheMovieDbId)).ToHashSet();
var plexContentLocalDataset = plexContent.Where(x => x.Type == MediaType.Movie && !string.IsNullOrEmpty(x.TheMovieDbId)).ToHashSet();
var embyContentLocalDataset = embyContent.Where(x => x.Type == MediaType.Movie && !string.IsNullOrEmpty(x.TheMovieDbId)).ToHashSet();
var jellyfinContentLocalDataset = jellyfinContent.Where(x => x.Type == MediaType.Movie && !string.IsNullOrEmpty(x.TheMovieDbId)).ToHashSet();
var plexContentMoviesToSend = plexContentLocalDataset.Where(x => !addedPlexMovieLogIds.Contains(StringHelper.IntParseLinq(x.TheMovieDbId))).ToHashSet();
var embyContentMoviesToSend = embyContentLocalDataset.Where(x => !addedEmbyMoviesLogIds.Contains(StringHelper.IntParseLinq(x.TheMovieDbId))).ToHashSet();
var jellyfinContentMoviesToSend = jellyfinContentLocalDataset.Where(x => !addedJellyfinMoviesLogIds.Contains(StringHelper.IntParseLinq(x.TheMovieDbId))).ToHashSet();
@ -158,9 +159,9 @@ namespace Ombi.Schedule.Jobs.Ombi
_log.LogInformation("Albums to send: {0}", lidarrContentAlbumsToSend.Count());
// Find the movies that do not yet have MovieDbIds
var needsMovieDbPlex = plexContent.Where(x => x.Type == PlexMediaTypeEntity.Movie && !string.IsNullOrEmpty(x.TheMovieDbId)).ToHashSet();
var needsMovieDbEmby = embyContent.Where(x => x.Type == EmbyMediaType.Movie && !string.IsNullOrEmpty(x.TheMovieDbId)).ToHashSet();
var needsMovieDbJellyfin = jellyfinContent.Where(x => x.Type == JellyfinMediaType.Movie && !string.IsNullOrEmpty(x.TheMovieDbId)).ToHashSet();
var needsMovieDbPlex = plexContent.Where(x => x.Type == MediaType.Movie && !string.IsNullOrEmpty(x.TheMovieDbId)).ToHashSet();
var needsMovieDbEmby = embyContent.Where(x => x.Type == MediaType.Movie && !string.IsNullOrEmpty(x.TheMovieDbId)).ToHashSet();
var needsMovieDbJellyfin = jellyfinContent.Where(x => x.Type == MediaType.Movie && !string.IsNullOrEmpty(x.TheMovieDbId)).ToHashSet();
var newPlexMovies = await GetMoviesWithoutId(addedPlexMovieLogIds, needsMovieDbPlex);
var newEmbyMovies = await GetMoviesWithoutId(addedEmbyMoviesLogIds, needsMovieDbEmby);
var newJellyfinMovies = await GetMoviesWithoutId(addedJellyfinMoviesLogIds, needsMovieDbJellyfin);
@ -188,9 +189,9 @@ namespace Ombi.Schedule.Jobs.Ombi
var body = string.Empty;
if (test)
{
var plexm = plexContent.Where(x => x.Type == PlexMediaTypeEntity.Movie).OrderByDescending(x => x.AddedAt).Take(10);
var embym = embyContent.Where(x => x.Type == EmbyMediaType.Movie).OrderByDescending(x => x.AddedAt).Take(10);
var jellyfinm = jellyfinContent.Where(x => x.Type == JellyfinMediaType.Movie).OrderByDescending(x => x.AddedAt).Take(10);
var plexm = plexContent.Where(x => x.Type == MediaType.Movie).OrderByDescending(x => x.AddedAt).Take(10);
var embym = embyContent.Where(x => x.Type == MediaType.Movie).OrderByDescending(x => x.AddedAt).Take(10);
var jellyfinm = jellyfinContent.Where(x => x.Type == MediaType.Movie).OrderByDescending(x => x.AddedAt).Take(10);
var plext = _plex.GetAllEpisodes().Include(x => x.Series).OrderByDescending(x => x.Series.AddedAt).Take(10).ToHashSet();
var embyt = _emby.GetAllEpisodes().Include(x => x.Series).OrderByDescending(x => x.AddedAt).Take(10).ToHashSet();
var jellyfint = _jellyfin.GetAllEpisodes().Include(x => x.Series).OrderByDescending(x => x.AddedAt).Take(10).ToHashSet();
@ -284,7 +285,7 @@ namespace Ombi.Schedule.Jobs.Ombi
}
foreach (var e in embyContentMoviesToSend)
{
if (e.Type == EmbyMediaType.Movie)
if (e.Type == MediaType.Movie)
{
recentlyAddedLog.Add(new RecentlyAddedLog
{
@ -311,7 +312,7 @@ namespace Ombi.Schedule.Jobs.Ombi
foreach (var e in jellyfinContentMoviesToSend)
{
if (e.Type == JellyfinMediaType.Movie)
if (e.Type == MediaType.Movie)
{
recentlyAddedLog.Add(new RecentlyAddedLog
{
@ -570,9 +571,9 @@ namespace Ombi.Schedule.Jobs.Ombi
var ombiSettings = await _ombiSettings.GetSettingsAsync();
var sb = new StringBuilder();
var plexMovies = plexContentToSend.Where(x => x.Type == PlexMediaTypeEntity.Movie);
var embyMovies = embyContentToSend.Where(x => x.Type == EmbyMediaType.Movie);
var jellyfinMovies = jellyfinContentToSend.Where(x => x.Type == JellyfinMediaType.Movie);
var plexMovies = plexContentToSend.Where(x => x.Type == MediaType.Movie);
var embyMovies = embyContentToSend.Where(x => x.Type == MediaType.Movie);
var jellyfinMovies = jellyfinContentToSend.Where(x => x.Type == MediaType.Movie);
if ((plexMovies.Any() || embyMovies.Any() || jellyfinMovies.Any()) && !settings.DisableMovies)
{
sb.Append("<h1 style=\"text-align: center; max-width: 1042px;\">New Movies</h1><br /><br />");

View file

@ -116,12 +116,12 @@ namespace Ombi.Schedule.Jobs.Ombi
{
// Ensure we check that we have not linked this item to a request
var allMovies = await _plexRepo.GetAll().Where(x =>
x.Type == PlexMediaTypeEntity.Movie && x.RequestId == null && (x.TheMovieDbId == null || x.ImdbId == null)).ToListAsync();
x.Type == MediaType.Movie && x.RequestId == null && (x.TheMovieDbId == null || x.ImdbId == null)).ToListAsync();
await StartPlexMovies(allMovies);
// Now Tv
var allTv = await _plexRepo.GetAll().Where(x =>
x.Type == PlexMediaTypeEntity.Show && x.RequestId == null && (x.TheMovieDbId == null || x.ImdbId == null || x.TvDbId == null)).ToListAsync();
x.Type == MediaType.Series && x.RequestId == null && (x.TheMovieDbId == null || x.ImdbId == null || x.TvDbId == null)).ToListAsync();
await StartPlexTv(allTv);
}
@ -178,7 +178,7 @@ namespace Ombi.Schedule.Jobs.Ombi
private async Task StartEmbyTv()
{
var allTv = await _embyRepo.GetAll().Where(x =>
x.Type == EmbyMediaType.Series && (x.TheMovieDbId == null || x.ImdbId == null || x.TvDbId == null)).ToListAsync();
x.Type == MediaType.Series && (x.TheMovieDbId == null || x.ImdbId == null || x.TvDbId == null)).ToListAsync();
foreach (var show in allTv)
{
@ -213,7 +213,7 @@ namespace Ombi.Schedule.Jobs.Ombi
private async Task StartJellyfinTv()
{
var allTv = await _jellyfinRepo.GetAll().Where(x =>
x.Type == JellyfinMediaType.Series && (x.TheMovieDbId == null || x.ImdbId == null || x.TvDbId == null)).ToListAsync();
x.Type == MediaType.Series && (x.TheMovieDbId == null || x.ImdbId == null || x.TvDbId == null)).ToListAsync();
foreach (var show in allTv)
{
@ -278,7 +278,7 @@ namespace Ombi.Schedule.Jobs.Ombi
private async Task StartEmbyMovies(EmbySettings settings)
{
var allMovies = await _embyRepo.GetAll().Where(x =>
x.Type == EmbyMediaType.Movie && (x.TheMovieDbId == null || x.ImdbId == null)).ToListAsync();
x.Type == MediaType.Movie && (x.TheMovieDbId == null || x.ImdbId == null)).ToListAsync();
foreach (var movie in allMovies)
{
movie.ImdbId.HasValue();
@ -333,7 +333,7 @@ namespace Ombi.Schedule.Jobs.Ombi
private async Task StartJellyfinMovies(JellyfinSettings settings)
{
var allMovies = await _jellyfinRepo.GetAll().Where(x =>
x.Type == JellyfinMediaType.Movie && (x.TheMovieDbId == null || x.ImdbId == null)).ToListAsync();
x.Type == MediaType.Movie && (x.TheMovieDbId == null || x.ImdbId == null)).ToListAsync();
foreach (var movie in allMovies)
{
movie.ImdbId.HasValue();

View file

@ -182,7 +182,7 @@ namespace Ombi.Schedule.Jobs.Plex
foreach (var content in allContent.OrderByDescending(x => x.viewGroup))
{
Logger.LogDebug($"Got type '{content.viewGroup}' to process");
if (content.viewGroup.Equals(PlexMediaType.Episode.ToString(), StringComparison.InvariantCultureIgnoreCase))
if (content.viewGroup.Equals(MediaType.Episode.ToString(), StringComparison.InvariantCultureIgnoreCase))
{
Logger.LogDebug("Found some episodes, this must be a recently added sync");
var count = 0;
@ -230,7 +230,7 @@ namespace Ombi.Schedule.Jobs.Plex
episodesProcessed.AddRange(episodesAdded.Select(x => x.Id));
}
}
if (content.viewGroup.Equals(PlexMediaType.Show.ToString(), StringComparison.InvariantCultureIgnoreCase))
if (content.viewGroup.Equals(MediaType.Series.ToString(), StringComparison.InvariantCultureIgnoreCase))
{
// Process Shows
Logger.LogDebug("Processing TV Shows");
@ -260,7 +260,7 @@ namespace Ombi.Schedule.Jobs.Plex
await Repo.SaveChangesAsync();
}
if (content.viewGroup.Equals(PlexMediaType.Movie.ToString(), StringComparison.InvariantCultureIgnoreCase))
if (content.viewGroup.Equals(MediaType.Movie.ToString(), StringComparison.InvariantCultureIgnoreCase))
{
await MovieLoop(servers, content, contentToAdd, contentProcessed);
}
@ -301,7 +301,7 @@ namespace Ombi.Schedule.Jobs.Plex
{
var existing = await Repo.GetFirstContentByCustom(x => x.Title == movie.title
&& x.ReleaseYear == movie.year.ToString()
&& x.Type == PlexMediaTypeEntity.Movie);
&& x.Type == MediaType.Movie);
// The rating key keeps changing
//var existing = await Repo.GetByKey(movie.ratingKey);
if (existing != null)
@ -349,7 +349,7 @@ namespace Ombi.Schedule.Jobs.Plex
AddedAt = DateTime.Now,
Key = movie.ratingKey,
ReleaseYear = movie.year.ToString(),
Type = PlexMediaTypeEntity.Movie,
Type = MediaType.Movie,
Title = movie.title,
Url = PlexHelper.GetPlexMediaUrl(servers.MachineIdentifier, movie.ratingKey),
Seasons = new List<PlexSeasonsContent>(),
@ -411,7 +411,7 @@ namespace Ombi.Schedule.Jobs.Plex
// Let's try and match
var existingContent = await Repo.GetFirstContentByCustom(x => x.Title == show.title
&& x.ReleaseYear == show.year.ToString()
&& x.Type == PlexMediaTypeEntity.Show);
&& x.Type == MediaType.Series);
// Just double check the rating key, since this is our unique constraint
var existingKey = await Repo.GetByKey(show.ratingKey);
@ -553,7 +553,7 @@ namespace Ombi.Schedule.Jobs.Plex
AddedAt = DateTime.Now,
Key = show.ratingKey,
ReleaseYear = show.year.ToString(),
Type = PlexMediaTypeEntity.Show,
Type = MediaType.Series,
Title = show.title,
Url = PlexHelper.GetPlexMediaUrl(servers.MachineIdentifier, show.ratingKey),
Seasons = new List<PlexSeasonsContent>()
@ -567,19 +567,19 @@ namespace Ombi.Schedule.Jobs.Plex
if (item.ImdbId.HasValue())
{
existingImdb = await Repo.GetAll().AnyAsync(x =>
x.ImdbId == item.ImdbId && x.Type == PlexMediaTypeEntity.Show);
x.ImdbId == item.ImdbId && x.Type == MediaType.Series);
}
if (item.TheMovieDbId.HasValue())
{
existingMovieDbId = await Repo.GetAll().AnyAsync(x =>
x.TheMovieDbId == item.TheMovieDbId && x.Type == PlexMediaTypeEntity.Show);
x.TheMovieDbId == item.TheMovieDbId && x.Type == MediaType.Series);
}
if (item.TvDbId.HasValue())
{
existingTvDbId = await Repo.GetAll().AnyAsync(x =>
x.TvDbId == item.TvDbId && x.Type == PlexMediaTypeEntity.Show);
x.TvDbId == item.TvDbId && x.Type == MediaType.Series);
}
if (existingImdb || existingTvDbId || existingMovieDbId)

View file

@ -83,7 +83,7 @@ namespace Ombi.Schedule.Jobs.Plex
var sections = await _api.GetLibrarySections(settings.PlexAuthToken, settings.FullUri);
// Filter the libSections
var tvSections = sections.MediaContainer.Directory.Where(x => x.type.Equals(PlexMediaType.Show.ToString(), StringComparison.CurrentCultureIgnoreCase));
var tvSections = sections.MediaContainer.Directory.Where(x => x.type.Equals(MediaType.Series.ToString(), StringComparison.CurrentCultureIgnoreCase));
foreach (var section in tvSections)
{

View file

@ -1,37 +0,0 @@
#region Copyright
// /************************************************************************
// Copyright (c) 2017 Jamie Rees
// File: PlexContentCacher.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
namespace Ombi.Schedule.Jobs
{
public enum PlexMediaType
{
Movie = 0,
Show = 1,
Episode = 2,
}
}

View file

@ -32,7 +32,7 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace Ombi.Store.Entities
{
[Table("EmbyContent")]
public class EmbyContent : Entity
public class EmbyContent : Entity, IMediaServerContent<EmbyEpisode>
{
public string Title { get; set; }
@ -41,7 +41,7 @@ namespace Ombi.Store.Entities
/// </summary>
public string ProviderId { get; set; }
public string EmbyId { get; set; }
public EmbyMediaType Type { get; set; }
public MediaType Type { get; set; }
public DateTime AddedAt { get; set; }
public string ImdbId { get; set; }
@ -62,10 +62,4 @@ namespace Ombi.Store.Entities
public bool HasTheMovieDb => !string.IsNullOrEmpty(TheMovieDbId);
}
public enum EmbyMediaType
{
Movie = 0,
Series = 1,
Music = 2
}
}

View file

@ -32,7 +32,7 @@ using Microsoft.EntityFrameworkCore.Metadata;
namespace Ombi.Store.Entities
{
[Table("EmbyEpisode")]
public class EmbyEpisode : Entity
public class EmbyEpisode : Entity, IMediaServerEpisode<EmbyContent>
{
public string Title { get; set; }
public string EmbyId { get; set; }

View file

@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
namespace Ombi.Store.Entities
{
public interface IMediaServerContent<IMediaServerEpisode>
{
public string Title { get; set; }
public string ImdbId { get; set; }
public string TvDbId { get; set; }
public string TheMovieDbId { get; set; }
public MediaType Type { get; set; }
public string Url { get; set; }
public ICollection<IMediaServerEpisode> Episodes { get; set; }
public DateTime AddedAt { get; set; }
[NotMapped]
public bool HasImdb => !string.IsNullOrEmpty(ImdbId);
[NotMapped]
public bool HasTvDb => !string.IsNullOrEmpty(TvDbId);
[NotMapped]
public bool HasTheMovieDb => !string.IsNullOrEmpty(TheMovieDbId);
}
public interface IMediaServerEpisode<IMediaServerContent>
{
public int EpisodeNumber { get; set; }
public int SeasonNumber { get; set; }
public string Title { get; set; }
/// <summary>
/// The Season key
/// </summary>
/// <value>
/// The parent key.
/// </value>
public IMediaServerContent Series { get; set; }
}
public enum MediaType
{
Movie = 0,
Series = 1,
Music = 2,
Episode = 3
}
}

View file

@ -32,7 +32,7 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace Ombi.Store.Entities
{
[Table("JellyfinContent")]
public class JellyfinContent : Entity
public class JellyfinContent : Entity, IMediaServerContent<JellyfinEpisode>
{
public string Title { get; set; }
@ -41,7 +41,7 @@ namespace Ombi.Store.Entities
/// </summary>
public string ProviderId { get; set; }
public string JellyfinId { get; set; }
public JellyfinMediaType Type { get; set; }
public MediaType Type { get; set; }
public DateTime AddedAt { get; set; }
public string ImdbId { get; set; }
@ -62,10 +62,4 @@ namespace Ombi.Store.Entities
public bool HasTheMovieDb => !string.IsNullOrEmpty(TheMovieDbId);
}
public enum JellyfinMediaType
{
Movie = 0,
Series = 1,
Music = 2
}
}

View file

@ -32,7 +32,7 @@ using Microsoft.EntityFrameworkCore.Metadata;
namespace Ombi.Store.Entities
{
[Table("JellyfinEpisode")]
public class JellyfinEpisode : Entity
public class JellyfinEpisode : Entity, IMediaServerEpisode<JellyfinContent>
{
public string Title { get; set; }
public string JellyfinId { get; set; }

View file

@ -3,7 +3,7 @@
namespace Ombi.Store.Entities
{
[Table("PlexEpisode")]
public class PlexEpisode : Entity
public class PlexEpisode : Entity, IMediaServerEpisode<PlexServerContent>
{
public int EpisodeNumber { get; set; }
public int SeasonNumber { get; set; }

View file

@ -32,17 +32,18 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace Ombi.Store.Entities
{
[Table("PlexServerContent")]
public class PlexServerContent : Entity
public class PlexServerContent : Entity, IMediaServerContent<PlexEpisode>
{
public string Title { get; set; }
public string ReleaseYear { get; set; }
public string ImdbId { get; set; }
public string TvDbId { get; set; }
public string TheMovieDbId { get; set; }
public PlexMediaTypeEntity Type { get; set; }
public MediaType Type { get; set; }
public string Url { get; set; }
//public IMediaServerEpisode Episode { get; set; }
public ICollection<PlexEpisode> Episodes { get; set; }
public ICollection<PlexSeasonsContent> Seasons { get; set; }
@ -73,10 +74,4 @@ namespace Ombi.Store.Entities
public int SeasonKey { get; set; }
public int ParentKey { get; set; }
}
public enum PlexMediaTypeEntity
{
Movie = 0,
Show = 1
}
}

View file

@ -12,7 +12,7 @@ namespace Ombi.Store.Repository
{
Task<bool> ContentExists(string providerId);
Task<PlexServerContent> Get(string providerId, ProviderType type);
Task<PlexServerContent> GetByType(string providerId, ProviderType type, PlexMediaTypeEntity plexType);
Task<PlexServerContent> GetByType(string providerId, ProviderType type, MediaType plexType);
Task<PlexServerContent> GetByKey(int key);
Task Update(PlexServerContent existingContent);
IQueryable<PlexEpisode> GetAllEpisodes();

View file

@ -79,7 +79,7 @@ namespace Ombi.Store.Repository
return null;
}
public async Task<PlexServerContent> GetByType(string providerId, ProviderType type, PlexMediaTypeEntity plexType)
public async Task<PlexServerContent> GetByType(string providerId, ProviderType type, MediaType plexType)
{
switch (type)
{