From 44840bcd87bf67ba0ccec0cf25ac9639090ea945 Mon Sep 17 00:00:00 2001 From: sephrat <34862846+sephrat@users.noreply.github.com> Date: Wed, 27 Apr 2022 09:14:29 +0200 Subject: [PATCH] refactor(newsletter): Clarify very rare cases where newsletter doesn't publish a series --- src/Ombi.Schedule/Jobs/Ombi/NewsletterJob.cs | 38 +++----------------- 1 file changed, 5 insertions(+), 33 deletions(-) diff --git a/src/Ombi.Schedule/Jobs/Ombi/NewsletterJob.cs b/src/Ombi.Schedule/Jobs/Ombi/NewsletterJob.cs index a11a9ff80..f0f30f869 100644 --- a/src/Ombi.Schedule/Jobs/Ombi/NewsletterJob.cs +++ b/src/Ombi.Schedule/Jobs/Ombi/NewsletterJob.cs @@ -409,7 +409,9 @@ namespace Ombi.Schedule.Jobs.Ombi private HashSet FilterEpisodes(IEnumerable source, IEnumerable recentlyAdded) { var itemsToReturn = new HashSet(); - foreach (var ep in source.Where(x => x.Series.HasTvDb)) + foreach (var ep in source.Where(x => x.Series.HasTvDb // needed for recentlyAddedLog + && x.Series.HasTheMovieDb // needed to fetch info to publish, this is just in case... + )) { var tvDbId = StringHelper.IntParseLinq(ep.Series.TvDbId); if (recentlyAdded.Any(x => x.ContentId == tvDbId && x.EpisodeNumber == ep.EpisodeNumber && x.SeasonNumber == ep.SeasonNumber)) @@ -665,48 +667,18 @@ namespace Ombi.Schedule.Jobs.Ombi var orderedTv = series.OrderByDescending(x => x.AddedAt); foreach (var t in orderedTv) { - if (!t.HasTvDb) - { - // We may need to use themoviedb for the imdbid or their own id to get info - if (t.HasTheMovieDb) - { - int.TryParse(t.TheMovieDbId, out var movieId); - var externals = await _movieApi.GetTvExternals(movieId); - if (externals == null || externals.tvdb_id <= 0) - { - // needed later for recently added log - _log.LogWarning($"{t.Title} has no TVDB ID, it won't be published."); - continue; - } - t.TvDbId = externals.tvdb_id.ToString(); - } - // WE could check the below but we need to get the moviedb and then perform the above, let the metadata job figure this out. - //else if(t.HasImdb) - //{ - // // Check the imdbid - // var externals = await _movieApi.Find(t.ImdbId, ExternalSource.imdb_id); - // if (externals?.tv_results == null || externals.tv_results.Length <= 0) - // { - // continue; - // } - // t.TvDbId = externals.tv_results.FirstOrDefault()..ToString(); - //} - - } - try { var tvInfo = await _movieApi.GetTVInfo(t.TheMovieDbId, languageCode); if (tvInfo == null) { - _log.LogWarning($"TMDB does not know series {t.Title}, it won't be published."); + _log.LogError($"TMDB does not know series {t.Title}. This shouldn't happen because our media server knows it as ID '{t.TheMovieDbId}'."); continue; } if (tvInfo.backdrop_path.HasValue()) { - AddBackgroundInsideTable($"https://image.tmdb.org/t/p/w500{tvInfo.backdrop_path}"); } else @@ -732,7 +704,7 @@ namespace Ombi.Schedule.Jobs.Ombi } catch (Exception e) { - _log.LogError(e, "Error when processing Plex TV {0}", t.Title); + _log.LogError(e, "Error when processing TV {0}", t.Title); } finally {