|
|
@ -76,42 +76,42 @@ namespace Ombi.Core.Engine
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<SearchTvShowViewModel> GetShowInformation(int tvdbid)
|
|
|
|
public async Task<SearchTvShowViewModel> GetShowInformation(string theMovieDbId)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var show = await Cache.GetOrAdd(nameof(GetShowInformation) + tvdbid,
|
|
|
|
var show = await Cache.GetOrAdd(nameof(GetShowInformation) + theMovieDbId,
|
|
|
|
async () => await TvMazeApi.ShowLookupByTheTvDbId(tvdbid), DateTime.Now.AddHours(12));
|
|
|
|
async () => await _theMovieDbApi.GetTVInfo(theMovieDbId), DateTime.Now.AddHours(12));
|
|
|
|
if (show == null)
|
|
|
|
if (show == null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// We don't have enough information
|
|
|
|
// We don't have enough information
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var episodes = await Cache.GetOrAdd("TvMazeEpisodeLookup" + show.id,
|
|
|
|
//var episodes = await Cache.GetOrAdd("TvMazeEpisodeLookup" + show.id,
|
|
|
|
async () => await TvMazeApi.EpisodeLookup(show.id), DateTime.Now.AddHours(12));
|
|
|
|
// async () => await TvMazeApi.EpisodeLookup(show.id), DateTime.Now.AddHours(12));
|
|
|
|
if (episodes == null || !episodes.Any())
|
|
|
|
//if (episodes == null || !episodes.Any())
|
|
|
|
{
|
|
|
|
//{
|
|
|
|
// We don't have enough information
|
|
|
|
// // We don't have enough information
|
|
|
|
return null;
|
|
|
|
// return null;
|
|
|
|
}
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
var mapped = Mapper.Map<SearchTvShowViewModel>(show);
|
|
|
|
var mapped = Mapper.Map<SearchTvShowViewModel>(show);
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var e in episodes)
|
|
|
|
foreach (var e in show.seasons)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var season = mapped.SeasonRequests.FirstOrDefault(x => x.SeasonNumber == e.season);
|
|
|
|
var season = mapped.SeasonRequests.FirstOrDefault(x => x.SeasonNumber == e.season_number);
|
|
|
|
if (season == null)
|
|
|
|
if (season == null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var newSeason = new SeasonRequests
|
|
|
|
var newSeason = new SeasonRequests
|
|
|
|
{
|
|
|
|
{
|
|
|
|
SeasonNumber = e.season,
|
|
|
|
SeasonNumber = e.season_number,
|
|
|
|
Episodes = new List<EpisodeRequests>()
|
|
|
|
Episodes = new List<EpisodeRequests>()
|
|
|
|
};
|
|
|
|
};
|
|
|
|
newSeason.Episodes.Add(new EpisodeRequests
|
|
|
|
newSeason.Episodes.Add(new EpisodeRequests
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Url = e.url.ToHttpsUrl(),
|
|
|
|
//Url = e..ToHttpsUrl(),
|
|
|
|
Title = e.name,
|
|
|
|
Title = e.name,
|
|
|
|
AirDate = e.airstamp.HasValue() ? DateTime.Parse(e.airstamp) : DateTime.MinValue,
|
|
|
|
AirDate = e.air_date.HasValue() ? DateTime.Parse(e.air_date) : DateTime.MinValue,
|
|
|
|
EpisodeNumber = e.number,
|
|
|
|
EpisodeNumber = e,
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
mapped.SeasonRequests.Add(newSeason);
|
|
|
|
mapped.SeasonRequests.Add(newSeason);
|
|
|
|