mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-23 06:25:24 -07:00
Attempt at abstracting repositories (WIP)
This commit is contained in:
parent
94c341098f
commit
cfe5797fdc
20 changed files with 199 additions and 165 deletions
|
@ -168,7 +168,8 @@ namespace Ombi.Schedule.Jobs.Emby
|
||||||
Type = MediaType.Series,
|
Type = MediaType.Series,
|
||||||
EmbyId = tvShow.Id,
|
EmbyId = tvShow.Id,
|
||||||
Url = EmbyHelper.GetEmbyMediaUrl(tvShow.Id, server?.ServerId, server.ServerHostname),
|
Url = EmbyHelper.GetEmbyMediaUrl(tvShow.Id, server?.ServerId, server.ServerHostname),
|
||||||
AddedAt = DateTime.UtcNow
|
AddedAt = DateTime.UtcNow,
|
||||||
|
Repository = _repo
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -259,6 +260,7 @@ namespace Ombi.Schedule.Jobs.Emby
|
||||||
EmbyId = movieInfo.Id,
|
EmbyId = movieInfo.Id,
|
||||||
Url = EmbyHelper.GetEmbyMediaUrl(movieInfo.Id, server?.ServerId, server.ServerHostname),
|
Url = EmbyHelper.GetEmbyMediaUrl(movieInfo.Id, server?.ServerId, server.ServerHostname),
|
||||||
AddedAt = DateTime.UtcNow,
|
AddedAt = DateTime.UtcNow,
|
||||||
|
Repository = _repo
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -146,7 +146,8 @@ namespace Ombi.Schedule.Jobs.Jellyfin
|
||||||
Type = MediaType.Series,
|
Type = MediaType.Series,
|
||||||
JellyfinId = tvShow.Id,
|
JellyfinId = tvShow.Id,
|
||||||
Url = JellyfinHelper.GetJellyfinMediaUrl(tvShow.Id, server?.ServerId, server.ServerHostname),
|
Url = JellyfinHelper.GetJellyfinMediaUrl(tvShow.Id, server?.ServerId, server.ServerHostname),
|
||||||
AddedAt = DateTime.UtcNow
|
AddedAt = DateTime.UtcNow,
|
||||||
|
Repository = _repo
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -227,6 +228,7 @@ namespace Ombi.Schedule.Jobs.Jellyfin
|
||||||
JellyfinId = movieInfo.Id,
|
JellyfinId = movieInfo.Id,
|
||||||
Url = JellyfinHelper.GetJellyfinMediaUrl(movieInfo.Id, server?.ServerId, server.ServerHostname),
|
Url = JellyfinHelper.GetJellyfinMediaUrl(movieInfo.Id, server?.ServerId, server.ServerHostname),
|
||||||
AddedAt = DateTime.UtcNow,
|
AddedAt = DateTime.UtcNow,
|
||||||
|
Repository = _repo
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -5,7 +5,8 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
{
|
{
|
||||||
public abstract class HtmlTemplateGenerator
|
public abstract class HtmlTemplateGenerator
|
||||||
{
|
{
|
||||||
protected virtual void AddBackgroundInsideTable(StringBuilder sb, string url)
|
protected StringBuilder sb;
|
||||||
|
protected virtual void AddBackgroundInsideTable(string url)
|
||||||
{
|
{
|
||||||
sb.Append("<td align=\"center\" valign=\"top\" width=\"500\" height=\"252\" class=\"media-card\" style=\"font-size: 14px; font-family: 'Open Sans', Helvetica, Arial, sans-serif; vertical-align: top; padding: 3px; width: 500px; min-width: 500px; max-width: 500px; height: 252px; max-height: 252px; \">");
|
sb.Append("<td align=\"center\" valign=\"top\" width=\"500\" height=\"252\" class=\"media-card\" style=\"font-size: 14px; font-family: 'Open Sans', Helvetica, Arial, sans-serif; vertical-align: top; padding: 3px; width: 500px; min-width: 500px; max-width: 500px; height: 252px; max-height: 252px; \">");
|
||||||
sb.AppendFormat("<table class=\"card-bg\" width=\"500\" height=\"252\" background=\"url(0)\" bgcolor=\"#1f1f1f\" style=\"background-image: url(0); border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 500px; background-color: #1f1f1f; background-position: center; background-size: cover; background-repeat: no-repeat; background-clip: padding-box; border: 2px solid rgba(255, 118, 27, .4); height: 252px; max-height: 252px; \">", url);
|
sb.AppendFormat("<table class=\"card-bg\" width=\"500\" height=\"252\" background=\"url(0)\" bgcolor=\"#1f1f1f\" style=\"background-image: url(0); border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 500px; background-color: #1f1f1f; background-position: center; background-size: cover; background-repeat: no-repeat; background-clip: padding-box; border: 2px solid rgba(255, 118, 27, .4); height: 252px; max-height: 252px; \">", url);
|
||||||
|
@ -14,14 +15,14 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
sb.Append("<table class=\"bg-tint\" width=\"100%\" bgcolor=\"rgba(0, 0, 0, .6)\" style=\"border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%; background-color: rgba(0, 0, 0, .6); \">");
|
sb.Append("<table class=\"bg-tint\" width=\"100%\" bgcolor=\"rgba(0, 0, 0, .6)\" style=\"border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%; background-color: rgba(0, 0, 0, .6); \">");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void AddPosterInsideTable(StringBuilder sb, string url)
|
protected virtual void AddPosterInsideTable(string url)
|
||||||
{
|
{
|
||||||
sb.Append("<tr>");
|
sb.Append("<tr>");
|
||||||
sb.Append("<td class=\"poster-container\" width=\"150\" height=\"225\" valign=\"top\" style=\"ont-family: sans-serif; font-size: 14px; vertical-align: top; width: 150px; min-width: 150px; height: 225px; max-height: 225px; min-height: 225px; \">");
|
sb.Append("<td class=\"poster-container\" width=\"150\" height=\"225\" valign=\"top\" style=\"ont-family: sans-serif; font-size: 14px; vertical-align: top; width: 150px; min-width: 150px; height: 225px; max-height: 225px; min-height: 225px; \">");
|
||||||
sb.AppendFormat("<table class=\"poster-img\" width=\"100%\" style=\"border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%; \">", url);
|
sb.AppendFormat("<table class=\"poster-img\" width=\"100%\" style=\"border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%; \">", url);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void AddMediaServerUrl(StringBuilder sb, string mediaurl, string url)
|
protected virtual void AddMediaServerUrl(string mediaurl, string url)
|
||||||
{
|
{
|
||||||
if (url.HasValue())
|
if (url.HasValue())
|
||||||
{
|
{
|
||||||
|
@ -41,14 +42,14 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
sb.Append("</td>");
|
sb.Append("</td>");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void AddInfoTable(StringBuilder sb)
|
protected virtual void AddInfoTable()
|
||||||
{
|
{
|
||||||
sb.Append(
|
sb.Append(
|
||||||
"<td class=\"movie-info\" height=\"227\" valign=\"top\" align=\"left\" style=\"font-family: 'Open Sans', Helvetica, Arial, sans-serif; font-size: 14px; vertical-align: top; padding-left: 4px; text-align: left; height: 227px; \">");
|
"<td class=\"movie-info\" height=\"227\" valign=\"top\" align=\"left\" style=\"font-family: 'Open Sans', Helvetica, Arial, sans-serif; font-size: 14px; vertical-align: top; padding-left: 4px; text-align: left; height: 227px; \">");
|
||||||
sb.Append("<table style=\"border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%; height: 100%; \">");
|
sb.Append("<table style=\"border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%; height: 100%; \">");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void AddTitle(StringBuilder sb, string url, string title)
|
protected virtual void AddTitle( string url, string title)
|
||||||
{
|
{
|
||||||
sb.Append("<tr class=\"title\" valign=\"top\" style=\"font-family: 'Open Sans', Helvetica, Arial, sans-serif;font-size: 22px;line-height: 24px;vertical-align: top;max-width: 320px;display: block;height: 50px;min-height: 50px;max-height: 50px; \">");
|
sb.Append("<tr class=\"title\" valign=\"top\" style=\"font-family: 'Open Sans', Helvetica, Arial, sans-serif;font-size: 22px;line-height: 24px;vertical-align: top;max-width: 320px;display: block;height: 50px;min-height: 50px;max-height: 50px; \">");
|
||||||
sb.Append("<td>");
|
sb.Append("<td>");
|
||||||
|
@ -59,7 +60,7 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
sb.Append("</tr>");
|
sb.Append("</tr>");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void AddParagraph(StringBuilder sb, string text)
|
protected virtual void AddParagraph(string text)
|
||||||
{
|
{
|
||||||
sb.Append("<tr class=\"description\" style=\"font-family: 'Open Sans', Helvetica, Arial, sans-serif;height: 130px;max-height: 130px;max-width: 320px;overflow: hidden;text-overflow: ellipsis;display: block;font-size: 14px !important;text-align: justify;\" valign=\"top\">");
|
sb.Append("<tr class=\"description\" style=\"font-family: 'Open Sans', Helvetica, Arial, sans-serif;height: 130px;max-height: 130px;max-width: 320px;overflow: hidden;text-overflow: ellipsis;display: block;font-size: 14px !important;text-align: justify;\" valign=\"top\">");
|
||||||
sb.Append("<td style=\"font-family: sans-serif; font-size: 14px; vertical-align: top; \">");
|
sb.Append("<td style=\"font-family: sans-serif; font-size: 14px; vertical-align: top; \">");
|
||||||
|
@ -68,7 +69,7 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
sb.Append("</tr>");
|
sb.Append("</tr>");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void AddTvParagraph(StringBuilder sb, string episodes, string summary)
|
protected virtual void AddTvParagraph(string episodes, string summary)
|
||||||
{
|
{
|
||||||
sb.Append("<tr class=\"description\" style=\"font-family: 'Open Sans', Helvetica, Arial, sans-serif;height: 130px;max-height: 130px;max-width: 320px;overflow: hidden;text-overflow: ellipsis;display: block;font-size: 14px !important;text-align: justify;\" valign=\"top\">");
|
sb.Append("<tr class=\"description\" style=\"font-family: 'Open Sans', Helvetica, Arial, sans-serif;height: 130px;max-height: 130px;max-width: 320px;overflow: hidden;text-overflow: ellipsis;display: block;font-size: 14px !important;text-align: justify;\" valign=\"top\">");
|
||||||
sb.Append("<td style=\"font-family: sans-serif; font-size: 14px; vertical-align: top; \">");
|
sb.Append("<td style=\"font-family: sans-serif; font-size: 14px; vertical-align: top; \">");
|
||||||
|
@ -78,7 +79,7 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
sb.Append("</tr>");
|
sb.Append("</tr>");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void AddGenres(StringBuilder sb, string text)
|
protected virtual void AddGenres(string text)
|
||||||
{
|
{
|
||||||
sb.Append("<tr class=\"meta\" style=\"font-family: 'Open Sans', Helvetica, Arial, sans-serif; max-width: 300px; min-width: 300px; padding: 3px 7px; margin-top: 10px; line-height: 1; text-align: left; white-space: nowrap; vertical-align: middle; background-color: rgba(255, 118, 27, 0.5); color: #fff; border-radius: 2px; overflow: hidden; display: block; font-size: 0.9rem;\" align=\"left\" valign=\"middle\" bgcolor=\"rgba(255, 118, 27, 0.5)\">");
|
sb.Append("<tr class=\"meta\" style=\"font-family: 'Open Sans', Helvetica, Arial, sans-serif; max-width: 300px; min-width: 300px; padding: 3px 7px; margin-top: 10px; line-height: 1; text-align: left; white-space: nowrap; vertical-align: middle; background-color: rgba(255, 118, 27, 0.5); color: #fff; border-radius: 2px; overflow: hidden; display: block; font-size: 0.9rem;\" align=\"left\" valign=\"middle\" bgcolor=\"rgba(255, 118, 27, 0.5)\">");
|
||||||
sb.Append("<td style=\"font-family: sans-serif; font-size: 14px; vertical-align: top; \">");
|
sb.Append("<td style=\"font-family: sans-serif; font-size: 14px; vertical-align: top; \">");
|
||||||
|
|
|
@ -129,9 +129,12 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
var jellyfinContent = (IQueryable<IMediaServerContent>)_jellyfin.GetAll().Include(x => x.Episodes).AsNoTracking();
|
var jellyfinContent = (IQueryable<IMediaServerContent>)_jellyfin.GetAll().Include(x => x.Episodes).AsNoTracking();
|
||||||
|
|
||||||
// MOVIES
|
// MOVIES
|
||||||
var plexContentMoviesToSend = await GetMoviesContent(plexContent, RecentlyAddedType.Plex);
|
var moviesContents = new List<IQueryable<IMediaServerContent>>();
|
||||||
var embyContentMoviesToSend = await GetMoviesContent(embyContent, RecentlyAddedType.Emby);
|
// these explicit casts won't work because:
|
||||||
var jellyfinContentMoviesToSend = await GetMoviesContent(jellyfinContent, RecentlyAddedType.Jellyfin);
|
// Unable to cast object of type 'PlexServerContentRepository' to type 'IMediaServerContentRepository`1[IMediaServerContent]
|
||||||
|
moviesContents.Add((await GetMoviesContent((IMediaServerContentRepository<IMediaServerContent>)_plex)).AsQueryable());
|
||||||
|
moviesContents.Add((await GetMoviesContent((IMediaServerContentRepository<IMediaServerContent>)_emby)).AsQueryable());
|
||||||
|
moviesContents.Add((await GetMoviesContent((IMediaServerContentRepository<IMediaServerContent>)_jellyfin)).AsQueryable());
|
||||||
|
|
||||||
// MUSIC
|
// MUSIC
|
||||||
var lidarrContent = _lidarrAlbumRepository.GetAll().AsNoTracking().ToList().Where(x => x.FullyAvailable);
|
var lidarrContent = _lidarrAlbumRepository.GetAll().AsNoTracking().ToList().Where(x => x.FullyAvailable);
|
||||||
|
@ -176,12 +179,12 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
var jellyfint = _jellyfin.GetAllEpisodes().Include(x => x.Series).OrderByDescending(x => x.Series.AddedAt).Take(10).ToHashSet();
|
var jellyfint = _jellyfin.GetAllEpisodes().Include(x => x.Series).OrderByDescending(x => x.Series.AddedAt).Take(10).ToHashSet();
|
||||||
var lidarr = lidarrContent.OrderByDescending(x => x.AddedAt).Take(10).ToHashSet();
|
var lidarr = lidarrContent.OrderByDescending(x => x.AddedAt).Take(10).ToHashSet();
|
||||||
|
|
||||||
var moviesProviders = new List<IQueryable<IMediaServerContent>>() {
|
var moviesProviders = new List<IQueryable<IMediaServerContent>>() {
|
||||||
plexm,
|
plexm,
|
||||||
embym,
|
embym,
|
||||||
jellyfinm
|
jellyfinm
|
||||||
};
|
};
|
||||||
var seriesProviders = new List<IEnumerable<IMediaServerEpisode>>() {
|
var seriesProviders = new List<IEnumerable<IMediaServerEpisode>>() {
|
||||||
plext,
|
plext,
|
||||||
embyt,
|
embyt,
|
||||||
jellyfint
|
jellyfint
|
||||||
|
@ -190,18 +193,13 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var moviesProviders = new List<IQueryable<IMediaServerContent>>() {
|
var seriesProviders = new List<IEnumerable<IMediaServerEpisode>>() {
|
||||||
plexContentMoviesToSend.AsQueryable(),
|
|
||||||
embyContentMoviesToSend.AsQueryable(),
|
|
||||||
jellyfinContentMoviesToSend.AsQueryable()
|
|
||||||
};
|
|
||||||
var seriesProviders = new List<IEnumerable<IMediaServerEpisode>>() {
|
|
||||||
plexEpisodesToSend,
|
plexEpisodesToSend,
|
||||||
embyEpisodesToSend,
|
embyEpisodesToSend,
|
||||||
jellyfinEpisodesToSend
|
jellyfinEpisodesToSend
|
||||||
};
|
};
|
||||||
|
|
||||||
body = await BuildHtml(moviesProviders, seriesProviders, lidarrContentAlbumsToSend, settings, embySettings, jellyfinSettings, plexSettings);
|
body = await BuildHtml(moviesContents, seriesProviders, lidarrContentAlbumsToSend, settings, embySettings, jellyfinSettings, plexSettings);
|
||||||
if (body.IsNullOrEmpty())
|
if (body.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -260,17 +258,7 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
|
|
||||||
// Now add all of this to the Recently Added log
|
// Now add all of this to the Recently Added log
|
||||||
var recentlyAddedLog = new HashSet<RecentlyAddedLog>();
|
var recentlyAddedLog = new HashSet<RecentlyAddedLog>();
|
||||||
foreach (var p in plexContentMoviesToSend)
|
AddToRecentlyAddedLog(moviesContents, recentlyAddedLog);
|
||||||
{
|
|
||||||
recentlyAddedLog.Add(new RecentlyAddedLog
|
|
||||||
{
|
|
||||||
AddedAt = DateTime.Now,
|
|
||||||
Type = RecentlyAddedType.Plex,
|
|
||||||
ContentType = ContentType.Parent,
|
|
||||||
ContentId = StringHelper.IntParseLinq(p.TheMovieDbId),
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var p in plexEpisodesToSend)
|
foreach (var p in plexEpisodesToSend)
|
||||||
{
|
{
|
||||||
|
@ -284,19 +272,6 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
SeasonNumber = p.SeasonNumber
|
SeasonNumber = p.SeasonNumber
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
foreach (var e in embyContentMoviesToSend)
|
|
||||||
{
|
|
||||||
if (e.Type == MediaType.Movie)
|
|
||||||
{
|
|
||||||
recentlyAddedLog.Add(new RecentlyAddedLog
|
|
||||||
{
|
|
||||||
AddedAt = DateTime.Now,
|
|
||||||
Type = RecentlyAddedType.Emby,
|
|
||||||
ContentType = ContentType.Parent,
|
|
||||||
ContentId = StringHelper.IntParseLinq(e.TheMovieDbId),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var p in embyEpisodesToSend)
|
foreach (var p in embyEpisodesToSend)
|
||||||
{
|
{
|
||||||
|
@ -311,20 +286,6 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var e in jellyfinContentMoviesToSend)
|
|
||||||
{
|
|
||||||
if (e.Type == MediaType.Movie)
|
|
||||||
{
|
|
||||||
recentlyAddedLog.Add(new RecentlyAddedLog
|
|
||||||
{
|
|
||||||
AddedAt = DateTime.Now,
|
|
||||||
Type = RecentlyAddedType.Jellyfin,
|
|
||||||
ContentType = ContentType.Parent,
|
|
||||||
ContentId = StringHelper.IntParseLinq(e.TheMovieDbId),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var p in jellyfinEpisodesToSend)
|
foreach (var p in jellyfinEpisodesToSend)
|
||||||
{
|
{
|
||||||
recentlyAddedLog.Add(new RecentlyAddedLog
|
recentlyAddedLog.Add(new RecentlyAddedLog
|
||||||
|
@ -377,29 +338,49 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
.SendAsync(NotificationHub.NotificationEvent, "Newsletter Finished");
|
.SendAsync(NotificationHub.NotificationEvent, "Newsletter Finished");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void AddToRecentlyAddedLog(List<IQueryable<IMediaServerContent>> moviesContents,
|
||||||
|
HashSet<RecentlyAddedLog> recentlyAddedLog)
|
||||||
|
{
|
||||||
|
foreach (var contentProvider in moviesContents)
|
||||||
|
{
|
||||||
|
foreach (var p in contentProvider)
|
||||||
|
{
|
||||||
|
recentlyAddedLog.Add(new RecentlyAddedLog
|
||||||
|
{
|
||||||
|
AddedAt = DateTime.Now,
|
||||||
|
Type = p.Repository.RecentlyAddedType,
|
||||||
|
ContentType = ContentType.Parent,
|
||||||
|
ContentId = StringHelper.IntParseLinq(p.TheMovieDbId),
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void GetRecentlyAddedMoviesData(List<RecentlyAddedLog> addedLog, out HashSet<string> addedAlbumLogIds)
|
private void GetRecentlyAddedMoviesData(List<RecentlyAddedLog> addedLog, out HashSet<string> addedAlbumLogIds)
|
||||||
{
|
{
|
||||||
var lidarrParent = addedLog.Where(x => x.Type == RecentlyAddedType.Lidarr && x.ContentType == ContentType.Album);
|
var lidarrParent = addedLog.Where(x => x.Type == RecentlyAddedType.Lidarr && x.ContentType == ContentType.Album);
|
||||||
addedAlbumLogIds = lidarrParent != null && lidarrParent.Any() ? (lidarrParent?.Select(x => x.AlbumId)?.ToHashSet() ?? new HashSet<string>()) : new HashSet<string>();
|
addedAlbumLogIds = lidarrParent != null && lidarrParent.Any() ? (lidarrParent?.Select(x => x.AlbumId)?.ToHashSet() ?? new HashSet<string>()) : new HashSet<string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<HashSet<IMediaServerContent>> GetMoviesContent(IQueryable<IMediaServerContent> content, RecentlyAddedType recentlyAddedType)
|
private async Task<HashSet<IMediaServerContent>> GetMoviesContent(IMediaServerContentRepository<IMediaServerContent> repository)
|
||||||
{
|
{
|
||||||
|
var content = repository.GetAll().Include(x => x.Episodes).AsNoTracking();
|
||||||
var localDataset = content.Where(x => x.Type == MediaType.Movie && !string.IsNullOrEmpty(x.TheMovieDbId)).ToHashSet();
|
var localDataset = content.Where(x => x.Type == MediaType.Movie && !string.IsNullOrEmpty(x.TheMovieDbId)).ToHashSet();
|
||||||
// Filter out the ones that we haven't sent yet
|
// Filter out the ones that we haven't sent yet
|
||||||
var addedLog = _recentlyAddedLog.GetAll().ToList();
|
var addedLog = _recentlyAddedLog.GetAll().ToList();
|
||||||
var plexParent = addedLog.Where(x => x.Type == recentlyAddedType
|
var parent = addedLog.Where(x => x.Type == repository.RecentlyAddedType
|
||||||
&& x.ContentType == ContentType.Parent).ToList();
|
&& x.ContentType == ContentType.Parent).ToList();
|
||||||
var addedPlexMovieLogIds = plexParent != null && plexParent.Any() ? (plexParent?.Select(x => x.ContentId)?.ToHashSet() ?? new HashSet<int>()) : new HashSet<int>();
|
var addedMovieLogIds = parent != null && parent.Any() ? (parent?.Select(x => x.ContentId)?.ToHashSet() ?? new HashSet<int>()) : new HashSet<int>();
|
||||||
var plexContentMoviesToSend = localDataset.Where(x => !addedPlexMovieLogIds.Contains(StringHelper.IntParseLinq(x.TheMovieDbId))).ToHashSet();
|
var contentMoviesToSend = localDataset.Where(x => !addedMovieLogIds.Contains(StringHelper.IntParseLinq(x.TheMovieDbId))).ToHashSet();
|
||||||
_log.LogInformation("Movies to send: {0}", plexContentMoviesToSend.Count());
|
_log.LogInformation("Movies to send: {0}", contentMoviesToSend.Count());
|
||||||
|
|
||||||
// Find the movies that do not yet have MovieDbIds
|
// Find the movies that do not yet have MovieDbIds
|
||||||
var needsMovieDbPlex = content.Where(x => x.Type == MediaType.Movie && !string.IsNullOrEmpty(x.TheMovieDbId)).ToHashSet();
|
var needsMovieDb = content.Where(x => x.Type == MediaType.Movie && !string.IsNullOrEmpty(x.TheMovieDbId)).ToHashSet();
|
||||||
var newPlexMovies = await GetMoviesWithoutId(addedPlexMovieLogIds, needsMovieDbPlex);
|
var newMovies = await GetMoviesWithoutId(addedMovieLogIds, needsMovieDb, repository);
|
||||||
plexContentMoviesToSend = plexContentMoviesToSend.Union(newPlexMovies).ToHashSet();
|
contentMoviesToSend = contentMoviesToSend.Union(newMovies).ToHashSet();
|
||||||
|
|
||||||
return plexContentMoviesToSend.DistinctBy(x => x.Id).ToHashSet();
|
return contentMoviesToSend.DistinctBy(x => x.Id).ToHashSet();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -418,21 +399,21 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
return b.ToString();
|
return b.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<HashSet<IMediaServerContent>> GetMoviesWithoutId(HashSet<int> addedMovieLogIds, HashSet<IMediaServerContent> needsMovieDbPlex)
|
private async Task<HashSet<IMediaServerContent>> GetMoviesWithoutId(HashSet<int> addedMovieLogIds, HashSet<IMediaServerContent> needsMovieDb, IMediaServerContentRepository<IMediaServerContent> repository)
|
||||||
{
|
{
|
||||||
foreach (var movie in needsMovieDbPlex)
|
foreach (var movie in needsMovieDb)
|
||||||
{
|
{
|
||||||
var id = await _refreshMetadata.GetTheMovieDbId(false, true, null, movie.ImdbId, movie.Title, true);
|
var id = await _refreshMetadata.GetTheMovieDbId(false, true, null, movie.ImdbId, movie.Title, true);
|
||||||
movie.TheMovieDbId = id.ToString();
|
movie.TheMovieDbId = id.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
var result = needsMovieDbPlex.Where(x => x.HasTheMovieDb && !addedMovieLogIds.Contains(StringHelper.IntParseLinq(x.TheMovieDbId)));
|
var result = needsMovieDb.Where(x => x.HasTheMovieDb && !addedMovieLogIds.Contains(StringHelper.IntParseLinq(x.TheMovieDbId)));
|
||||||
await UpdateTheMovieDbId(result);
|
await UpdateTheMovieDbId(result, repository);
|
||||||
// Filter them out now
|
// Filter them out now
|
||||||
return result.ToHashSet();
|
return result.ToHashSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task UpdateTheMovieDbId(IEnumerable<IMediaServerContent> content)
|
private async Task UpdateTheMovieDbId(IEnumerable<IMediaServerContent> content, IMediaServerContentRepository<IMediaServerContent> repository)
|
||||||
{
|
{
|
||||||
foreach (var movie in content)
|
foreach (var movie in content)
|
||||||
{
|
{
|
||||||
|
@ -440,15 +421,15 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
var entity = await _plex.Find(movie.Id);
|
var entity = await repository.Find(movie.Id);
|
||||||
if (entity == null)
|
if (entity == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
entity.TheMovieDbId = movie.TheMovieDbId;
|
entity.TheMovieDbId = movie.TheMovieDbId;
|
||||||
_plex.UpdateWithoutSave(entity);
|
repository.UpdateWithoutSave(entity);
|
||||||
}
|
}
|
||||||
await _plex.SaveChangesAsync();
|
await repository.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Execute(IJobExecutionContext job)
|
public async Task Execute(IJobExecutionContext job)
|
||||||
|
@ -489,7 +470,7 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
PlexSettings plexSettings)
|
PlexSettings plexSettings)
|
||||||
{
|
{
|
||||||
var ombiSettings = await _ombiSettings.GetSettingsAsync();
|
var ombiSettings = await _ombiSettings.GetSettingsAsync();
|
||||||
var sb = new StringBuilder();
|
sb = new StringBuilder();
|
||||||
|
|
||||||
if (!settings.DisableMovies)
|
if (!settings.DisableMovies)
|
||||||
{
|
{
|
||||||
|
@ -502,7 +483,7 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
sb.Append("<tr>");
|
sb.Append("<tr>");
|
||||||
foreach (var mediaServerContent in contentToSend)
|
foreach (var mediaServerContent in contentToSend)
|
||||||
{
|
{
|
||||||
await ProcessMovies(mediaServerContent, sb, ombiSettings.DefaultLanguageCode, /*plexSettings.Servers?.FirstOrDefault()?.ServerHostname ?? */ string.Empty);
|
await ProcessMovies(mediaServerContent, ombiSettings.DefaultLanguageCode, /*plexSettings.Servers?.FirstOrDefault()?.ServerHostname ?? */ string.Empty);
|
||||||
}
|
}
|
||||||
sb.Append("</tr>");
|
sb.Append("</tr>");
|
||||||
sb.Append("</table>");
|
sb.Append("</table>");
|
||||||
|
@ -522,7 +503,7 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
sb.Append("<tr>");
|
sb.Append("<tr>");
|
||||||
foreach (var mediaServerContent in episodes)
|
foreach (var mediaServerContent in episodes)
|
||||||
{
|
{
|
||||||
await ProcessTv(mediaServerContent, sb, ombiSettings.DefaultLanguageCode, /* plexSettings.Servers.FirstOrDefault()?.ServerHostname ?? */ string.Empty);
|
await ProcessTv(mediaServerContent, ombiSettings.DefaultLanguageCode, /* plexSettings.Servers.FirstOrDefault()?.ServerHostname ?? */ string.Empty);
|
||||||
}
|
}
|
||||||
sb.Append("</tr>");
|
sb.Append("</tr>");
|
||||||
sb.Append("</table>");
|
sb.Append("</table>");
|
||||||
|
@ -541,7 +522,7 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
sb.Append("<td style=\"font-family: 'Open Sans', Helvetica, Arial, sans-serif; font-size: 14px; vertical-align: top; \">");
|
sb.Append("<td style=\"font-family: 'Open Sans', Helvetica, Arial, sans-serif; font-size: 14px; vertical-align: top; \">");
|
||||||
sb.Append("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" style=\"border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%; \">");
|
sb.Append("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" style=\"border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%; \">");
|
||||||
sb.Append("<tr>");
|
sb.Append("<tr>");
|
||||||
await ProcessAlbums(albums, sb);
|
await ProcessAlbums(albums);
|
||||||
sb.Append("</tr>");
|
sb.Append("</tr>");
|
||||||
sb.Append("</table>");
|
sb.Append("</table>");
|
||||||
sb.Append("</td>");
|
sb.Append("</td>");
|
||||||
|
@ -552,7 +533,7 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task ProcessMovies(IQueryable<IMediaServerContent> plexContentToSend, StringBuilder sb, string defaultLanguageCode, string mediaServerUrl)
|
private async Task ProcessMovies(IQueryable<IMediaServerContent> plexContentToSend, string defaultLanguageCode, string mediaServerUrl)
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
var ordered = plexContentToSend.OrderByDescending(x => x.AddedAt);
|
var ordered = plexContentToSend.OrderByDescending(x => x.AddedAt);
|
||||||
|
@ -571,7 +552,7 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CreateMovieHtmlContent(sb, info, mediaurl);
|
CreateMovieHtmlContent(info, mediaurl);
|
||||||
count += 1;
|
count += 1;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
@ -580,7 +561,7 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
EndLoopHtml(sb);
|
EndLoopHtml();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count == 2)
|
if (count == 2)
|
||||||
|
@ -591,7 +572,7 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private async Task ProcessAlbums(HashSet<LidarrAlbumCache> albumsToSend, StringBuilder sb)
|
private async Task ProcessAlbums(HashSet<LidarrAlbumCache> albumsToSend)
|
||||||
{
|
{
|
||||||
var settings = await _lidarrSettings.GetSettingsAsync();
|
var settings = await _lidarrSettings.GetSettingsAsync();
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
@ -605,7 +586,7 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CreateAlbumHtmlContent(sb, info);
|
CreateAlbumHtmlContent(info);
|
||||||
count += 1;
|
count += 1;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
@ -614,7 +595,7 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
EndLoopHtml(sb);
|
EndLoopHtml();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count == 2)
|
if (count == 2)
|
||||||
|
@ -626,13 +607,13 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CreateMovieHtmlContent(StringBuilder sb, MovieResponseDto info, string mediaurl)
|
private void CreateMovieHtmlContent(MovieResponseDto info, string mediaurl)
|
||||||
{
|
{
|
||||||
AddBackgroundInsideTable(sb, $"https://image.tmdb.org/t/p/w1280/{info.BackdropPath}");
|
AddBackgroundInsideTable($"https://image.tmdb.org/t/p/w1280/{info.BackdropPath}");
|
||||||
AddPosterInsideTable(sb, $"https://image.tmdb.org/t/p/original{info.PosterPath}");
|
AddPosterInsideTable($"https://image.tmdb.org/t/p/original{info.PosterPath}");
|
||||||
|
|
||||||
AddMediaServerUrl(sb, mediaurl, $"https://image.tmdb.org/t/p/original{info.PosterPath}");
|
AddMediaServerUrl(mediaurl, $"https://image.tmdb.org/t/p/original{info.PosterPath}");
|
||||||
AddInfoTable(sb);
|
AddInfoTable();
|
||||||
|
|
||||||
var releaseDate = string.Empty;
|
var releaseDate = string.Empty;
|
||||||
try
|
try
|
||||||
|
@ -646,7 +627,7 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
// Swallow, couldn't parse the date
|
// Swallow, couldn't parse the date
|
||||||
}
|
}
|
||||||
|
|
||||||
AddTitle(sb, $"https://www.imdb.com/title/{info.ImdbId}/", $"{info.Title} {releaseDate}");
|
AddTitle($"https://www.imdb.com/title/{info.ImdbId}/", $"{info.Title} {releaseDate}");
|
||||||
|
|
||||||
var summary = info.Overview;
|
var summary = info.Overview;
|
||||||
if (summary.Length > 280)
|
if (summary.Length > 280)
|
||||||
|
@ -654,16 +635,15 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
summary = summary.Remove(280);
|
summary = summary.Remove(280);
|
||||||
summary = summary + "...</p>";
|
summary = summary + "...</p>";
|
||||||
}
|
}
|
||||||
AddParagraph(sb, summary);
|
AddParagraph(summary);
|
||||||
|
|
||||||
if (info.Genres.Any())
|
if (info.Genres.Any())
|
||||||
{
|
{
|
||||||
AddGenres(sb,
|
AddGenres($"Genres: {string.Join(", ", info.Genres.Select(x => x.Name.ToString()).ToArray())}");
|
||||||
$"Genres: {string.Join(", ", info.Genres.Select(x => x.Name.ToString()).ToArray())}");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CreateAlbumHtmlContent(StringBuilder sb, AlbumLookup info)
|
private void CreateAlbumHtmlContent(AlbumLookup info)
|
||||||
{
|
{
|
||||||
var cover = info.images
|
var cover = info.images
|
||||||
.FirstOrDefault(x => x.coverType.Equals("cover", StringComparison.InvariantCultureIgnoreCase))?.url;
|
.FirstOrDefault(x => x.coverType.Equals("cover", StringComparison.InvariantCultureIgnoreCase))?.url;
|
||||||
|
@ -671,21 +651,21 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
{
|
{
|
||||||
cover = info.remoteCover;
|
cover = info.remoteCover;
|
||||||
}
|
}
|
||||||
AddBackgroundInsideTable(sb, cover);
|
AddBackgroundInsideTable(cover);
|
||||||
var disk = info.images
|
var disk = info.images
|
||||||
.FirstOrDefault(x => x.coverType.Equals("disc", StringComparison.InvariantCultureIgnoreCase))?.url;
|
.FirstOrDefault(x => x.coverType.Equals("disc", StringComparison.InvariantCultureIgnoreCase))?.url;
|
||||||
if (disk.IsNullOrEmpty())
|
if (disk.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
disk = info.remoteCover;
|
disk = info.remoteCover;
|
||||||
}
|
}
|
||||||
AddPosterInsideTable(sb, disk);
|
AddPosterInsideTable(disk);
|
||||||
|
|
||||||
AddMediaServerUrl(sb, string.Empty, string.Empty);
|
AddMediaServerUrl(string.Empty, string.Empty);
|
||||||
AddInfoTable(sb);
|
AddInfoTable();
|
||||||
|
|
||||||
var releaseDate = $"({info.releaseDate.Year})";
|
var releaseDate = $"({info.releaseDate.Year})";
|
||||||
|
|
||||||
AddTitle(sb, string.Empty, $"{info.title} {releaseDate}");
|
AddTitle(string.Empty, $"{info.title} {releaseDate}");
|
||||||
|
|
||||||
var summary = info.artist?.artistName ?? string.Empty;
|
var summary = info.artist?.artistName ?? string.Empty;
|
||||||
if (summary.Length > 280)
|
if (summary.Length > 280)
|
||||||
|
@ -693,12 +673,12 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
summary = summary.Remove(280);
|
summary = summary.Remove(280);
|
||||||
summary = summary + "...</p>";
|
summary = summary + "...</p>";
|
||||||
}
|
}
|
||||||
AddParagraph(sb, summary);
|
AddParagraph(summary);
|
||||||
|
|
||||||
AddGenres(sb, $"Type: {info.albumType}");
|
AddGenres($"Type: {info.albumType}");
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task ProcessTv(IEnumerable<IMediaServerEpisode> episodes, StringBuilder sb, string languageCode, string serverHostname)
|
private async Task ProcessTv(IEnumerable<IMediaServerEpisode> episodes, string languageCode, string serverHostname)
|
||||||
{
|
{
|
||||||
var series = new List<IMediaServerContent>();
|
var series = new List<IMediaServerContent>();
|
||||||
foreach (var episode in episodes)
|
foreach (var episode in episodes)
|
||||||
|
@ -768,17 +748,17 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
if (tvInfo != null && tvInfo.backdrop_path.HasValue())
|
if (tvInfo != null && tvInfo.backdrop_path.HasValue())
|
||||||
{
|
{
|
||||||
|
|
||||||
AddBackgroundInsideTable(sb, $"https://image.tmdb.org/t/p/w500{tvInfo.backdrop_path}");
|
AddBackgroundInsideTable($"https://image.tmdb.org/t/p/w500{tvInfo.backdrop_path}");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AddBackgroundInsideTable(sb, $"https://image.tmdb.org/t/p/w1280/");
|
AddBackgroundInsideTable($"https://image.tmdb.org/t/p/w1280/");
|
||||||
}
|
}
|
||||||
AddPosterInsideTable(sb, banner);
|
AddPosterInsideTable(banner);
|
||||||
AddMediaServerUrl(sb, PlexHelper.BuildPlexMediaUrl(t.Url, serverHostname), banner);
|
AddMediaServerUrl(PlexHelper.BuildPlexMediaUrl(t.Url, serverHostname), banner);
|
||||||
AddInfoTable(sb);
|
AddInfoTable();
|
||||||
|
|
||||||
AddTvTitle(sb, info, tvInfo);
|
AddTvTitle(info, tvInfo);
|
||||||
|
|
||||||
// Group by the season number
|
// Group by the season number
|
||||||
var results = t.Episodes.GroupBy(p => p.SeasonNumber,
|
var results = t.Episodes.GroupBy(p => p.SeasonNumber,
|
||||||
|
@ -801,7 +781,7 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
finalsb.Append("<br />");
|
finalsb.Append("<br />");
|
||||||
}
|
}
|
||||||
|
|
||||||
AddTvEpisodesSummaryGenres(sb, finalsb.ToString(), tvInfo);
|
AddTvEpisodesSummaryGenres(finalsb.ToString(), tvInfo);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
@ -810,7 +790,7 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
EndLoopHtml(sb);
|
EndLoopHtml();
|
||||||
count += 1;
|
count += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -823,7 +803,7 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddTvTitle(StringBuilder sb, Api.TvMaze.Models.TvMazeShow info, TvInfo tvInfo)
|
private void AddTvTitle(Api.TvMaze.Models.TvMazeShow info, TvInfo tvInfo)
|
||||||
{
|
{
|
||||||
var title = "";
|
var title = "";
|
||||||
if (!String.IsNullOrEmpty(info.premiered) && info.premiered.Length > 4)
|
if (!String.IsNullOrEmpty(info.premiered) && info.premiered.Length > 4)
|
||||||
|
@ -834,10 +814,10 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
{
|
{
|
||||||
title = $"{tvInfo.name}";
|
title = $"{tvInfo.name}";
|
||||||
}
|
}
|
||||||
AddTitle(sb, $"https://www.imdb.com/title/{info.externals.imdb}/", title);
|
AddTitle($"https://www.imdb.com/title/{info.externals.imdb}/", title);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddTvEpisodesSummaryGenres(StringBuilder sb, string episodes, TvInfo tvInfo)
|
private void AddTvEpisodesSummaryGenres(string episodes, TvInfo tvInfo)
|
||||||
{
|
{
|
||||||
var summary = tvInfo.overview;
|
var summary = tvInfo.overview;
|
||||||
if (summary.Length > 280)
|
if (summary.Length > 280)
|
||||||
|
@ -845,15 +825,15 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
summary = summary.Remove(280);
|
summary = summary.Remove(280);
|
||||||
summary = summary + "...</p>";
|
summary = summary + "...</p>";
|
||||||
}
|
}
|
||||||
AddTvParagraph(sb, episodes, summary);
|
AddTvParagraph(episodes, summary);
|
||||||
|
|
||||||
if (tvInfo.genres.Any())
|
if (tvInfo.genres.Any())
|
||||||
{
|
{
|
||||||
AddGenres(sb, $"Genres: {string.Join(", ", tvInfo.genres.Select(x => x.name.ToString()).ToArray())}");
|
AddGenres($"Genres: {string.Join(", ", tvInfo.genres.Select(x => x.name.ToString()).ToArray())}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void EndLoopHtml(StringBuilder sb)
|
private void EndLoopHtml()
|
||||||
{
|
{
|
||||||
//NOTE: BR have to be in TD's as per html spec or it will be put outside of the table...
|
//NOTE: BR have to be in TD's as per html spec or it will be put outside of the table...
|
||||||
//Source: http://stackoverflow.com/questions/6588638/phantom-br-tag-rendered-by-browsers-prior-to-table-tag
|
//Source: http://stackoverflow.com/questions/6588638/phantom-br-tag-rendered-by-browsers-prior-to-table-tag
|
||||||
|
|
|
@ -353,7 +353,8 @@ namespace Ombi.Schedule.Jobs.Plex
|
||||||
Title = movie.title,
|
Title = movie.title,
|
||||||
Url = PlexHelper.GetPlexMediaUrl(servers.MachineIdentifier, movie.ratingKey),
|
Url = PlexHelper.GetPlexMediaUrl(servers.MachineIdentifier, movie.ratingKey),
|
||||||
Seasons = new List<PlexSeasonsContent>(),
|
Seasons = new List<PlexSeasonsContent>(),
|
||||||
Quality = movie.Media?.FirstOrDefault()?.videoResolution ?? string.Empty
|
Quality = movie.Media?.FirstOrDefault()?.videoResolution ?? string.Empty,
|
||||||
|
Repository = Repo
|
||||||
};
|
};
|
||||||
if (providerIds.ImdbId.HasValue())
|
if (providerIds.ImdbId.HasValue())
|
||||||
{
|
{
|
||||||
|
@ -556,7 +557,8 @@ namespace Ombi.Schedule.Jobs.Plex
|
||||||
Type = MediaType.Series,
|
Type = MediaType.Series,
|
||||||
Title = show.title,
|
Title = show.title,
|
||||||
Url = PlexHelper.GetPlexMediaUrl(servers.MachineIdentifier, show.ratingKey),
|
Url = PlexHelper.GetPlexMediaUrl(servers.MachineIdentifier, show.ratingKey),
|
||||||
Seasons = new List<PlexSeasonsContent>()
|
Seasons = new List<PlexSeasonsContent>(),
|
||||||
|
Repository = Repo
|
||||||
};
|
};
|
||||||
await GetProviderIds(showMetadata, item);
|
await GetProviderIds(showMetadata, item);
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace Ombi.Store.Entities
|
namespace Ombi.Store.Entities
|
||||||
{
|
{
|
||||||
public abstract class Entity
|
public abstract class Entity: IEntity
|
||||||
{
|
{
|
||||||
[Key]
|
[Key]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
10
src/Ombi.Store/Entities/IEntity.cs
Normal file
10
src/Ombi.Store/Entities/IEntity.cs
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace Ombi.Store.Entities
|
||||||
|
{
|
||||||
|
public interface IEntity
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public int Id { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,14 +5,14 @@ using Ombi.Store.Repository;
|
||||||
|
|
||||||
namespace Ombi.Store.Entities
|
namespace Ombi.Store.Entities
|
||||||
{
|
{
|
||||||
public interface IMediaServerContent
|
public interface IMediaServerContent: IEntity
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
|
||||||
public string Title { get; set; }
|
public string Title { get; set; }
|
||||||
public string ImdbId { get; set; }
|
public string ImdbId { get; set; }
|
||||||
public string TvDbId { get; set; }
|
public string TvDbId { get; set; }
|
||||||
public string TheMovieDbId { get; set; }
|
public string TheMovieDbId { get; set; }
|
||||||
public MediaType Type { get; set; }
|
public MediaType Type { get; set; }
|
||||||
|
public IMediaServerContentRepositoryLight Repository { get; }
|
||||||
|
|
||||||
public string Url { get; set; }
|
public string Url { get; set; }
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using Ombi.Store.Repository;
|
||||||
|
|
||||||
namespace Ombi.Store.Entities
|
namespace Ombi.Store.Entities
|
||||||
{
|
{
|
||||||
|
@ -26,6 +27,9 @@ namespace Ombi.Store.Entities
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public bool HasTheMovieDb => !string.IsNullOrEmpty(TheMovieDbId);
|
public bool HasTheMovieDb => !string.IsNullOrEmpty(TheMovieDbId);
|
||||||
|
|
||||||
|
[NotMapped] //TODO: instantiate this variable upon read // something in ExternalContext.cs?
|
||||||
|
public IMediaServerContentRepositoryLight Repository { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract class MediaServerEpisode: Entity, IMediaServerEpisode
|
public abstract class MediaServerEpisode: Entity, IMediaServerEpisode
|
||||||
|
|
|
@ -35,17 +35,13 @@ using Ombi.Store.Entities;
|
||||||
|
|
||||||
namespace Ombi.Store.Repository
|
namespace Ombi.Store.Repository
|
||||||
{
|
{
|
||||||
public class EmbyContentRepository : ExternalRepository<EmbyContent>, IEmbyContentRepository
|
public class EmbyContentRepository : MediaServerContentRepository<EmbyContent>, IEmbyContentRepository
|
||||||
{
|
{
|
||||||
|
|
||||||
public EmbyContentRepository(ExternalContext db):base(db)
|
public EmbyContentRepository(ExternalContext db):base(db)
|
||||||
{
|
{
|
||||||
Db = db;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ExternalContext Db { get; }
|
|
||||||
|
|
||||||
|
|
||||||
public async Task<EmbyContent> GetByImdbId(string imdbid)
|
public async Task<EmbyContent> GetByImdbId(string imdbid)
|
||||||
{
|
{
|
||||||
return await Db.EmbyContent.FirstOrDefaultAsync(x => x.ImdbId == imdbid);
|
return await Db.EmbyContent.FirstOrDefaultAsync(x => x.ImdbId == imdbid);
|
||||||
|
@ -69,18 +65,18 @@ namespace Ombi.Store.Repository
|
||||||
return await Db.EmbyContent./*Include(x => x.Seasons).*/FirstOrDefaultAsync(x => x.EmbyId == embyId);
|
return await Db.EmbyContent./*Include(x => x.Seasons).*/FirstOrDefaultAsync(x => x.EmbyId == embyId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Update(IMediaServerContent existingContent)
|
public override async Task Update(IMediaServerContent existingContent)
|
||||||
{
|
{
|
||||||
Db.EmbyContent.Update((EmbyContent)existingContent);
|
Db.EmbyContent.Update((EmbyContent)existingContent);
|
||||||
await InternalSaveChanges();
|
await InternalSaveChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IQueryable<IMediaServerEpisode> GetAllEpisodes()
|
public override IQueryable<IMediaServerEpisode> GetAllEpisodes()
|
||||||
{
|
{
|
||||||
return Db.EmbyEpisode.AsQueryable();
|
return Db.EmbyEpisode.AsQueryable();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IMediaServerEpisode> Add(IMediaServerEpisode content)
|
public override async Task<IMediaServerEpisode> Add(IMediaServerEpisode content)
|
||||||
{
|
{
|
||||||
await Db.EmbyEpisode.AddAsync((EmbyEpisode)content);
|
await Db.EmbyEpisode.AddAsync((EmbyEpisode)content);
|
||||||
await InternalSaveChanges();
|
await InternalSaveChanges();
|
||||||
|
@ -91,16 +87,17 @@ namespace Ombi.Store.Repository
|
||||||
return await Db.EmbyEpisode.FirstOrDefaultAsync(x => x.EmbyId == key);
|
return await Db.EmbyEpisode.FirstOrDefaultAsync(x => x.EmbyId == key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task AddRange(IEnumerable<IMediaServerEpisode> content)
|
public override async Task AddRange(IEnumerable<IMediaServerEpisode> content)
|
||||||
{
|
{
|
||||||
Db.EmbyEpisode.AddRange((EmbyEpisode)content);
|
Db.EmbyEpisode.AddRange((EmbyEpisode)content);
|
||||||
await InternalSaveChanges();
|
await InternalSaveChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateWithoutSave(IMediaServerContent existingContent)
|
public override void UpdateWithoutSave(IMediaServerContent existingContent)
|
||||||
{
|
{
|
||||||
Db.EmbyContent.Update((EmbyContent)existingContent);
|
Db.EmbyContent.Update((EmbyContent)existingContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override RecentlyAddedType RecentlyAddedType => RecentlyAddedType.Emby;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,7 +6,7 @@ using Ombi.Store.Entities;
|
||||||
|
|
||||||
namespace Ombi.Store.Repository
|
namespace Ombi.Store.Repository
|
||||||
{
|
{
|
||||||
public interface IEmbyContentRepository : IMediaServerContentRepository<EmbyContent, EmbyEpisode>
|
public interface IEmbyContentRepository : IMediaServerContentRepository<EmbyContent>
|
||||||
{
|
{
|
||||||
Task<EmbyContent> GetByEmbyId(string embyId);
|
Task<EmbyContent> GetByEmbyId(string embyId);
|
||||||
Task<EmbyEpisode> GetEpisodeByEmbyId(string key);
|
Task<EmbyEpisode> GetEpisodeByEmbyId(string key);
|
||||||
|
|
|
@ -9,7 +9,7 @@ using Ombi.Store.Entities;
|
||||||
|
|
||||||
namespace Ombi.Store.Repository
|
namespace Ombi.Store.Repository
|
||||||
{
|
{
|
||||||
public interface IExternalRepository<T> where T : Entity
|
public interface IExternalRepository<T> where T : IEntity
|
||||||
{
|
{
|
||||||
Task<T> Find(object key);
|
Task<T> Find(object key);
|
||||||
IQueryable<T> GetAll();
|
IQueryable<T> GetAll();
|
||||||
|
@ -25,6 +25,5 @@ namespace Ombi.Store.Repository
|
||||||
where TEntity : class;
|
where TEntity : class;
|
||||||
|
|
||||||
Task ExecuteSql(string sql);
|
Task ExecuteSql(string sql);
|
||||||
DbSet<T> _db { get; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,7 +6,7 @@ using Ombi.Store.Entities;
|
||||||
|
|
||||||
namespace Ombi.Store.Repository
|
namespace Ombi.Store.Repository
|
||||||
{
|
{
|
||||||
public interface IJellyfinContentRepository : IMediaServerContentRepository<JellyfinContent, JellyfinEpisode>
|
public interface IJellyfinContentRepository : IMediaServerContentRepository<JellyfinContent>
|
||||||
{
|
{
|
||||||
Task<JellyfinContent> GetByJellyfinId(string jellyfinId);
|
Task<JellyfinContent> GetByJellyfinId(string jellyfinId);
|
||||||
Task<JellyfinEpisode> GetEpisodeByJellyfinId(string key);
|
Task<JellyfinEpisode> GetEpisodeByJellyfinId(string key);
|
||||||
|
|
|
@ -5,8 +5,8 @@ using Ombi.Store.Entities;
|
||||||
|
|
||||||
namespace Ombi.Store.Repository
|
namespace Ombi.Store.Repository
|
||||||
{
|
{
|
||||||
public interface IMediaServerContentRepository<Content, Episode> : IExternalRepository<Content>, IMediaServerContentRepositoryLight
|
public interface IMediaServerContentRepository<Content> : IExternalRepository<Content>, IMediaServerContentRepositoryLight
|
||||||
where Content : Entity
|
where Content : IMediaServerContent
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -5,9 +5,23 @@ using Ombi.Store.Entities;
|
||||||
|
|
||||||
namespace Ombi.Store.Repository
|
namespace Ombi.Store.Repository
|
||||||
{
|
{
|
||||||
|
// TOOD: this is a mess done to bypass the fact that
|
||||||
|
// I can't pass around IMediaServerContentRepository as a parameter
|
||||||
|
// because I want to pass it a generic IMediaServerContent as a 'type'
|
||||||
|
// and casting from concrete classes doesn't work due to my poor C# knowledge
|
||||||
|
|
||||||
|
// My workaround so far has been to use this lightened interface,
|
||||||
|
// but the ever-growing number of wrapper methods for methods coming from IRepository<T>
|
||||||
|
// is starting to smell (see implementing class MediaServerContentRepository).
|
||||||
public interface IMediaServerContentRepositoryLight
|
public interface IMediaServerContentRepositoryLight
|
||||||
{
|
{
|
||||||
|
RecentlyAddedType RecentlyAddedType{ get; }
|
||||||
Task Update(IMediaServerContent existingContent);
|
Task Update(IMediaServerContent existingContent);
|
||||||
|
|
||||||
|
// IQueryable<IMediaServerContent> GetAllContent();
|
||||||
|
// Task<IMediaServerContent> FindContent(object key);
|
||||||
|
// Task<int> SaveChangesAsync();
|
||||||
|
|
||||||
IQueryable<IMediaServerEpisode> GetAllEpisodes();
|
IQueryable<IMediaServerEpisode> GetAllEpisodes();
|
||||||
Task<IMediaServerEpisode> Add(IMediaServerEpisode content);
|
Task<IMediaServerEpisode> Add(IMediaServerEpisode content);
|
||||||
Task AddRange(IEnumerable<IMediaServerEpisode> content);
|
Task AddRange(IEnumerable<IMediaServerEpisode> content);
|
||||||
|
|
|
@ -8,7 +8,7 @@ using Ombi.Store.Entities;
|
||||||
|
|
||||||
namespace Ombi.Store.Repository
|
namespace Ombi.Store.Repository
|
||||||
{
|
{
|
||||||
public interface IPlexContentRepository : IMediaServerContentRepository<PlexServerContent, PlexEpisode>
|
public interface IPlexContentRepository : IMediaServerContentRepository<PlexServerContent>
|
||||||
{
|
{
|
||||||
Task<bool> ContentExists(string providerId);
|
Task<bool> ContentExists(string providerId);
|
||||||
Task<PlexServerContent> Get(string providerId, ProviderType type);
|
Task<PlexServerContent> Get(string providerId, ProviderType type);
|
||||||
|
|
|
@ -10,7 +10,7 @@ using Ombi.Store.Entities;
|
||||||
|
|
||||||
namespace Ombi.Store.Repository
|
namespace Ombi.Store.Repository
|
||||||
{
|
{
|
||||||
public interface IRepository<T> where T : Entity
|
public interface IRepository<T> where T : IEntity
|
||||||
{
|
{
|
||||||
Task<T> Find(object key);
|
Task<T> Find(object key);
|
||||||
Task<T> Find(object key, CancellationToken cancellationToken);
|
Task<T> Find(object key, CancellationToken cancellationToken);
|
||||||
|
@ -27,6 +27,5 @@ namespace Ombi.Store.Repository
|
||||||
where TEntity : class;
|
where TEntity : class;
|
||||||
|
|
||||||
Task ExecuteSql(string sql);
|
Task ExecuteSql(string sql);
|
||||||
DbSet<T> _db { get; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -35,17 +35,13 @@ using Ombi.Store.Entities;
|
||||||
|
|
||||||
namespace Ombi.Store.Repository
|
namespace Ombi.Store.Repository
|
||||||
{
|
{
|
||||||
public class JellyfinContentRepository : ExternalRepository<JellyfinContent>, IJellyfinContentRepository
|
public class JellyfinContentRepository : MediaServerContentRepository<JellyfinContent>, IJellyfinContentRepository
|
||||||
{
|
{
|
||||||
|
|
||||||
public JellyfinContentRepository(ExternalContext db):base(db)
|
public JellyfinContentRepository(ExternalContext db):base(db)
|
||||||
{
|
{
|
||||||
Db = db;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ExternalContext Db { get; }
|
|
||||||
|
|
||||||
|
|
||||||
public async Task<JellyfinContent> GetByImdbId(string imdbid)
|
public async Task<JellyfinContent> GetByImdbId(string imdbid)
|
||||||
{
|
{
|
||||||
return await Db.JellyfinContent.FirstOrDefaultAsync(x => x.ImdbId == imdbid);
|
return await Db.JellyfinContent.FirstOrDefaultAsync(x => x.ImdbId == imdbid);
|
||||||
|
@ -69,18 +65,18 @@ namespace Ombi.Store.Repository
|
||||||
return await Db.JellyfinContent./*Include(x => x.Seasons).*/FirstOrDefaultAsync(x => x.JellyfinId == jellyfinId);
|
return await Db.JellyfinContent./*Include(x => x.Seasons).*/FirstOrDefaultAsync(x => x.JellyfinId == jellyfinId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Update(IMediaServerContent existingContent)
|
public override async Task Update(IMediaServerContent existingContent)
|
||||||
{
|
{
|
||||||
Db.JellyfinContent.Update((JellyfinContent)existingContent);
|
Db.JellyfinContent.Update((JellyfinContent)existingContent);
|
||||||
await InternalSaveChanges();
|
await InternalSaveChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IQueryable<IMediaServerEpisode> GetAllEpisodes()
|
public override IQueryable<IMediaServerEpisode> GetAllEpisodes()
|
||||||
{
|
{
|
||||||
return Db.JellyfinEpisode.AsQueryable();
|
return Db.JellyfinEpisode.AsQueryable();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IMediaServerEpisode> Add(IMediaServerEpisode content)
|
public override async Task<IMediaServerEpisode> Add(IMediaServerEpisode content)
|
||||||
{
|
{
|
||||||
await Db.JellyfinEpisode.AddAsync((JellyfinEpisode)content);
|
await Db.JellyfinEpisode.AddAsync((JellyfinEpisode)content);
|
||||||
await InternalSaveChanges();
|
await InternalSaveChanges();
|
||||||
|
@ -91,16 +87,17 @@ namespace Ombi.Store.Repository
|
||||||
return await Db.JellyfinEpisode.FirstOrDefaultAsync(x => x.JellyfinId == key);
|
return await Db.JellyfinEpisode.FirstOrDefaultAsync(x => x.JellyfinId == key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task AddRange(IEnumerable<IMediaServerEpisode> content)
|
public override async Task AddRange(IEnumerable<IMediaServerEpisode> content)
|
||||||
{
|
{
|
||||||
Db.JellyfinEpisode.AddRange((JellyfinEpisode)content);
|
Db.JellyfinEpisode.AddRange((JellyfinEpisode)content);
|
||||||
await InternalSaveChanges();
|
await InternalSaveChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateWithoutSave(IMediaServerContent existingContent)
|
public override void UpdateWithoutSave(IMediaServerContent existingContent)
|
||||||
{
|
{
|
||||||
Db.JellyfinContent.Update((JellyfinContent)existingContent);
|
Db.JellyfinContent.Update((JellyfinContent)existingContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override RecentlyAddedType RecentlyAddedType => RecentlyAddedType.Jellyfin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
30
src/Ombi.Store/Repository/MediaServerRepository.cs
Normal file
30
src/Ombi.Store/Repository/MediaServerRepository.cs
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Ombi.Store.Context;
|
||||||
|
using Ombi.Store.Entities;
|
||||||
|
|
||||||
|
namespace Ombi.Store.Repository
|
||||||
|
{
|
||||||
|
public abstract class MediaServerContentRepository<T> : ExternalRepository<T>, IMediaServerContentRepository<T> where T : MediaServerContent
|
||||||
|
{
|
||||||
|
protected ExternalContext Db { get; }
|
||||||
|
public abstract RecentlyAddedType RecentlyAddedType { get; }
|
||||||
|
|
||||||
|
public MediaServerContentRepository(ExternalContext db) : base(db)
|
||||||
|
{
|
||||||
|
Db = db;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract Task Update(IMediaServerContent existingContent);
|
||||||
|
|
||||||
|
// TOOD: this smells: trying to wrap ExternalRepository methods in IMediaServerContentRepositoryLight for generic consumption
|
||||||
|
public IQueryable<IMediaServerContent> GetAllContent() => (IQueryable<IMediaServerContent>)GetAll();
|
||||||
|
public async Task<IMediaServerContent> FindContent(object key) => (IMediaServerContent)await Find(key);
|
||||||
|
|
||||||
|
public abstract IQueryable<IMediaServerEpisode> GetAllEpisodes();
|
||||||
|
public abstract Task<IMediaServerEpisode> Add(IMediaServerEpisode content);
|
||||||
|
public abstract Task AddRange(IEnumerable<IMediaServerEpisode> content);
|
||||||
|
public abstract void UpdateWithoutSave(IMediaServerContent existingContent);
|
||||||
|
}
|
||||||
|
}
|
|
@ -37,17 +37,13 @@ using Ombi.Store.Entities;
|
||||||
|
|
||||||
namespace Ombi.Store.Repository
|
namespace Ombi.Store.Repository
|
||||||
{
|
{
|
||||||
public class PlexServerContentRepository : ExternalRepository<PlexServerContent>, IPlexContentRepository
|
public class PlexServerContentRepository : MediaServerContentRepository<PlexServerContent>, IPlexContentRepository
|
||||||
{
|
{
|
||||||
|
public override RecentlyAddedType RecentlyAddedType => RecentlyAddedType.Plex;
|
||||||
public PlexServerContentRepository(ExternalContext db) : base(db)
|
public PlexServerContentRepository(ExternalContext db) : base(db)
|
||||||
{
|
{
|
||||||
Db = db;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ExternalContext Db { get; }
|
|
||||||
|
|
||||||
|
|
||||||
public async Task<bool> ContentExists(string providerId)
|
public async Task<bool> ContentExists(string providerId)
|
||||||
{
|
{
|
||||||
var any = await Db.PlexServerContent.AnyAsync(x => x.ImdbId == providerId);
|
var any = await Db.PlexServerContent.AnyAsync(x => x.ImdbId == providerId);
|
||||||
|
@ -114,12 +110,12 @@ namespace Ombi.Store.Repository
|
||||||
.FirstOrDefaultAsync(predicate);
|
.FirstOrDefaultAsync(predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Update(IMediaServerContent existingContent)
|
public override async Task Update(IMediaServerContent existingContent)
|
||||||
{
|
{
|
||||||
Db.PlexServerContent.Update((PlexServerContent)existingContent);
|
Db.PlexServerContent.Update((PlexServerContent)existingContent);
|
||||||
await InternalSaveChanges();
|
await InternalSaveChanges();
|
||||||
}
|
}
|
||||||
public void UpdateWithoutSave(IMediaServerContent existingContent)
|
public override void UpdateWithoutSave(IMediaServerContent existingContent)
|
||||||
{
|
{
|
||||||
Db.PlexServerContent.Update((PlexServerContent)existingContent);
|
Db.PlexServerContent.Update((PlexServerContent)existingContent);
|
||||||
}
|
}
|
||||||
|
@ -130,7 +126,7 @@ namespace Ombi.Store.Repository
|
||||||
await InternalSaveChanges();
|
await InternalSaveChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IQueryable<IMediaServerEpisode> GetAllEpisodes()
|
public override IQueryable<IMediaServerEpisode> GetAllEpisodes()
|
||||||
{
|
{
|
||||||
return Db.PlexEpisode.Include(x => x.Series).AsQueryable();
|
return Db.PlexEpisode.Include(x => x.Series).AsQueryable();
|
||||||
}
|
}
|
||||||
|
@ -145,7 +141,7 @@ namespace Ombi.Store.Repository
|
||||||
Db.PlexEpisode.Remove(content);
|
Db.PlexEpisode.Remove(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IMediaServerEpisode> Add(IMediaServerEpisode content)
|
public override async Task<IMediaServerEpisode> Add(IMediaServerEpisode content)
|
||||||
{
|
{
|
||||||
await Db.PlexEpisode.AddAsync((PlexEpisode)content);
|
await Db.PlexEpisode.AddAsync((PlexEpisode)content);
|
||||||
await InternalSaveChanges();
|
await InternalSaveChanges();
|
||||||
|
@ -162,10 +158,11 @@ namespace Ombi.Store.Repository
|
||||||
{
|
{
|
||||||
return await Db.PlexEpisode.FirstOrDefaultAsync(x => x.Key == key);
|
return await Db.PlexEpisode.FirstOrDefaultAsync(x => x.Key == key);
|
||||||
}
|
}
|
||||||
public async Task AddRange(IEnumerable<IMediaServerEpisode> content)
|
public override async Task AddRange(IEnumerable<IMediaServerEpisode> content)
|
||||||
{
|
{
|
||||||
Db.PlexEpisode.AddRange((PlexEpisode)content);
|
Db.PlexEpisode.AddRange((PlexEpisode)content);
|
||||||
await InternalSaveChanges();
|
await InternalSaveChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue