|
|
|
@ -60,6 +60,7 @@ namespace Ombi.Schedule.Jobs.Ombi
|
|
|
|
|
private readonly ISettingsService<NewsletterSettings> _newsletterSettings;
|
|
|
|
|
private readonly UserManager<OmbiUser> _userManager;
|
|
|
|
|
private readonly ILogger _log;
|
|
|
|
|
private string overlay;
|
|
|
|
|
|
|
|
|
|
public async Task Start(NewsletterSettings settings, bool test)
|
|
|
|
|
{
|
|
|
|
@ -306,16 +307,38 @@ namespace Ombi.Schedule.Jobs.Ombi
|
|
|
|
|
var embyMovies = embyContentToSend.Where(x => x.Type == EmbyMediaType.Movie);
|
|
|
|
|
if ((plexMovies.Any() || embyMovies.Any()) && !settings.DisableMovies)
|
|
|
|
|
{
|
|
|
|
|
sb.Append("<h1>New Movies:</h1><br /><br />");
|
|
|
|
|
sb.Append("<h1 style=\"text-align: center;\">New Movies</h1><br /><br />");
|
|
|
|
|
sb.Append(
|
|
|
|
|
"<table class=\"movies-table\" style=\"border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100 %; \">");
|
|
|
|
|
sb.Append("<tr>");
|
|
|
|
|
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("<tr>");
|
|
|
|
|
await ProcessPlexMovies(plexMovies, sb);
|
|
|
|
|
await ProcessEmbyMovies(embyMovies, sb);
|
|
|
|
|
sb.Append("</tr>");
|
|
|
|
|
sb.Append("</table>");
|
|
|
|
|
sb.Append("</td>");
|
|
|
|
|
sb.Append("</tr>");
|
|
|
|
|
sb.Append("</table>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((plexEpisodes.Any() || embyEp.Any()) && !settings.DisableTv)
|
|
|
|
|
{
|
|
|
|
|
sb.Append("<h1>New Episodes:</h1><br /><br />");
|
|
|
|
|
sb.Append("<br /><br /><h1 style=\"text-align: center;\">New TV</h1><br /><br />");
|
|
|
|
|
sb.Append(
|
|
|
|
|
"<table class=\"tv-table\" style=\"border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100 %; \">");
|
|
|
|
|
sb.Append("<tr>");
|
|
|
|
|
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("<tr>");
|
|
|
|
|
await ProcessPlexTv(plexEpisodes, sb);
|
|
|
|
|
await ProcessEmbyTv(embyEp, sb);
|
|
|
|
|
sb.Append("</tr>");
|
|
|
|
|
sb.Append("</table>");
|
|
|
|
|
sb.Append("</td>");
|
|
|
|
|
sb.Append("</tr>");
|
|
|
|
|
sb.Append("</table>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return sb.ToString();
|
|
|
|
@ -323,8 +346,8 @@ namespace Ombi.Schedule.Jobs.Ombi
|
|
|
|
|
|
|
|
|
|
private async Task ProcessPlexMovies(IQueryable<PlexServerContent> plexContentToSend, StringBuilder sb)
|
|
|
|
|
{
|
|
|
|
|
sb.Append(
|
|
|
|
|
"<table border=\"0\" cellpadding=\"0\" align=\"center\" cellspacing=\"0\" style=\"border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%;\" width=\"100%\">");
|
|
|
|
|
int count = 0;
|
|
|
|
|
overlay = "https://www.plex.tv/wp-content/themes/plex/img/plex-logo@2x.png";
|
|
|
|
|
var ordered = plexContentToSend.OrderByDescending(x => x.AddedAt);
|
|
|
|
|
foreach (var content in ordered)
|
|
|
|
|
{
|
|
|
|
@ -334,13 +357,15 @@ namespace Ombi.Schedule.Jobs.Ombi
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
var info = await _movieApi.GetMovieInformationWithExtraInfo(movieDbId);
|
|
|
|
|
var mediaurl = content.Url;
|
|
|
|
|
if (info == null)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
CreateMovieHtmlContent(sb, info);
|
|
|
|
|
CreateMovieHtmlContent(sb, info, mediaurl);
|
|
|
|
|
count += 1;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
@ -350,13 +375,20 @@ namespace Ombi.Schedule.Jobs.Ombi
|
|
|
|
|
{
|
|
|
|
|
EndLoopHtml(sb);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (count == 2)
|
|
|
|
|
{
|
|
|
|
|
count = 0;
|
|
|
|
|
sb.Append("</tr>");
|
|
|
|
|
sb.Append("<tr>");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async Task ProcessEmbyMovies(IQueryable<EmbyContent> embyContent, StringBuilder sb)
|
|
|
|
|
{
|
|
|
|
|
sb.Append(
|
|
|
|
|
"<table border=\"0\" cellpadding=\"0\" align=\"center\" cellspacing=\"0\" style=\"border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%;\" width=\"100%\">");
|
|
|
|
|
int count = 0;
|
|
|
|
|
overlay = "https://emby.media/resources/logowhite_1881.png";
|
|
|
|
|
var ordered = embyContent.OrderByDescending(x => x.AddedAt);
|
|
|
|
|
foreach (var content in ordered)
|
|
|
|
|
{
|
|
|
|
@ -375,13 +407,15 @@ namespace Ombi.Schedule.Jobs.Ombi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var info = await _movieApi.GetMovieInformationWithExtraInfo(int.Parse(theMovieDbId));
|
|
|
|
|
var mediaurl = content.Url;
|
|
|
|
|
if (info == null)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
CreateMovieHtmlContent(sb, info);
|
|
|
|
|
CreateMovieHtmlContent(sb, info, mediaurl);
|
|
|
|
|
count += 1;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
@ -391,17 +425,24 @@ namespace Ombi.Schedule.Jobs.Ombi
|
|
|
|
|
{
|
|
|
|
|
EndLoopHtml(sb);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (count == 2)
|
|
|
|
|
{
|
|
|
|
|
count = 0;
|
|
|
|
|
sb.Append("</tr>");
|
|
|
|
|
sb.Append("<tr>");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void CreateMovieHtmlContent(StringBuilder sb, MovieResponseDto info)
|
|
|
|
|
private void CreateMovieHtmlContent(StringBuilder sb, MovieResponseDto info, string mediaurl)
|
|
|
|
|
{
|
|
|
|
|
AddImageInsideTable(sb, $"https://image.tmdb.org/t/p/original{info.PosterPath}");
|
|
|
|
|
AddBackgroundInsideTable(sb, $"https://image.tmdb.org/t/p/w1280/{info.BackdropPath}");
|
|
|
|
|
AddPosterInsideTable(sb, $"https://image.tmdb.org/t/p/original{info.PosterPath}");
|
|
|
|
|
|
|
|
|
|
sb.Append("<tr>");
|
|
|
|
|
TableData(sb);
|
|
|
|
|
AddMediaServerUrl(sb, mediaurl, overlay);
|
|
|
|
|
AddInfoTable(sb);
|
|
|
|
|
|
|
|
|
|
Href(sb, $"https://www.imdb.com/title/{info.ImdbId}/");
|
|
|
|
|
var releaseDate = string.Empty;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
@ -411,16 +452,15 @@ namespace Ombi.Schedule.Jobs.Ombi
|
|
|
|
|
{
|
|
|
|
|
// Swallow, couldn't parse the date
|
|
|
|
|
}
|
|
|
|
|
Header(sb, 3, $"{info.Title} {releaseDate}");
|
|
|
|
|
EndTag(sb, "a");
|
|
|
|
|
|
|
|
|
|
AddTitle(sb, $"https://www.imdb.com/title/{info.ImdbId}/", $"{info.Title} {releaseDate}");
|
|
|
|
|
AddParagraph(sb, info.Overview);
|
|
|
|
|
|
|
|
|
|
if (info.Genres.Any())
|
|
|
|
|
{
|
|
|
|
|
AddParagraph(sb,
|
|
|
|
|
$"Genre: {string.Join(", ", info.Genres.Select(x => x.Name.ToString()).ToArray())}");
|
|
|
|
|
AddGenres(sb,
|
|
|
|
|
$"Genres: {string.Join(", ", info.Genres.Select(x => x.Name.ToString()).ToArray())}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AddParagraph(sb, info.Overview);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async Task ProcessPlexTv(HashSet<PlexEpisode> plexContent, StringBuilder sb)
|
|
|
|
@ -444,9 +484,9 @@ namespace Ombi.Schedule.Jobs.Ombi
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int count = 0;
|
|
|
|
|
overlay = "https://www.plex.tv/wp-content/themes/plex/img/plex-logo@2x.png";
|
|
|
|
|
var orderedTv = series.OrderByDescending(x => x.AddedAt);
|
|
|
|
|
sb.Append(
|
|
|
|
|
"<table border=\"0\" cellpadding=\"0\" align=\"center\" cellspacing=\"0\" style=\"border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%;\" width=\"100%\">");
|
|
|
|
|
foreach (var t in orderedTv)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
@ -489,17 +529,15 @@ namespace Ombi.Schedule.Jobs.Ombi
|
|
|
|
|
{
|
|
|
|
|
banner = banner.Replace("http", "https"); // Always use the Https banners
|
|
|
|
|
}
|
|
|
|
|
AddImageInsideTable(sb, banner);
|
|
|
|
|
|
|
|
|
|
sb.Append("<tr>");
|
|
|
|
|
sb.Append(
|
|
|
|
|
"<td align=\"center\" style=\"font-family: sans-serif; font-size: 14px; vertical-align: top;\" valign=\"top\">");
|
|
|
|
|
//GET BACKGROUND URL HERE AND CALL
|
|
|
|
|
AddBackgroundInsideTable(sb, $"https://image.tmdb.org/t/p/w1280/");
|
|
|
|
|
AddPosterInsideTable(sb, banner);
|
|
|
|
|
AddMediaServerUrl(sb, t.Url, overlay);
|
|
|
|
|
AddInfoTable(sb);
|
|
|
|
|
|
|
|
|
|
var title = $"{t.Title} ({t.ReleaseYear})";
|
|
|
|
|
|
|
|
|
|
Href(sb, $"https://www.imdb.com/title/{info.externals.imdb}/");
|
|
|
|
|
Header(sb, 3, title);
|
|
|
|
|
EndTag(sb, "a");
|
|
|
|
|
AddTitle(sb, $"https://www.imdb.com/title/{info.externals.imdb}/", title);
|
|
|
|
|
|
|
|
|
|
// Group by the season number
|
|
|
|
|
var results = t.Episodes.GroupBy(p => p.SeasonNumber,
|
|
|
|
@ -511,6 +549,7 @@ namespace Ombi.Schedule.Jobs.Ombi
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Group the episodes
|
|
|
|
|
var finalsb = new StringBuilder();
|
|
|
|
|
foreach (var epInformation in results.OrderBy(x => x.SeasonNumber))
|
|
|
|
|
{
|
|
|
|
|
var orderedEpisodes = epInformation.Episodes.OrderBy(x => x.EpisodeNumber).ToList();
|
|
|
|
@ -528,15 +567,24 @@ namespace Ombi.Schedule.Jobs.Ombi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
AddParagraph(sb, $"Season: {epInformation.SeasonNumber}, Episode: {epSb}");
|
|
|
|
|
finalsb.Append($"Season: {epInformation.SeasonNumber} - Episodes: {epSb}");
|
|
|
|
|
finalsb.Append("<br />");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var summary = info.summary;
|
|
|
|
|
if (summary.Length > 280)
|
|
|
|
|
{
|
|
|
|
|
summary = summary.Remove(280);
|
|
|
|
|
summary = summary + "...</p>";
|
|
|
|
|
}
|
|
|
|
|
AddTvParagraph(sb, finalsb.ToString(), summary);
|
|
|
|
|
|
|
|
|
|
if (info.genres.Any())
|
|
|
|
|
{
|
|
|
|
|
AddParagraph(sb, $"Genre: {string.Join(", ", info.genres.Select(x => x.ToString()).ToArray())}");
|
|
|
|
|
AddGenres(sb, $"Genres: {string.Join(", ", info.genres.Select(x => x.ToString()).ToArray())}");
|
|
|
|
|
}
|
|
|
|
|
count += 1;
|
|
|
|
|
|
|
|
|
|
AddParagraph(sb, info.summary);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
@ -546,9 +594,14 @@ namespace Ombi.Schedule.Jobs.Ombi
|
|
|
|
|
{
|
|
|
|
|
EndLoopHtml(sb);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
sb.Append("</table><br /><br />");
|
|
|
|
|
|
|
|
|
|
if (count == 2)
|
|
|
|
|
{
|
|
|
|
|
count = 0;
|
|
|
|
|
sb.Append("</tr>");
|
|
|
|
|
sb.Append("<tr>");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async Task ProcessEmbyTv(HashSet<EmbyEpisode> embyContent, StringBuilder sb)
|
|
|
|
@ -570,9 +623,10 @@ namespace Ombi.Schedule.Jobs.Ombi
|
|
|
|
|
series.Add(episode.Series);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int count = 0;
|
|
|
|
|
overlay = "https://emby.media/resources/logowhite_1881.png";
|
|
|
|
|
var orderedTv = series.OrderByDescending(x => x.AddedAt);
|
|
|
|
|
sb.Append(
|
|
|
|
|
"<table border=\"0\" cellpadding=\"0\" align=\"center\" cellspacing=\"0\" style=\"border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%;\" width=\"100%\">");
|
|
|
|
|
foreach (var t in orderedTv)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
@ -581,26 +635,26 @@ namespace Ombi.Schedule.Jobs.Ombi
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int.TryParse(t.TvDbId, out var tvdbId);
|
|
|
|
|
var info = await _tvApi.ShowLookupByTheTvDbId(tvdbId);
|
|
|
|
|
if (info == null)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var banner = info.image?.original;
|
|
|
|
|
if (!string.IsNullOrEmpty(banner))
|
|
|
|
|
{
|
|
|
|
|
banner = banner.Replace("http", "https"); // Always use the Https banners
|
|
|
|
|
}
|
|
|
|
|
AddImageInsideTable(sb, banner);
|
|
|
|
|
|
|
|
|
|
sb.Append("<tr>");
|
|
|
|
|
sb.Append(
|
|
|
|
|
"<td align=\"center\" style=\"font-family: sans-serif; font-size: 14px; vertical-align: top;\" valign=\"top\">");
|
|
|
|
|
|
|
|
|
|
Href(sb, $"https://www.imdb.com/title/{info.externals.imdb}/");
|
|
|
|
|
Header(sb, 3, t.Title);
|
|
|
|
|
EndTag(sb, "a");
|
|
|
|
|
//GET BACKGROUND URL HERE AND CALL
|
|
|
|
|
AddBackgroundInsideTable(sb, $"https://image.tmdb.org/t/p/w1280/");
|
|
|
|
|
AddPosterInsideTable(sb, banner);
|
|
|
|
|
AddMediaServerUrl(sb, t.Url, overlay);
|
|
|
|
|
AddInfoTable(sb);
|
|
|
|
|
AddTitle(sb, $"https://www.imdb.com/title/{info.externals.imdb}/", $"{t.Title} ({info.premiered.Remove(4)})");
|
|
|
|
|
|
|
|
|
|
// Group by the season number
|
|
|
|
|
var results = t.Episodes?.GroupBy(p => p.SeasonNumber,
|
|
|
|
@ -612,6 +666,7 @@ namespace Ombi.Schedule.Jobs.Ombi
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Group the episodes
|
|
|
|
|
var finalsb = new StringBuilder();
|
|
|
|
|
foreach (var epInformation in results.OrderBy(x => x.SeasonNumber))
|
|
|
|
|
{
|
|
|
|
|
var orderedEpisodes = epInformation.Episodes.OrderBy(x => x.EpisodeNumber).ToList();
|
|
|
|
@ -629,15 +684,24 @@ namespace Ombi.Schedule.Jobs.Ombi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
AddParagraph(sb, $"Season: {epInformation.SeasonNumber}, Episode: {epSb}");
|
|
|
|
|
finalsb.Append($"Season: {epInformation.SeasonNumber} - Episodes: {epSb}");
|
|
|
|
|
finalsb.Append("<br />");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var summary = info.summary;
|
|
|
|
|
if (summary.Length > 280)
|
|
|
|
|
{
|
|
|
|
|
summary = summary.Remove(280);
|
|
|
|
|
summary = summary + "...</p>";
|
|
|
|
|
}
|
|
|
|
|
AddTvParagraph(sb, finalsb.ToString(), summary);
|
|
|
|
|
|
|
|
|
|
if (info.genres.Any())
|
|
|
|
|
{
|
|
|
|
|
AddParagraph(sb, $"Genre: {string.Join(", ", info.genres.Select(x => x.ToString()).ToArray())}");
|
|
|
|
|
AddGenres(sb, $"Genres: {string.Join(", ", info.genres.Select(x => x.ToString()).ToArray())}");
|
|
|
|
|
}
|
|
|
|
|
count += 1;
|
|
|
|
|
|
|
|
|
|
AddParagraph(sb, info.summary);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
@ -647,19 +711,28 @@ namespace Ombi.Schedule.Jobs.Ombi
|
|
|
|
|
{
|
|
|
|
|
EndLoopHtml(sb);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (count == 2)
|
|
|
|
|
{
|
|
|
|
|
count = 0;
|
|
|
|
|
sb.Append("</tr>");
|
|
|
|
|
sb.Append("<tr>");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
sb.Append("</table><br /><br />");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void EndLoopHtml(StringBuilder sb)
|
|
|
|
|
{
|
|
|
|
|
//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
|
|
|
|
|
sb.Append("<hr />");
|
|
|
|
|
sb.Append("<br />");
|
|
|
|
|
sb.Append("<br />");
|
|
|
|
|
sb.Append("</table>");
|
|
|
|
|
sb.Append("</td>");
|
|
|
|
|
sb.Append("</tr>");
|
|
|
|
|
sb.Append("</table>");
|
|
|
|
|
sb.Append("</td>");
|
|
|
|
|
sb.Append("</tr>");
|
|
|
|
|
sb.Append("</table>");
|
|
|
|
|
sb.Append("</td>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected bool ValidateConfiguration(EmailNotificationSettings settings)
|
|
|
|
|