mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-23 06:25:24 -07:00
Stop using TVMaze in newsletter
This commit is contained in:
parent
aacdb4cb2a
commit
4054ff168c
1 changed files with 20 additions and 23 deletions
|
@ -12,7 +12,6 @@ using Ombi.Api.Lidarr;
|
||||||
using Ombi.Api.Lidarr.Models;
|
using Ombi.Api.Lidarr.Models;
|
||||||
using Ombi.Api.TheMovieDb;
|
using Ombi.Api.TheMovieDb;
|
||||||
using Ombi.Api.TheMovieDb.Models;
|
using Ombi.Api.TheMovieDb.Models;
|
||||||
using Ombi.Api.TvMaze;
|
|
||||||
using Ombi.Core.Settings;
|
using Ombi.Core.Settings;
|
||||||
using Ombi.Core.Settings.Models.External;
|
using Ombi.Core.Settings.Models.External;
|
||||||
using Ombi.Helpers;
|
using Ombi.Helpers;
|
||||||
|
@ -33,7 +32,7 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
public class NewsletterJob : HtmlTemplateGenerator, INewsletterJob
|
public class NewsletterJob : HtmlTemplateGenerator, INewsletterJob
|
||||||
{
|
{
|
||||||
public NewsletterJob(IPlexContentRepository plex, IEmbyContentRepository emby, IJellyfinContentRepository jellyfin, IRepository<RecentlyAddedLog> addedLog,
|
public NewsletterJob(IPlexContentRepository plex, IEmbyContentRepository emby, IJellyfinContentRepository jellyfin, IRepository<RecentlyAddedLog> addedLog,
|
||||||
IMovieDbApi movieApi, ITvMazeApi tvApi, IEmailProvider email, ISettingsService<CustomizationSettings> custom,
|
IMovieDbApi movieApi, IEmailProvider email, ISettingsService<CustomizationSettings> custom,
|
||||||
ISettingsService<EmailNotificationSettings> emailSettings, INotificationTemplatesRepository templateRepo,
|
ISettingsService<EmailNotificationSettings> emailSettings, INotificationTemplatesRepository templateRepo,
|
||||||
UserManager<OmbiUser> um, ISettingsService<NewsletterSettings> newsletter, ILogger<NewsletterJob> log,
|
UserManager<OmbiUser> um, ISettingsService<NewsletterSettings> newsletter, ILogger<NewsletterJob> log,
|
||||||
ILidarrApi lidarrApi, IExternalRepository<LidarrAlbumCache> albumCache, ISettingsService<LidarrSettings> lidarrSettings,
|
ILidarrApi lidarrApi, IExternalRepository<LidarrAlbumCache> albumCache, ISettingsService<LidarrSettings> lidarrSettings,
|
||||||
|
@ -45,7 +44,6 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
_jellyfin = jellyfin;
|
_jellyfin = jellyfin;
|
||||||
_recentlyAddedLog = addedLog;
|
_recentlyAddedLog = addedLog;
|
||||||
_movieApi = movieApi;
|
_movieApi = movieApi;
|
||||||
_tvApi = tvApi;
|
|
||||||
_email = email;
|
_email = email;
|
||||||
_customizationSettings = custom;
|
_customizationSettings = custom;
|
||||||
_templateRepo = templateRepo;
|
_templateRepo = templateRepo;
|
||||||
|
@ -73,7 +71,6 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
private readonly IMediaServerContentRepository<JellyfinContent> _jellyfin;
|
private readonly IMediaServerContentRepository<JellyfinContent> _jellyfin;
|
||||||
private readonly IRepository<RecentlyAddedLog> _recentlyAddedLog;
|
private readonly IRepository<RecentlyAddedLog> _recentlyAddedLog;
|
||||||
private readonly IMovieDbApi _movieApi;
|
private readonly IMovieDbApi _movieApi;
|
||||||
private readonly ITvMazeApi _tvApi;
|
|
||||||
private readonly IEmailProvider _email;
|
private readonly IEmailProvider _email;
|
||||||
private readonly ISettingsService<CustomizationSettings> _customizationSettings;
|
private readonly ISettingsService<CustomizationSettings> _customizationSettings;
|
||||||
private readonly INotificationTemplatesRepository _templateRepo;
|
private readonly INotificationTemplatesRepository _templateRepo;
|
||||||
|
@ -692,23 +689,16 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int.TryParse(t.TvDbId, out var tvdbId);
|
try
|
||||||
var info = await _tvApi.ShowLookupByTheTvDbId(tvdbId);
|
{
|
||||||
if (info == null)
|
var tvInfo = await _movieApi.GetTVInfo(t.TheMovieDbId, languageCode);
|
||||||
|
if (tvInfo == null)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var banner = info.image?.original;
|
|
||||||
if (!string.IsNullOrEmpty(banner))
|
|
||||||
{
|
|
||||||
banner = banner.ToHttpsUrl(); // Always use the Https banners
|
|
||||||
}
|
|
||||||
|
|
||||||
var tvInfo = await _movieApi.GetTVInfo(t.TheMovieDbId, languageCode);
|
if (tvInfo.backdrop_path.HasValue())
|
||||||
if (tvInfo != null && tvInfo.backdrop_path.HasValue())
|
|
||||||
{
|
{
|
||||||
|
|
||||||
AddBackgroundInsideTable($"https://image.tmdb.org/t/p/w500{tvInfo.backdrop_path}");
|
AddBackgroundInsideTable($"https://image.tmdb.org/t/p/w500{tvInfo.backdrop_path}");
|
||||||
|
@ -717,11 +707,18 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
{
|
{
|
||||||
AddBackgroundInsideTable($"https://image.tmdb.org/t/p/w1280/");
|
AddBackgroundInsideTable($"https://image.tmdb.org/t/p/w1280/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var banner = tvInfo.poster_path;
|
||||||
|
if (!string.IsNullOrEmpty(banner))
|
||||||
|
{
|
||||||
|
banner = $"https://image.tmdb.org/t/p/w300/{banner?.TrimStart('/') ?? string.Empty}";
|
||||||
|
};
|
||||||
AddPosterInsideTable(banner);
|
AddPosterInsideTable(banner);
|
||||||
AddMediaServerUrl(t.Url, banner);
|
AddMediaServerUrl(t.Url, banner);
|
||||||
|
|
||||||
AddInfoTable();
|
AddInfoTable();
|
||||||
|
|
||||||
AddTvTitle(info, tvInfo);
|
AddTvTitle(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,
|
||||||
|
@ -766,18 +763,18 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddTvTitle(Api.TvMaze.Models.TvMazeShow info, TvInfo tvInfo)
|
private void AddTvTitle(TvInfo tvInfo)
|
||||||
{
|
{
|
||||||
var title = "";
|
var title = "";
|
||||||
if (!String.IsNullOrEmpty(info.premiered) && info.premiered.Length > 4)
|
if (!String.IsNullOrEmpty(tvInfo.first_air_date) && tvInfo.first_air_date.Length > 4)
|
||||||
{
|
{
|
||||||
title = $"{tvInfo.name} ({info.premiered.Remove(4)})";
|
title = $"{tvInfo.name} ({tvInfo.first_air_date.Remove(4)})";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
title = $"{tvInfo.name}";
|
title = $"{tvInfo.name}";
|
||||||
}
|
}
|
||||||
AddTitle($"https://www.imdb.com/title/{info.externals.imdb}/", title);
|
AddTitle($"https://www.themoviedb.org/tv/{tvInfo.id}/", title);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddTvEpisodesSummaryGenres(string episodes, TvInfo tvInfo)
|
private void AddTvEpisodesSummaryGenres(string episodes, TvInfo tvInfo)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue