Skip to content

Commit

Permalink
Improvement:
Browse files Browse the repository at this point in the history
- Episode AirDate converted to nullable, to support TBA episodes.
  • Loading branch information
umutozel committed Apr 19, 2015
1 parent 98a0185 commit 0e8053e
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Novaroma.Engine/NovaromaEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ private Task<IEnumerable<TvShowEpisode>> GetTvShowEpisodesToDownload() {
using (var context = _contextFactory.CreateContext()) {
return context.TvShows
.Episodes()
.Where(e => e.BackgroundDownload && e.AirDate.Date.AddHours(8) < DateTime.UtcNow)
.Where(e => e.BackgroundDownload && e.AirDate.HasValue && e.AirDate.Value.AddHours(8) < DateTime.UtcNow)
.Take(10)
.ToList()
.AsEnumerable();
Expand Down Expand Up @@ -548,7 +548,7 @@ private Task<IEnumerable<TvShowEpisode>> GetTvShowEpisodesForSubtitleDownload()
using (var context = _contextFactory.CreateContext()) {
return context.TvShows
.Episodes()
.Where(e => !string.IsNullOrEmpty(e.FilePath) && e.BackgroundSubtitleDownload && e.AirDate.Date.AddHours(12) < DateTime.UtcNow)
.Where(e => !string.IsNullOrEmpty(e.FilePath) && e.BackgroundSubtitleDownload && e.AirDate.HasValue && e.AirDate.Value.AddHours(12) < DateTime.UtcNow)
.ToList()
.AsEnumerable();
}
Expand Down
5 changes: 4 additions & 1 deletion Novaroma.Services/Tmdb/TmdbTracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ public static Task<TvShowUpdate> GetUpdate(int id, DateTime? lastUpdate = null,

foreach (var episode in season.Episodes) {
var ad = episode.AirDate;
var airDate = new DateTime(ad.Year, ad.Month, ad.Day, 20, 0, 0, DateTimeKind.Utc);
DateTime? airDate;
if (ad.Year < 1896) airDate = null;
else
airDate = new DateTime(ad.Year, ad.Month, ad.Day, 20, 0, 0, DateTimeKind.Utc);
episodes.Add(new TvShowEpisodeInfo(season.SeasonNumber, episode.EpisodeNumber, episode.Name, airDate, episode.Overview));
}
}
Expand Down
2 changes: 1 addition & 1 deletion Novaroma/Interface/Track/ITvShowEpisodeInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public interface ITvShowEpisodeInfo {
int Season { get; }
int Episode { get; }
string Name { get; }
DateTime AirDate { get; }
DateTime? AirDate { get; }
string Overview { get; }
}
}
6 changes: 3 additions & 3 deletions Novaroma/Interface/Track/TvShowEpisodeInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ public class TvShowEpisodeInfo: ITvShowEpisodeInfo {
private readonly int _season;
private readonly int _episode;
private readonly string _name;
private readonly DateTime _airDate;
private readonly DateTime? _airDate;
private readonly string _overview;

public TvShowEpisodeInfo(int season, int episode, string name, DateTime airDate, string overview) {
public TvShowEpisodeInfo(int season, int episode, string name, DateTime? airDate, string overview) {
_season = season;
_episode = episode;
_name = name;
Expand All @@ -29,7 +29,7 @@ public string Name {
get { return _name; }
}

public DateTime AirDate {
public DateTime? AirDate {
get { return _airDate; }
}

Expand Down
4 changes: 2 additions & 2 deletions Novaroma/Model/TvShowEpisode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class TvShowEpisode : ModelBase, IDownloadable {
private int _episode;
private string _name;
private string _overview;
private DateTime _airDate;
private DateTime? _airDate;
private bool _backgroundDownload;
private string _downloadKey;
private bool _notFound;
Expand Down Expand Up @@ -62,7 +62,7 @@ public string Overview {
}
}

public DateTime AirDate {
public DateTime? AirDate {
get { return _airDate; }
set {
if (_airDate == value) return;
Expand Down

0 comments on commit 0e8053e

Please sign in to comment.