From c95e7368aeb57cb27ddeb35e1570f9206057fdd6 Mon Sep 17 00:00:00 2001 From: tidusjar Date: Mon, 6 Mar 2017 20:54:31 +0000 Subject: [PATCH] Fixed a bug in the Plex Newsletter --- .../PlexRecentlyAddedNewsletter.cs | 22 ++++++++++++++++--- Ombi.Store/TableCreation.cs | 3 ++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/Ombi.Services/Jobs/RecentlyAddedNewsletter/PlexRecentlyAddedNewsletter.cs b/Ombi.Services/Jobs/RecentlyAddedNewsletter/PlexRecentlyAddedNewsletter.cs index 0b37ae813..79687636a 100644 --- a/Ombi.Services/Jobs/RecentlyAddedNewsletter/PlexRecentlyAddedNewsletter.cs +++ b/Ombi.Services/Jobs/RecentlyAddedNewsletter/PlexRecentlyAddedNewsletter.cs @@ -117,12 +117,16 @@ namespace Ombi.Services.Jobs.RecentlyAddedNewsletter var filteredMovies = movie.Where(m => recentlyAdded.All(x => x.ProviderId != m.ProviderId)).ToList(); var filteredEp = episodes.Where(m => recentlyAdded.All(x => x.ProviderId != m.ProviderId)).ToList(); - + var filteredSeries = series.Where(x => recentlyAdded.All(c => c.ProviderId != x.ProviderId)).ToList(); var info = new List(); foreach (var m in filteredMovies) { var i = Api.GetMetadata(plexSettings.PlexAuthToken, plexSettings.FullUri, m.ItemId); + if (i.Video == null) + { + continue; + } info.Add(new PlexRecentlyAddedModel { Metadata = i, @@ -132,10 +136,14 @@ namespace Ombi.Services.Jobs.RecentlyAddedNewsletter GenerateMovieHtml(info, sb); info.Clear(); - foreach (var t in series) + foreach (var t in filteredSeries) { var i = Api.GetMetadata(plexSettings.PlexAuthToken, plexSettings.FullUri, t.ItemId); - + if (i.Directory == null) + { + continue; + + } //var ep = filteredEp.Where(x => x.ShowTitle == t.Title); info.Add(new PlexRecentlyAddedModel { @@ -183,6 +191,14 @@ namespace Ombi.Services.Jobs.RecentlyAddedNewsletter AddedAt = DateTime.UtcNow }); } + foreach (var a in filteredSeries) + { + RecentlyAddedLog.Insert(new RecentlyAddedLog + { + ProviderId = a.ProviderId, + AddedAt = DateTime.UtcNow + }); + } } var escapedHtml = new string(html.Where(c => !char.IsControl(c)).ToArray()); diff --git a/Ombi.Store/TableCreation.cs b/Ombi.Store/TableCreation.cs index e3fc2c3f8..90aad78e5 100644 --- a/Ombi.Store/TableCreation.cs +++ b/Ombi.Store/TableCreation.cs @@ -25,6 +25,7 @@ // *********************************************************************** #endregion +using System; using System.Collections.Generic; using System.Data; using System.Linq; @@ -61,7 +62,7 @@ namespace Ombi.Store { connection.Open(); var result = connection.Query($"PRAGMA table_info({tableName});"); - if (result.Any(x => x.name == newColumn)) + if (result.Any(x => x.name.Equals(newColumn, StringComparison.CurrentCultureIgnoreCase))) { connection.Close(); return;