diff --git a/PlexRequests.Services/Jobs/RecentlyAdded.cs b/PlexRequests.Services/Jobs/RecentlyAdded.cs index 0755baafa..3de05ea07 100644 --- a/PlexRequests.Services/Jobs/RecentlyAdded.cs +++ b/PlexRequests.Services/Jobs/RecentlyAdded.cs @@ -138,25 +138,6 @@ namespace PlexRequests.Services.Jobs Send(html, plexSettings, testEmail); } - private void StartDb(bool testEmail = false) - { - var sb = new StringBuilder(); - var plexSettings = PlexSettings.GetSettings(); - - var recentlyAdded = PlexDb.GetItemsAddedAfterDate(DateTime.Now.AddDays(-12)).ToList(); // TODO Date configurable - - var movies = recentlyAdded.Where(x => x.metadata_type == MetadataTypeMovie); - var tv = recentlyAdded.Where(x => x.metadata_type == MetadataTypeTv); - - GenerateMovieHtml(movies, ref sb); - GenerateTvHtml(tv, ref sb); - - var template = new RecentlyAddedTemplate(); - var html = template.LoadTemplate(sb.ToString()); - - Send(html, plexSettings, testEmail); - } - private void GenerateMovieHtml(RecentlyAddedModel movies, PlexSettings plexSettings, ref StringBuilder sb) { sb.Append("

New Movies:



"); @@ -294,11 +275,15 @@ namespace PlexRequests.Services.Jobs sb.Append(""); sb.Append(""); - var title = $"{t.grandparentTitle} - {t.title} {t.originallyAvailableAt.Substring(0, 4)}"; + var title = $"{t.grandparentTitle} - {t.title} {t.originallyAvailableAt?.Substring(0, 4)}"; - sb.AppendFormat("

{1} {2}

", + sb.AppendFormat("

{1}

", info.externals.imdb, title); // Only the year + + sb.AppendFormat("

Season: {0}, Episode: {1}

", t.parentIndex, t.index); + + sb.AppendFormat("

Genre: {0}

", string.Join(", ", info.genres.Select(x => x.ToString()).ToArray())); sb.AppendFormat("

{0}

", string.IsNullOrEmpty(t.summary) ? info.summary : t.summary); // Episode Summary @@ -311,6 +296,11 @@ namespace PlexRequests.Services.Jobs } catch (Exception e) { + sb.Append(""); + sb.Append("
"); + sb.Append("
"); + sb.Append(""); Log.Error(e); Log.Error("Exception when trying to process a TV Show, either in getting the metadata from Plex OR getting the information from TVMaze, Plex GUID = {0}", plexGUID); } diff --git a/PlexRequests.UI/Views/Admin/NewsletterSettings.cshtml b/PlexRequests.UI/Views/Admin/NewsletterSettings.cshtml index f45060aa8..a93aba3ec 100644 --- a/PlexRequests.UI/Views/Admin/NewsletterSettings.cshtml +++ b/PlexRequests.UI/Views/Admin/NewsletterSettings.cshtml @@ -71,6 +71,29 @@ }); }); + $('#recentlyAddedBtn').click(function (e) { + e.preventDefault(); + var base = '@Html.GetBaseUrl()'; + var url = createBaseUrl(base, '/admin/recentlyAddedTest'); + + $.ajax({ + type: "post", + url: url, + dataType: "json", + success: function (response) { + if (response) { + generateNotify(response.message, "success"); + } else { + + generateNotify(response.message, "danger"); + } + }, + error: function (e) { + console.log(e); + generateNotify("Something went wrong!", "danger"); + } + }); + }); }); \ No newline at end of file diff --git a/PlexRequests.UI/Views/Admin/Settings.cshtml b/PlexRequests.UI/Views/Admin/Settings.cshtml index fdb847b13..acebf8e31 100644 --- a/PlexRequests.UI/Views/Admin/Settings.cshtml +++ b/PlexRequests.UI/Views/Admin/Settings.cshtml @@ -361,7 +361,7 @@ }); }); - $('#refreshKey').click(function (e) { + $('#refreshKey').click(function(e) { e.preventDefault(); var base = '@Html.GetBaseUrl()'; var url = createBaseUrl(base, '/admin/createapikey'); @@ -370,37 +370,13 @@ type: "post", url: url, dataType: "json", - success: function (response) { + success: function(response) { if (response) { generateNotify("Success!", "success"); $('#apiKey').val(response); } }, - error: function (e) { - console.log(e); - generateNotify("Something went wrong!", "danger"); - } - }); - }); - - $('#recentlyAddedBtn').click(function (e) { - e.preventDefault(); - var base = '@Html.GetBaseUrl()'; - var url = createBaseUrl(base, '/admin/recentlyAddedTest'); - - $.ajax({ - type: "post", - url: url, - dataType: "json", - success: function (response) { - if (response) { - generateNotify(response.message, "success"); - } else { - - generateNotify(response.message, "danger"); - } - }, - error: function (e) { + error: function(e) { console.log(e); generateNotify("Something went wrong!", "danger"); }