Skip to content

Commit

Permalink
Improve timezone handling of streamed shows
Browse files Browse the repository at this point in the history
  • Loading branch information
SirSparkles committed Jul 4, 2023
1 parent 6cc250c commit cbd9533
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
12 changes: 8 additions & 4 deletions TVRename/Model/Episode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,19 @@ protected Episode(Episode o)

public LocalDateTime? GetAirDateDt()
{
if (FirstAired is null || internalSeries is null)
DateTime? fa = FirstAired;

if (fa is null)
{
return null;
}
DateTime? airs = internalSeries?.AirsTime ?? AirStamp;

DateTime fa = (DateTime)FirstAired;
DateTime? airs = internalSeries.AirsTime;
int defaultHour = (internalSeries?.Network).IsStreamingService()
? 0
: 20;

return new LocalDateTime(fa.Year, fa.Month, fa.Day, airs?.Hour ?? 20, airs?.Minute ?? 0);
return new LocalDateTime(fa.Value.Year, fa.Value.Month, fa.Value.Day, airs?.Hour ?? defaultHour, airs?.Minute ?? 0);
}

public DateTime? GetAirDateDt(DateTimeZone tz)
Expand Down
4 changes: 2 additions & 2 deletions TVRename/ScanActivity/CleanDownloadDirectory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ private static Action SetupDirectoryRemoval(DirectoryInfo di,
{
ShowConfiguration si = matchingShows[0]; //Choose the first cachedSeries
FinderHelper.FindSeasEp(di, out int seasF, out int epF, si, out TVSettings.FilenameProcessorRE? _);
CachedSeriesInfo? s = si.CachedShow;
if (s is null)

if (si.CachedShow is null)
{
throw new ArgumentNullException(nameof(matchingShows), "s is null");
}
Expand Down
2 changes: 1 addition & 1 deletion TVRename/Utility/Helper/JSONHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static class JsonHelper
{
Logger.Error($"Failed to parse time: {theTime}");
}
return DateTime.Parse("20:00");
return null;
}

public static bool ContainsTyped<T>(this JArray arr, T? item)
Expand Down
12 changes: 12 additions & 0 deletions TVRename/Utility/Helper/TimeZoneHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ public static class TimeZoneHelper

public static string DefaultTimeZone() => "America/New_York";

public static bool IsStreamingService(this string? network)
{
if (string.IsNullOrWhiteSpace(network))
{
return false;
}

string[] streamers = { "Netflix","Apple TV+","Disney+","Amazon Prime Video","Paramount+" };

return streamers.Contains(network);
}

public static string TimeZoneForNetwork(string? network, string defaultTimeZone)
{
string[] uktv = { "Sky Atlantic (UK)", "BBC One", "Sky1", "BBC Two", "ITV", "Nick Jr.", "BBC Three", "Channel 4", "CBeebies", "Sky Box Office", "Watch", "ITV2", "National Geographic (UK)", "V", "ITV Encore", "ITV1", "BBC", "E4", "Channel 5 (UK)", "BBC Four", "ITVBe" };
Expand Down

0 comments on commit cbd9533

Please sign in to comment.