mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-24 06:55:23 -07:00
Use the MovieDb to get episode info and set aired date
This commit is contained in:
parent
18f78d0848
commit
3a634c7920
1 changed files with 12 additions and 1 deletions
|
@ -12,6 +12,7 @@ using Microsoft.AspNetCore.SignalR;
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using MimeKit;
|
||||
using Nito.AsyncEx;
|
||||
using Ombi.Api.CouchPotato.Models;
|
||||
using Ombi.Api.Lidarr;
|
||||
using Ombi.Api.Lidarr.Models;
|
||||
|
@ -808,12 +809,14 @@ namespace Ombi.Schedule.Jobs.Ombi
|
|||
}
|
||||
);
|
||||
|
||||
var allSeasonInfo = await results.Select(x => _movieApi.GetTVSeasonInfo(t.TheMovieDbId, x.SeasonNumber)).WhenAll();
|
||||
|
||||
// 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();
|
||||
var episodeString = BuildEpisodeList(orderedEpisodes.Select(x => (x.EpisodeNumber, x.Aired)));
|
||||
var episodeString = BuildEpisodeList(orderedEpisodes.Select(x => (x.EpisodeNumber, GetDateAired(x, allSeasonInfo))));
|
||||
var seasonAirDate = epInformation.SeasonAirDate;
|
||||
finalsb.Append($"Season: {epInformation.SeasonNumber} - Episodes: {episodeString} {seasonAirDate}");
|
||||
finalsb.Append("<br />");
|
||||
|
@ -852,6 +855,14 @@ namespace Ombi.Schedule.Jobs.Ombi
|
|||
}
|
||||
}
|
||||
|
||||
private static DateTime? GetDateAired(PlexEpisode episode, TvSeason[] allSeasonInfo)
|
||||
{
|
||||
return DateTime.TryParse(allSeasonInfo.FirstOrDefault(_ => _.season_number == episode.SeasonNumber)?.episodes
|
||||
.FirstOrDefault(e => e.episode_number == episode.EpisodeNumber)?.air_date, out var airedDate)
|
||||
? airedDate
|
||||
: (DateTime?)null;
|
||||
}
|
||||
|
||||
public static string BuildEpisodeList(IEnumerable<(int EpisodeNumber, DateTime? Aired)> orderedEpisodes)
|
||||
{
|
||||
var epSb = new StringBuilder();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue