mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-20 21:33:15 -07:00
fix (technical): Improved some of the date time parsing handling
This commit is contained in:
parent
f858c88433
commit
20bbe92114
4 changed files with 46 additions and 8 deletions
|
@ -106,11 +106,17 @@ namespace Ombi.Core.Engine
|
||||||
SeasonNumber = e.season,
|
SeasonNumber = e.season,
|
||||||
Episodes = new List<EpisodeRequests>()
|
Episodes = new List<EpisodeRequests>()
|
||||||
};
|
};
|
||||||
|
var hasAirDate = e.airstamp.HasValue();
|
||||||
|
var airDate = DateTime.MinValue;
|
||||||
|
if (hasAirDate)
|
||||||
|
{
|
||||||
|
hasAirDate = DateTime.TryParse(e.airdate, out airDate);
|
||||||
|
}
|
||||||
newSeason.Episodes.Add(new EpisodeRequests
|
newSeason.Episodes.Add(new EpisodeRequests
|
||||||
{
|
{
|
||||||
Url = e.url.ToHttpsUrl(),
|
Url = e.url.ToHttpsUrl(),
|
||||||
Title = e.name,
|
Title = e.name,
|
||||||
AirDate = e.airstamp.HasValue() ? DateTime.Parse(e.airstamp) : DateTime.MinValue,
|
AirDate = airDate,
|
||||||
EpisodeNumber = e.number,
|
EpisodeNumber = e.number,
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -118,12 +124,18 @@ namespace Ombi.Core.Engine
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
var hasAirDate = e.airstamp.HasValue();
|
||||||
|
var airDate = DateTime.MinValue;
|
||||||
|
if (hasAirDate)
|
||||||
|
{
|
||||||
|
hasAirDate = DateTime.TryParse(e.airdate, out airDate);
|
||||||
|
}
|
||||||
// We already have the season, so just add the episode
|
// We already have the season, so just add the episode
|
||||||
season.Episodes.Add(new EpisodeRequests
|
season.Episodes.Add(new EpisodeRequests
|
||||||
{
|
{
|
||||||
Url = e.url.ToHttpsUrl(),
|
Url = e.url.ToHttpsUrl(),
|
||||||
Title = e.name,
|
Title = e.name,
|
||||||
AirDate = e.airstamp.HasValue() ? DateTime.Parse(e.airstamp) : DateTime.MinValue,
|
AirDate = airDate,
|
||||||
EpisodeNumber = e.number,
|
EpisodeNumber = e.number,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -272,11 +272,17 @@ namespace Ombi.Core.Engine.V2
|
||||||
Overview = tvSeason.overview,
|
Overview = tvSeason.overview,
|
||||||
Episodes = new List<EpisodeRequests>()
|
Episodes = new List<EpisodeRequests>()
|
||||||
};
|
};
|
||||||
|
var hasAirDate = episode.air_date.HasValue();
|
||||||
|
var airDate = DateTime.MinValue;
|
||||||
|
if (hasAirDate)
|
||||||
|
{
|
||||||
|
DateTime.TryParse(episode.air_date, out airDate);
|
||||||
|
}
|
||||||
newSeason.Episodes.Add(new EpisodeRequests
|
newSeason.Episodes.Add(new EpisodeRequests
|
||||||
{
|
{
|
||||||
//Url = episode...ToHttpsUrl(),
|
//Url = episode...ToHttpsUrl(),
|
||||||
Title = episode.name,
|
Title = episode.name,
|
||||||
AirDate = episode.air_date.HasValue() ? DateTime.Parse(episode.air_date) : DateTime.MinValue,
|
AirDate = airDate,
|
||||||
EpisodeNumber = episode.episode_number,
|
EpisodeNumber = episode.episode_number,
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -284,12 +290,18 @@ namespace Ombi.Core.Engine.V2
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
var hasAirDate = episode.air_date.HasValue();
|
||||||
|
var airDate = DateTime.MinValue;
|
||||||
|
if (hasAirDate)
|
||||||
|
{
|
||||||
|
DateTime.TryParse(episode.air_date, out airDate);
|
||||||
|
}
|
||||||
// We already have the season, so just add the episode
|
// We already have the season, so just add the episode
|
||||||
season.Episodes.Add(new EpisodeRequests
|
season.Episodes.Add(new EpisodeRequests
|
||||||
{
|
{
|
||||||
//Url = e.url.ToHttpsUrl(),
|
//Url = e.url.ToHttpsUrl(),
|
||||||
Title = episode.name,
|
Title = episode.name,
|
||||||
AirDate = episode.air_date.HasValue() ? DateTime.Parse(episode.air_date) : DateTime.MinValue,
|
AirDate = airDate,
|
||||||
EpisodeNumber = episode.episode_number,
|
EpisodeNumber = episode.episode_number,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -261,9 +261,16 @@ namespace Ombi.Core.Helpers
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private DateTime FormatDate(string date)
|
private static DateTime FormatDate(string date)
|
||||||
{
|
{
|
||||||
return string.IsNullOrEmpty(date) ? DateTime.MinValue : DateTime.Parse(date);
|
if (date.HasValue())
|
||||||
|
{
|
||||||
|
if (DateTime.TryParse(date, out var d))
|
||||||
|
{
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return DateTime.MinValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -255,9 +255,16 @@ namespace Ombi.Core.Helpers
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private DateTime FormatDate(string date)
|
private static DateTime FormatDate(string date)
|
||||||
{
|
{
|
||||||
return string.IsNullOrEmpty(date) ? DateTime.MinValue : DateTime.Parse(date);
|
if (date.HasValue())
|
||||||
|
{
|
||||||
|
if (DateTime.TryParse(date, out var d))
|
||||||
|
{
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return DateTime.MinValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue