diff --git a/TVRename#/App/ApplicationBase.cs b/TVRename#/App/ApplicationBase.cs
index 13fe472e8..314cd019e 100644
--- a/TVRename#/App/ApplicationBase.cs
+++ b/TVRename#/App/ApplicationBase.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using System.Windows.Forms;
using Alphaleonis.Win32.Filesystem;
using Microsoft.VisualBasic.ApplicationServices;
@@ -12,7 +13,7 @@ namespace TVRename.App
///
internal class ApplicationBase : WindowsFormsApplicationBase
{
- private static readonly NLog.Logger Logger = NLog.LogManager.GetCurrentClassLogger();
+ private static readonly NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
///
/// Initializes the splash screen.
@@ -22,7 +23,7 @@ protected override void OnCreateSplashScreen()
this.SplashScreen = new TVRenameSplash();
CommandLineArgs clargs = new CommandLineArgs(this.CommandLineArgs);
- if ((!clargs.Unattended) && (!clargs.Hide)) this.SplashScreen.Enabled = false;
+ if ((clargs.Unattended) || (clargs.Hide)) this.SplashScreen.Visible = false;
}
@@ -32,6 +33,11 @@ protected override void OnCreateSplashScreen()
///
protected override void OnCreateMainForm()
{
+ CommandLineArgs clargs = new CommandLineArgs(this.CommandLineArgs);
+ if ((clargs.Unattended) || (clargs.Hide))
+ this.SplashScreen.SafeInvoke(
+ () => ((TVRenameSplash)this.SplashScreen).Visible = false,true);
+
// Update splash screen
this.SplashScreen.SafeInvoke(
() => ((TVRenameSplash) this.SplashScreen).UpdateStatus("Initializing"), true);
@@ -39,8 +45,6 @@ protected override void OnCreateMainForm()
// Update RegVersion to bring the WebBrowser up to speed
RegistryHelper.UpdateBrowserEmulationVersion();
- CommandLineArgs clargs = new CommandLineArgs(this.CommandLineArgs);
-
bool recover = false;
string recoverText = string.Empty;
@@ -62,7 +66,7 @@ protected override void OnCreateMainForm()
{
if (!clargs.Unattended && !clargs.Hide) MessageBox.Show($"Error while setting the User-Defined File Path:{Environment.NewLine}{ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
- Logger.Error(ex, $"Error while setting the User-Defined File Path - EXITING: {clargs.UserFilePath}");
+ logger.Error(ex, $"Error while setting the User-Defined File Path - EXITING: {clargs.UserFilePath}");
Environment.Exit(1);
}
@@ -96,6 +100,9 @@ protected override void OnCreateMainForm()
// Try loading settings file
doc = new TVDoc(settingsFile, clargs);
+ convertSeriesTimeZones(doc, TheTVDB.Instance);
+
+
if (recover) doc.SetDirty();
recover = !doc.LoadOK;
@@ -116,5 +123,24 @@ protected override void OnCreateMainForm()
this.MainForm = ui;
}
+
+ private void convertSeriesTimeZones(TVDoc doc, TheTVDB tvdb)
+ {
+ //this is just to convert timezones in the TheTVDB into the TVDOC where they should be:
+ //itshould only do anything the first time it is run and then be entirely begign
+ //can be removed after 1/1/19
+
+ foreach (ShowItem si in doc.ShowItems)
+ {
+ string newTimeZone = tvdb.GetSeries(si.TVDBCode).tempTimeZone;
+ if ((si.ShowTimeZone == TimeZone.DefaultTimeZone()) && newTimeZone != TimeZone.DefaultTimeZone() && !string.IsNullOrWhiteSpace(newTimeZone))
+ {
+ si.ShowTimeZone = newTimeZone;
+ doc.SetDirty();
+ logger.Info("Copied timezone:{0} onto series {1}", newTimeZone, si.ShowName);
+ }
+ }
+
+ }
}
}
diff --git a/TVRename#/App/CommandLineArgs.cs b/TVRename#/App/CommandLineArgs.cs
index 9f6b21997..13329d0d1 100644
--- a/TVRename#/App/CommandLineArgs.cs
+++ b/TVRename#/App/CommandLineArgs.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.ObjectModel;
using System.Linq;
+using System.Text;
namespace TVRename
{
@@ -25,6 +26,8 @@ public enum MissingFolderBehavior
public bool Quit { get; }
public bool ForceRecover { get; }
public bool Scan { get; }
+ public bool QuickScan { get; }
+ public bool RecentScan { get; }
public bool DoAll { get; }
public bool Unattended { get; }
public string UserFilePath { get; }
@@ -41,6 +44,8 @@ public CommandLineArgs(ReadOnlyCollection args)
this.ForceRecover = args.Contains("/recover", StringComparer.OrdinalIgnoreCase);
this.DoAll = args.Contains("/doall", StringComparer.OrdinalIgnoreCase);
this.Scan = args.Contains("/scan", StringComparer.OrdinalIgnoreCase);
+ this.QuickScan = args.Contains("/quickscan", StringComparer.OrdinalIgnoreCase);
+ this.RecentScan = args.Contains("/recentscan", StringComparer.OrdinalIgnoreCase);
this.Unattended = args.Contains("/unattended", StringComparer.OrdinalIgnoreCase);
this.UserFilePath = args.Where(a => a.StartsWith("/userfilepath:", StringComparison.OrdinalIgnoreCase)).Select(a => a.Substring(a.IndexOf(":", StringComparison.Ordinal) + 1)).FirstOrDefault();
@@ -58,5 +63,31 @@ public CommandLineArgs(ReadOnlyCollection args)
this.MissingFolder = MissingFolderBehavior.Ask;
}
}
+
+ public static string Helptext()
+ {
+ StringBuilder output = new StringBuilder();
+ output.AppendLine("/scan will Tell TV Rename to run a scan");
+ output.AppendLine("/quickscan will scan shows most likely to need an update: http://www.tvrename.com/userguide#scan");
+ output.AppendLine("/recentscan will scan recent shows: http://www.tvrename.com/userguide#scan");
+ output.AppendLine("/doall Tell TV Rename execute all the actions it can.");
+ output.AppendLine("/quit Tell a running TV Rename session to exit.");
+ output.AppendLine("");
+ output.AppendLine("/hide will hide the UI");
+ output.AppendLine("/unattended same as /hide");
+ output.AppendLine("");
+ output.AppendLine("/recover will Recover will load a dialog box that enables the user to recover a prior TVDB.xml or TVRenameSettings.xml file");
+ output.AppendLine("/userfilepath:BLAH Sets a custom folder path for the settings files.");
+ output.AppendLine("/createmissing will Create folders if they are missing.");
+ output.AppendLine("/ignoremissing will Ignore missing folders.");
+ output.AppendLine("/norenamecheck will Allows a request to an existing TV Rename session to scan without renaming.");
+ output.AppendLine("");
+ output.AppendLine("Further information is available at http://www.tvrename.com/cmd-line");
+
+ return output.ToString();
+
+
+ }
}
}
+
diff --git a/TVRename#/App/Program.cs b/TVRename#/App/Program.cs
index 7514b2949..48dde3d56 100644
--- a/TVRename#/App/Program.cs
+++ b/TVRename#/App/Program.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.ObjectModel;
+using System.Linq;
using System.Threading;
using System.Windows.Forms;
using TVRename.Ipc;
@@ -28,6 +29,11 @@ private static void Main(string[] args)
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(GlobalExceptionHandler);
+ if (args.Contains("/?", StringComparer.OrdinalIgnoreCase))
+ {
+ Logger.Info(CommandLineArgs.Helptext());
+ Console.WriteLine(CommandLineArgs.Helptext());
+ }
// Check if an application instance is already running
Mutex mutex = new Mutex(true, "TVRename", out bool newInstance);
@@ -35,7 +41,7 @@ private static void Main(string[] args)
{
// Already running
- Logger.Warn("An instance is alrady running");
+ Logger.Warn("An instance is already running");
// Create an IPC channel to the existing instance
RemoteClient.Proxy();
@@ -72,8 +78,11 @@ private static void Main(string[] args)
// TODO: Unify command line handling between here and in UI.cs (ProcessArgs). Just send in clargs via IPC?
- // DoAll implies Scan
- if (clargs.DoAll || clargs.Scan) ipc.Scan();
+
+ if (clargs.Scan) ipc.Scan();
+
+ if (clargs.QuickScan) ipc.QuickScan();
+ if (clargs.RecentScan) ipc.RecentScan();
if (clargs.DoAll) ipc.ProcessAll();
diff --git a/TVRename#/DownloadIdentifers/DownloadXBMCImages.cs b/TVRename#/DownloadIdentifers/DownloadXBMCImages.cs
index 7c94d0679..9a58248e6 100644
--- a/TVRename#/DownloadIdentifers/DownloadXBMCImages.cs
+++ b/TVRename#/DownloadIdentifers/DownloadXBMCImages.cs
@@ -171,7 +171,7 @@ public override ItemList ProcessEpisode(ProcessedEpisode dbep, FileInfo filo, bo
string foldername = filo.DirectoryName;
string filename =
TVSettings.Instance.FilenameFriendly(
- TVSettings.Instance.NamingStyle.GetTargetEpisodeName(sourceEp,dbep.SI.ShowName));
+ TVSettings.Instance.NamingStyle.GetTargetEpisodeName(sourceEp,dbep.SI.ShowName, dbep.SI.GetTimeZone()));
ActionDownload b = DoEpisode(dbep.SI,sourceEp,new FileInfo(foldername+"/"+filename), ".jpg", forceRefresh);
if (b != null) theActionList.Add(b);
}
diff --git a/TVRename#/Forms/AddEditShow.cs b/TVRename#/Forms/AddEditShow.cs
index 955a73e94..4ddafe00c 100644
--- a/TVRename#/Forms/AddEditShow.cs
+++ b/TVRename#/Forms/AddEditShow.cs
@@ -27,7 +27,6 @@ namespace TVRename
///
public partial class AddEditShow : Form
{
- public string ShowTimeZone;
private ShowItem mSI;
private TheTVDBCodeFinder mTCCF;
@@ -43,6 +42,7 @@ public AddEditShow(ShowItem si)
this.cbTimeZone.Items.Add(s);
this.cbTimeZone.EndUpdate();
+ this.cbTimeZone.Text = si.ShowTimeZone;
this.mTCCF = new TheTVDBCodeFinder(si.TVDBCode != -1 ? si.TVDBCode.ToString() : "");
this.mTCCF.Dock = DockStyle.Fill;
@@ -72,11 +72,6 @@ public AddEditShow(ShowItem si)
this.chkPadTwoDigits.Checked = si.PadSeasonToTwoDigits;
- this.ShowTimeZone = ((si == null) || (si.TheSeries() == null))
- ? TimeZone.DefaultTimeZone()
- : si.TheSeries().ShowTimeZone;
-
- this.cbTimeZone.Text = this.ShowTimeZone;
this.chkDVDOrder.Checked = si.DVDOrder;
this.cbIncludeFuture.Checked = si.ForceCheckFuture;
this.cbIncludeNoAirdate.Checked = si.ForceCheckNoAirdate;
@@ -157,11 +152,10 @@ private void SetmSI()
{
int code = this.mTCCF.SelectedCode();
- string tz = (this.cbTimeZone.SelectedItem != null) ? this.cbTimeZone.SelectedItem.ToString() : "";
this.mSI.CustomShowName = this.txtCustomShowName.Text;
this.mSI.UseCustomShowName = this.chkCustomShowName.Checked;
- this.ShowTimeZone = tz; //TODO: move to somewhere else. make timezone manager for tvdb?
+ this.mSI.ShowTimeZone = cbTimeZone.SelectedItem?.ToString() ?? TVRename.TimeZone.DefaultTimeZone();
this.mSI.ShowNextAirdate = this.chkShowNextAirdate.Checked;
this.mSI.PadSeasonToTwoDigits = this.chkPadTwoDigits.Checked;
this.mSI.TVDBCode = code;
diff --git a/TVRename#/Forms/CustomNameDesigner.cs b/TVRename#/Forms/CustomNameDesigner.cs
index 9115e7c3a..7336d7468 100644
--- a/TVRename#/Forms/CustomNameDesigner.cs
+++ b/TVRename#/Forms/CustomNameDesigner.cs
@@ -84,23 +84,16 @@ private void FillExamples()
string fn = TVSettings.Instance.FilenameFriendly(this.CN.NameForExt(pe));
lvi.Text = fn;
- bool ok = false;
- bool ok1 = false;
- bool ok2 = false;
-
- //TODO: Do we still need this check, MarkSummerville
- if (fn.Length < 255)
- {
- ok = TVDoc.FindSeasEp(new FileInfo(fn + ".avi"), out int seas, out int ep, pe.SI);
- ok1 = ok && (seas == pe.SeasonNumber);
- ok2 = ok && (ep == pe.EpNum);
- string pre1 = ok1 ? "" : "* ";
- string pre2 = ok2 ? "" : "* ";
-
- lvi.SubItems.Add(pre1 + ((seas != -1) ? seas.ToString() : ""));
- lvi.SubItems.Add(pre2 + ((ep != -1) ? ep.ToString() : ""));
- lvi.Tag = pe;
- }
+ bool ok = TVDoc.FindSeasEp(new FileInfo(fn + ".avi"), out int seas, out int ep, pe.SI);
+ bool ok1 = ok && (seas == pe.SeasonNumber);
+ bool ok2 = ok && (ep == pe.EpNum);
+ string pre1 = ok1 ? "" : "* ";
+ string pre2 = ok2 ? "" : "* ";
+
+ lvi.SubItems.Add(pre1 + ((seas != -1) ? seas.ToString() : ""));
+ lvi.SubItems.Add(pre2 + ((ep != -1) ? ep.ToString() : ""));
+ lvi.Tag = pe;
+
if (!ok || !ok1 || !ok2)
lvi.BackColor = Helpers.WarningColor();
this.lvTest.Items.Add(lvi);
diff --git a/TVRename#/Forms/UI.cs b/TVRename#/Forms/UI.cs
index e63b7e9bb..640063c65 100644
--- a/TVRename#/Forms/UI.cs
+++ b/TVRename#/Forms/UI.cs
@@ -214,9 +214,9 @@ protected void LessBusy()
private void SetupIPC()
{
- this.AFMFullScan += this.ProcessAll;
- this.AFMQuickScan += this.ScanQuick;
- this.AFMRecentScan += this.ScanRecent;
+ this.AFMFullScan += this.Scan;
+ this.AFMQuickScan += this.QuickScan;
+ this.AFMRecentScan += this.RecentScan;
this.AFMDoAll += this.ProcessAll;
}
@@ -236,8 +236,12 @@ public void ProcessArgs()
{
// TODO: Unify command line handling between here and in Program.cs
- if (this.mDoc.Args.Scan || this.mDoc.Args.DoAll) // doall implies scan
+ if (this.mDoc.Args.Scan)
this.Scan();
+ if (this.mDoc.Args.QuickScan )
+ this.QuickScan();
+ if (this.mDoc.Args.RecentScan )
+ this.RecentScan();
if (this.mDoc.Args.DoAll)
this.ProcessAll();
if (this.mDoc.Args.Quit || this.mDoc.Args.Hide)
@@ -2373,7 +2377,7 @@ public TreeNode AddShowItemToTree(ShowItem si)
{
Color nodeColor =
TVSettings.Instance.ShowStatusColors.GetEntry(true, false,
- ser.Seasons[snum].Status.ToString());
+ ser.Seasons[snum].Status(si.GetTimeZone()).ToString());
if (!nodeColor.IsEmpty)
n2.ForeColor = nodeColor;
}
@@ -2492,12 +2496,11 @@ private void bnMyShowsAdd_Click(object sender, System.EventArgs e)
{
this.mDoc.GetShowItems(true).Add(si);
this.mDoc.UnlockShowItems();
- SeriesInfo ser = TheTVDB.Instance.GetSeries(si.TVDBCode);
- if (ser != null)
- ser.ShowTimeZone = aes.ShowTimeZone;
+
this.ShowAddedOrEdited(true);
this.SelectShow(si);
- logger.Info("Added new show called {0}", ser.Name);
+
+ logger.Info("Added new show called {0}", si.ShowName);
}
else logger.Info("Cancelled adding new show");
@@ -2596,11 +2599,10 @@ private void EditShow(ShowItem si)
if (dr == System.Windows.Forms.DialogResult.OK)
{
- if (ser != null)
- ser.ShowTimeZone = aes.ShowTimeZone; // TODO: move into AddEditShow
-
this.ShowAddedOrEdited(si.TVDBCode != oldCode);
this.SelectShow(si);
+
+ logger.Info("Modified show called {0}", si.ShowName);
}
this.LessBusy();
@@ -2911,7 +2913,8 @@ public void Scan()
this.mDoc.ExportMissingXML(); //Save missing shows to XML
}
- private void ScanRecent()
+
+ public void RecentScan()
{
Scan(this.mDoc.getRecentShows());
}
@@ -2927,7 +2930,7 @@ private void Scan(List shows)
this.FillActionList();
}
- private void ScanQuick()
+ public void QuickScan()
{
logger.Info("*******************************");
logger.Info("Starting QuickScan...");
@@ -3085,7 +3088,7 @@ private void FillActionList()
private void bnActionAction_Click(object sender, System.EventArgs e)
{
- this.ActionAction(true);
+ ProcessAll();
}
public void ProcessAll()
@@ -3559,9 +3562,9 @@ private void bnHideHTMLPanel_Click(object sender, EventArgs e)
}
}
- private void bnActionRecentCheck_Click(object sender, EventArgs e) => this.ScanRecent();
+ private void bnActionRecentCheck_Click(object sender, EventArgs e) => this.RecentScan();
- private void btnActionQuickScan_Click(object sender, EventArgs e) => this.ScanQuick();
+ private void btnActionQuickScan_Click(object sender, EventArgs e) => this.QuickScan();
private void btnFilter_Click(object sender, EventArgs e)
{
@@ -3691,10 +3694,10 @@ private void RunAutoScan(string scanType)
Scan();
break;
case TVRename.TVSettings.ScanType.Recent:
- ScanRecent();
+ RecentScan();
break;
case TVRename.TVSettings.ScanType.Quick:
- ScanQuick();
+ QuickScan();
break;
}
diff --git a/TVRename#/Ipc/IRemoteActions.cs b/TVRename#/Ipc/IRemoteActions.cs
index bcc837f18..b811cbf0f 100644
--- a/TVRename#/Ipc/IRemoteActions.cs
+++ b/TVRename#/Ipc/IRemoteActions.cs
@@ -16,6 +16,17 @@ internal interface IRemoteActions
///
void Scan();
+ ///
+ /// Scans all files.
+ ///
+ void QuickScan();
+
+ ///
+ /// Scans all files.
+ ///
+ void RecentScan();
+
+
///
/// Processes all file tasks.
///
diff --git a/TVRename#/Ipc/RemoteClient.cs b/TVRename#/Ipc/RemoteClient.cs
index a477a27a6..973161d4c 100644
--- a/TVRename#/Ipc/RemoteClient.cs
+++ b/TVRename#/Ipc/RemoteClient.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Ipc;
@@ -41,7 +42,11 @@ public static void Bind(UI form, TVDoc settings)
ui = form;
doc = settings;
- ChannelServices.RegisterChannel(new IpcServerChannel(IpcChannel), true);
+ Hashtable channelProperties = new Hashtable {{"exclusiveAddressUse", false}, {"portName", IpcChannel}};
+
+ IpcServerChannel serverChannel = new IpcServerChannel(channelProperties,null);
+ ChannelServices.RegisterChannel(serverChannel, true);
+
RemotingConfiguration.RegisterWellKnownServiceType(typeof(RemoteClient), IpcService, WellKnownObjectMode.Singleton);
}
@@ -98,8 +103,23 @@ public void Scan()
}
///
- /// Processes all file tasks.
+ /// Scans all recent files.
+ ///
+ public void RecentScan()
+ {
+ ui?.BeginInvoke((MethodInvoker)ui.RecentScan);
+ }
+
+ ///
+ /// Scans all missing recent episodes plus any files in download directory.
///
+ public void QuickScan()
+ {
+ ui?.BeginInvoke((MethodInvoker)ui.QuickScan);
+ }
+ ///
+ /// Processes all file tasks.
+ ///
public void ProcessAll()
{
ui?.BeginInvoke((MethodInvoker)ui.ProcessAll);
diff --git a/TVRename#/ItemsAndActions/ActionNFO.cs b/TVRename#/ItemsAndActions/ActionNFO.cs
index 28cb608b4..5defb17c4 100644
--- a/TVRename#/ItemsAndActions/ActionNFO.cs
+++ b/TVRename#/ItemsAndActions/ActionNFO.cs
@@ -145,7 +145,7 @@ private void writeEpisodeDetailsFor(Episode episode, XmlWriter writer,bool multi
ShowItem episodeSi = this.Episode.SI??this.SI;
string filename =
TVSettings.Instance.FilenameFriendly(
- TVSettings.Instance.NamingStyle.GetTargetEpisodeName(episode, episodeSi.ShowName));
+ TVSettings.Instance.NamingStyle.GetTargetEpisodeName(episode,episodeSi.ShowName, episodeSi.GetTimeZone()));
string thumbFilename = filename + ".jpg";
XMLHelper.WriteElementToXML(writer, "thumb",thumbFilename);
diff --git a/TVRename#/Settings/CustomName.cs b/TVRename#/Settings/CustomName.cs
index 6efee2ed2..29101718f 100644
--- a/TVRename#/Settings/CustomName.cs
+++ b/TVRename#/Settings/CustomName.cs
@@ -82,7 +82,7 @@ public string NameForExt(ProcessedEpisode pe, string extension = "", int folderN
return r;
}
- public string GetTargetEpisodeName(Episode ep, string showname, bool urlEncode = false )
+ public string GetTargetEpisodeName(Episode ep, string showname,TimeZone tz, bool urlEncode = false )
{
//note this is for an Episode and not a ProcessedEpisode
String name = this.StyleString;
@@ -98,7 +98,7 @@ public string GetTargetEpisodeName(Episode ep, string showname, bool urlEncode =
name = name.ReplaceInsensitive("{Number}", "");
name = name.ReplaceInsensitive("{Number:2}", "");
name = name.ReplaceInsensitive("{Number:3}", "");
- DateTime? airdt = ep.GetAirDateDT(false);
+ DateTime? airdt = ep.GetAirDateDT(tz);
if (airdt != null)
{
DateTime dt = (DateTime)airdt;
diff --git a/TVRename#/Settings/ShowsAndEpisodes.cs b/TVRename#/Settings/ShowsAndEpisodes.cs
index d1e636632..6be8853fe 100644
--- a/TVRename#/Settings/ShowsAndEpisodes.cs
+++ b/TVRename#/Settings/ShowsAndEpisodes.cs
@@ -137,8 +137,53 @@ public static int DVDOrderSorter(ProcessedEpisode e1, ProcessedEpisode e2)
return ep1 - ep2;
}
+ public DateTime? GetAirDateDT(bool inLocalTime)
+ {
-}
+ if (!inLocalTime)
+ return GetAirDateDT();
+
+ // do timezone adjustment
+ return GetAirDateDT(this.SI.GetTimeZone());
+ }
+
+ public string HowLong()
+ {
+ DateTime? airsdt = GetAirDateDT(true);
+ if (airsdt == null)
+ return "";
+ DateTime dt = (DateTime)airsdt;
+
+ TimeSpan ts = dt.Subtract(DateTime.Now); // how long...
+ if (ts.TotalHours < 0)
+ return "Aired";
+ else
+ {
+ int h = ts.Hours;
+ if (ts.TotalHours >= 1)
+ {
+ if (ts.Minutes >= 30)
+ h += 1;
+ return ts.Days + "d " + h + "h"; // +ts->Minutes+"m "+ts->Seconds+"s";
+ }
+ else
+ return Math.Round(ts.TotalMinutes) + "min";
+ }
+ }
+
+ public string DayOfWeek()
+ {
+ DateTime? dt = GetAirDateDT(true);
+ return (dt != null) ? dt.Value.ToString("ddd") : "-";
+ }
+
+ public string TimeOfDay()
+ {
+ DateTime? dt = GetAirDateDT(true);
+ return (dt != null) ? dt.Value.ToString("t") : "-";
+ }
+
+ }
public class ShowItem
{
@@ -154,11 +199,11 @@ public class ShowItem
public bool DoRename;
public bool ForceCheckFuture;
public bool ForceCheckNoAirdate;
- public System.Collections.Generic.List IgnoreSeasons;
- public System.Collections.Generic.Dictionary> ManualFolderLocations;
+ public List IgnoreSeasons;
+ public Dictionary> ManualFolderLocations;
public bool PadSeasonToTwoDigits;
- public System.Collections.Generic.Dictionary> SeasonEpisodes; // built up by applying rules.
- public System.Collections.Generic.Dictionary> SeasonRules;
+ public Dictionary> SeasonEpisodes; // built up by applying rules.
+ public Dictionary> SeasonRules;
public bool ShowNextAirdate;
public int TVDBCode;
public bool UseCustomShowName;
@@ -167,33 +212,48 @@ public class ShowItem
public bool UseCustomSearchURL;
public String CustomSearchURL;
- private DateTime? bannersLastUpdatedOnDisk;
- public DateTime? BannersLastUpdatedOnDisk
- {
- get
- {
- return bannersLastUpdatedOnDisk;
- }
- set
- {
- bannersLastUpdatedOnDisk = value;
- }
- }
+ public String ShowTimeZone;
+ private TimeZone SeriesTZ;
+ private string LastFiguredTZ;
+
+
+ public DateTime? BannersLastUpdatedOnDisk { get; set; }
public ShowItem()
{
- this.SetDefaults();
+ SetDefaults();
}
public ShowItem(int tvDBCode)
{
- this.SetDefaults();
+ SetDefaults();
this.TVDBCode = tvDBCode;
}
+ private void FigureOutTimeZone()
+ {
+ string tzstr = this.ShowTimeZone;
+
+ if (string.IsNullOrEmpty(tzstr))
+ tzstr = TimeZone.DefaultTimeZone();
+
+ this.SeriesTZ = TimeZone.TimeZoneFor(tzstr);
+
+ this.LastFiguredTZ = tzstr;
+ }
+
+ public TimeZone GetTimeZone()
+ {
+ // we cache the timezone info, as the fetching is a bit slow, and we do this a lot
+ if (this.LastFiguredTZ != this.ShowTimeZone)
+ this.FigureOutTimeZone();
+
+ return this.SeriesTZ;
+ }
+
public ShowItem(XmlReader reader)
{
- this.SetDefaults();
+ SetDefaults();
reader.Read();
if (reader.Name != "ShowItem")
@@ -238,6 +298,8 @@ public ShowItem(XmlReader reader)
this.UseCustomSearchURL = reader.ReadElementContentAsBoolean();
else if (reader.Name == "CustomSearchURL")
this.CustomSearchURL = reader.ReadElementContentAsString();
+ else if (reader.Name == "TimeZone")
+ this.ShowTimeZone = reader.ReadElementContentAsString();
else if (reader.Name == "ForceCheckAll") // removed 2.2.0b2
this.ForceCheckNoAirdate = this.ForceCheckFuture = reader.ReadElementContentAsBoolean();
else if (reader.Name == "ForceCheckFuture")
@@ -318,7 +380,7 @@ public ShowItem(XmlReader reader)
if ((reader.Name == "Folder") && reader.IsStartElement())
{
string ff = reader.GetAttribute("Location");
- if (this.AutoFolderNameForSeason(snum) != ff)
+ if (AutoFolderNameForSeason(snum) != ff)
this.ManualFolderLocations[snum].Add(ff);
}
reader.Read();
@@ -348,7 +410,7 @@ public string ShowName
{
if (this.UseCustomShowName)
return this.CustomShowName;
- SeriesInfo ser = this.TheSeries();
+ SeriesInfo ser = TheSeries();
if (ser != null)
return ser.Name;
return "<" + this.TVDBCode + " not downloaded>";
@@ -379,7 +441,7 @@ public List getSimplifiedPossibleShowNames()
public string ShowStatus
{
get{
- SeriesInfo ser = this.TheSeries();
+ SeriesInfo ser = TheSeries();
if (ser != null ) return ser.getStatus();
return "Unknown";
}
@@ -397,17 +459,17 @@ public ShowAirStatus SeasonsAirStatus
{
get
{
- if (HasSeasonsAndEpisodes)
+ if (this.HasSeasonsAndEpisodes)
{
- if (HasAiredEpisodes && !HasUnairedEpisodes)
+ if (this.HasAiredEpisodes && !this.HasUnairedEpisodes)
{
return ShowAirStatus.Aired;
}
- else if (HasUnairedEpisodes && !HasAiredEpisodes)
+ else if (this.HasUnairedEpisodes && !this.HasAiredEpisodes)
{
return ShowAirStatus.NoneAired;
}
- else if (HasAiredEpisodes && HasUnairedEpisodes)
+ else if (this.HasAiredEpisodes && this.HasUnairedEpisodes)
{
return ShowAirStatus.PartiallyAired;
}
@@ -424,13 +486,12 @@ public ShowAirStatus SeasonsAirStatus
}
}
- bool HasSeasonsAndEpisodes
+ private bool HasSeasonsAndEpisodes
{
- get
- {
- if (this.TheSeries() != null && this.TheSeries().Seasons != null && this.TheSeries().Seasons.Count > 0)
+ get {
+ if (TheSeries() != null && TheSeries().Seasons != null && TheSeries().Seasons.Count > 0)
{
- foreach (KeyValuePair s in this.TheSeries().Seasons)
+ foreach (KeyValuePair s in TheSeries().Seasons)
{
if(this.IgnoreSeasons.Contains(s.Key))
continue;
@@ -441,57 +502,51 @@ bool HasSeasonsAndEpisodes
}
}
return false;
- }
+ }
}
- bool HasUnairedEpisodes
+ private bool HasUnairedEpisodes
{
get
{
- if (HasSeasonsAndEpisodes)
+ if (this.HasSeasonsAndEpisodes)
{
- foreach (KeyValuePair s in this.TheSeries().Seasons)
+ foreach (KeyValuePair s in TheSeries().Seasons)
{
- if(this.IgnoreSeasons.Contains(s.Key))
+ if (this.IgnoreSeasons.Contains(s.Key))
continue;
- if (s.Value.Status == Season.SeasonStatus.NoneAired || s.Value.Status == Season.SeasonStatus.PartiallyAired)
+ if (s.Value.Status(GetTimeZone()) == Season.SeasonStatus.NoneAired ||
+ s.Value.Status(GetTimeZone()) == Season.SeasonStatus.PartiallyAired)
{
return true;
}
}
}
+
return false;
}
}
- bool HasAiredEpisodes
+ private bool HasAiredEpisodes
{
- get
- {
- if (HasSeasonsAndEpisodes)
- {
- foreach (KeyValuePair s in this.TheSeries().Seasons)
+ get{
+ if (!this.HasSeasonsAndEpisodes) return false;
+
+ foreach (KeyValuePair s in TheSeries().Seasons)
{
if(this.IgnoreSeasons.Contains(s.Key))
continue;
- if (s.Value.Status == Season.SeasonStatus.PartiallyAired || s.Value.Status == Season.SeasonStatus.Aired)
+ if (s.Value.Status(GetTimeZone()) == Season.SeasonStatus.PartiallyAired || s.Value.Status(GetTimeZone()) == Season.SeasonStatus.Aired)
{
return true;
}
}
- }
- return false;
- }
+ return false;
+ }
}
- public string[] Genres
- {
- get
- {
- return this.TheSeries()?.GetGenres();
- }
- }
+ public string[] Genres => TheSeries()?.GetGenres();
public void SetDefaults()
{
@@ -515,20 +570,20 @@ public void SetDefaults()
this.DoMissingCheck = true;
this.CountSpecials = false;
this.DVDOrder = false;
- CustomSearchURL = "";
- UseCustomSearchURL = false;
- ForceCheckNoAirdate = false;
- ForceCheckFuture = false;
+ this.CustomSearchURL = "";
+ this.UseCustomSearchURL = false;
+ this.ForceCheckNoAirdate = false;
+ this.ForceCheckFuture = false;
this.BannersLastUpdatedOnDisk = null; //assume that the baners are old and have expired
+ this.ShowTimeZone = TVRename.TimeZone.DefaultTimeZone(); // default, is correct for most shows
+
+ this.LastFiguredTZ = "";
}
public List RulesForSeason(int n)
{
- if (this.SeasonRules.ContainsKey(n))
- return this.SeasonRules[n];
- else
- return null;
+ return this.SeasonRules.ContainsKey(n) ? this.SeasonRules[n] : null;
}
public string AutoFolderNameForSeason(int n)
@@ -593,6 +648,7 @@ public void WriteXMLSettings(XmlWriter writer)
XMLHelper.WriteElementToXML(writer,"UseSequentialMatch",this.UseSequentialMatch);
XMLHelper.WriteElementToXML(writer,"PadSeasonToTwoDigits",this.PadSeasonToTwoDigits);
XMLHelper.WriteElementToXML(writer, "BannersLastUpdatedOnDisk", this.BannersLastUpdatedOnDisk);
+ XMLHelper.WriteElementToXML(writer, "TimeZone", this.ShowTimeZone);
writer.WriteStartElement("IgnoreSeasons");
@@ -657,12 +713,12 @@ public static List ProcessedListFromEpisodes(List el,
public Dictionary> AllFolderLocations()
{
- return this.AllFolderLocations( true);
+ return AllFolderLocations( true);
}
public Dictionary> AllFolderLocationsEpCheck(bool checkExist)
{
- return this.AllFolderLocations(true, checkExist);
+ return AllFolderLocations(true, checkExist);
}
public Dictionary> AllFolderLocations(bool manualToo,bool checkExist=true)
@@ -688,12 +744,12 @@ public Dictionary> AllFolderLocations(bool manualToo,bool chec
if (kvp.Key > highestThereIs)
highestThereIs = kvp.Key;
}
- foreach (int i in SeasonEpisodes.Keys)
+ foreach (int i in this.SeasonEpisodes.Keys)
{
if (this.IgnoreSeasons.Contains(i))
continue;
- string newName = this.AutoFolderNameForSeason(i);
+ string newName = AutoFolderNameForSeason(i);
if ((!string.IsNullOrEmpty(newName)) && (!checkExist ||(Directory.Exists(newName))))
{
if (!fld.ContainsKey(i))
diff --git a/TVRename#/TVRename/TVDoc.cs b/TVRename#/TVRename/TVDoc.cs
index 9d6b001a7..e20c3213c 100644
--- a/TVRename#/TVRename/TVDoc.cs
+++ b/TVRename#/TVRename/TVDoc.cs
@@ -2806,8 +2806,8 @@ private static bool FindSeasEpDateCheck(FileInfo fi, out int seas, out int ep, S
foreach (Episode epi in kvp.Value.Episodes)
{
- DateTime? dt = epi.GetAirDateDT(false); // file will have local timezone date, not ours
- if ((dt == null) || (!dt.HasValue))
+ DateTime? dt = epi.GetAirDateDT(); // file will have local timezone date, not ours
+ if (dt == null)
continue;
TimeSpan closestDate = TimeSpan.MaxValue;
@@ -3025,10 +3025,6 @@ public static bool FindSeasEp(string directory, string filename, out int seas, o
string fullPath = directory + System.IO.Path.DirectorySeparatorChar + filename; // construct full path with sanitised filename
- //TODO:Do we still need this now we have AlphaFS, MarkSummerville
- if ((filename.Length > 256) || (fullPath.Length > 256))
- return false;
-
int leftMostPos = filename.Length;
filename = filename.ToLower() + " ";
diff --git a/TVRename#/TheTVDB/Episode.cs b/TVRename#/TheTVDB/Episode.cs
index b974a34e9..9d708ac5b 100644
--- a/TVRename#/TheTVDB/Episode.cs
+++ b/TVRename#/TheTVDB/Episode.cs
@@ -9,7 +9,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using System.Windows.Forms;
using System.Xml;
namespace TVRename
@@ -20,7 +19,7 @@ public class Episode
public int EpNum;
public int EpisodeID;
public DateTime? FirstAired;
- private System.Collections.Generic.Dictionary Items; // other fields we don't specifically grab
+ private Dictionary Items; // other fields we don't specifically grab
public string Overview;
public string EpisodeRating;
public string EpisodeGuestStars;
@@ -55,16 +54,35 @@ public Episode(Episode O)
this.SeasonID = O.SeasonID;
this.Dirty = O.Dirty;
- this.Items = new System.Collections.Generic.Dictionary();
- foreach (System.Collections.Generic.KeyValuePair i in O.Items)
+ this.Items = new Dictionary();
+ foreach (KeyValuePair i in O.Items)
this.Items.Add(i.Key, i.Value);
}
public Episode(SeriesInfo ser, Season seas)
{
- this.SetDefaults(ser, seas);
+ SetDefaults(ser, seas);
}
+ public DateTime? GetAirDateDT()
+ {
+ if (this.FirstAired == null)
+ return null;
+
+ DateTime fa = (DateTime)this.FirstAired;
+ DateTime? airs = this.TheSeries.AirsTime;
+
+ return new DateTime(fa.Year, fa.Month, fa.Day, airs?.Hour ?? 20, airs?.Minute ?? 0, 0, 0);
+ }
+
+
+ public DateTime? GetAirDateDT(TimeZone tz)
+ {
+ DateTime? dt = GetAirDateDT();
+ if (dt == null) return null;
+
+ return TimeZone.AdjustTZTimeToLocalTime(dt.Value, tz);
+ }
internal IEnumerable> OtherItems()
{
@@ -112,7 +130,6 @@ internal IEnumerable> OtherItems()
}
-
public string DVDEp => getValueAcrossVersions("dvdEpisodeNumber", "DVD_episodenumber", "");
public string AirsBeforeSeason => getValueAcrossVersions("airsBeforeSeason", "airsbefore_season", "");
public string AirsBeforeEpisode => getValueAcrossVersions("airsBeforeEpisode", "airsbefore_episode", "");
@@ -126,7 +143,7 @@ public Episode(SeriesInfo ser, Season seas, XmlReader r, CommandLineArgs args)
try
{
- this.SetDefaults(ser, seas);
+ SetDefaults(ser, seas);
r.Read();
if (r.Name != "Episode")
@@ -218,8 +235,8 @@ public Episode(SeriesInfo ser, Season seas, XmlReader r, CommandLineArgs args)
public Episode(int seriesId, JObject json, JObject jsonInDefaultLang)
{
- this.SetDefaults(null,null);
- this.loadJSON(seriesId, json, jsonInDefaultLang);
+ SetDefaults(null,null);
+ loadJSON(seriesId, json, jsonInDefaultLang);
}
public Episode(int seriesId,JObject r)
@@ -229,9 +246,9 @@ public Episode(int seriesId,JObject r)
// blah blah
//
- this.SetDefaults(null, null);
+ SetDefaults(null, null);
- this.loadJSON(seriesId,r);
+ loadJSON(seriesId,r);
}
private void loadJSON(int seriesId, JObject bestLanguageR, JObject backupLanguageR)
{
@@ -300,7 +317,7 @@ private void loadJSON(int seriesId, JObject r)
if ((string)r["airedSeasonID"] != null) { this.SeasonID = (int)r["airedSeasonID"]; }
else
{
- logger.Error("Issue with episode " + EpisodeID + " for series " + seriesId + " no airedSeasonID " );
+ logger.Error("Issue with episode " + this.EpisodeID + " for series " + seriesId + " no airedSeasonID " );
logger.Error(r.ToString());
}
@@ -312,7 +329,7 @@ private void loadJSON(int seriesId, JObject r)
String sn = (string)r["airedSeason"];
if (sn == null) {
- logger.Error("Issue with episode " + EpisodeID + " for series " + seriesId + " airedSeason = null");
+ logger.Error("Issue with episode " + this.EpisodeID + " for series " + seriesId + " airedSeason = null");
logger.Error(r.ToString());
}
else { int.TryParse(sn, out this.ReadSeasonNum); }
@@ -346,11 +363,11 @@ public string Name
{
get
{
- if ((this.mName == null) || (string.IsNullOrEmpty(this.mName)))
+ if (string.IsNullOrEmpty(this.mName))
return "Episode " + this.EpNum;
return this.mName;
}
- set { this.mName = value; }
+ set => this.mName = value;
}
public int SeasonNumber
@@ -376,19 +393,19 @@ public string GetFilename()
public string[] GetGuestStars()
{
- String guest = this.EpisodeGuestStars;
+ string guest = this.EpisodeGuestStars;
if (!string.IsNullOrEmpty(guest))
{
return guest.Split('|');
}
- return new String[] { };
+ return new string[] { };
}
- string getValueAcrossVersions(string oldTag, string newTag, string defaultValue)
+ private string getValueAcrossVersions(string oldTag, string newTag, string defaultValue)
{
//Need to cater for new and old style tags (TVDB interface v1 vs v2)
if (this.Items.ContainsKey(oldTag)) return this.Items[oldTag];
@@ -401,7 +418,7 @@ public bool OK()
bool returnVal = (this.SeriesID != -1) && (this.EpisodeID != -1) && (this.EpNum != -1) && (this.SeasonID != -1) && (this.ReadSeasonNum != -1);
if (!returnVal)
{
- logger.Warn("Issue with episode " + EpisodeID + " for series " + SeriesID + " for EpNum " + EpNum + " for SeasonID " + SeasonID + " for ReadSeasonNum " + ReadSeasonNum);
+ logger.Warn("Issue with episode " + this.EpisodeID + " for series " + this.SeriesID + " for EpNum " + this.EpNum + " for SeasonID " + this.SeasonID + " for ReadSeasonNum " + this.ReadSeasonNum);
}
return returnVal;
@@ -409,7 +426,7 @@ public bool OK()
public void SetDefaults(SeriesInfo ser, Season seas)
{
- this.Items = new System.Collections.Generic.Dictionary();
+ this.Items = new Dictionary();
this.TheSeason = seas;
this.TheSeries = ser;
@@ -428,58 +445,7 @@ public void SetDefaults(SeriesInfo ser, Season seas)
this.Dirty = false;
}
- public DateTime? GetAirDateDT(bool inLocalTime)
- {
- if (this.FirstAired == null)
- return null;
-
- DateTime fa = (DateTime) this.FirstAired;
- DateTime? airs = this.TheSeries.AirsTime;
-
- DateTime dt = new DateTime(fa.Year, fa.Month, fa.Day, (airs != null) ? airs.Value.Hour : 20, (airs != null) ? airs.Value.Minute : 0, 0, 0);
-
- if (!inLocalTime)
- return dt;
-
- // do timezone adjustment
- return TimeZone.AdjustTZTimeToLocalTime(dt, this.TheSeries.GetTimeZone());
- }
-
- public string HowLong()
- {
- DateTime? airsdt = this.GetAirDateDT(true);
- if (airsdt == null)
- return "";
- DateTime dt = (DateTime) airsdt;
-
- TimeSpan ts = dt.Subtract(DateTime.Now); // how long...
- if (ts.TotalHours < 0)
- return "Aired";
- else
- {
- int h = ts.Hours;
- if (ts.TotalHours >= 1)
- {
- if (ts.Minutes >= 30)
- h += 1;
- return ts.Days + "d " + h + "h"; // +ts->Minutes+"m "+ts->Seconds+"s";
- }
- else
- return System.Math.Round(ts.TotalMinutes) + "min";
- }
- }
-
- public string DayOfWeek()
- {
- DateTime? dt = this.GetAirDateDT(true);
- return (dt != null) ? dt.Value.ToString("ddd") : "-";
- }
- public string TimeOfDay()
- {
- DateTime? dt = this.GetAirDateDT(true);
- return (dt != null) ? dt.Value.ToString("t") : "-";
- }
public void SetSeriesSeason(SeriesInfo ser, Season seas)
{
@@ -515,7 +481,7 @@ public void WriteXml(XmlWriter writer)
"GuestStars","guestStars","director","directors","EpisodeDirector","Writer","Writers","id","seasonid","Overview","Rating"
};
- foreach (System.Collections.Generic.KeyValuePair kvp in this.Items)
+ foreach (KeyValuePair kvp in this.Items)
{
if (!skip.Contains(kvp.Key))
{
diff --git a/TVRename#/TheTVDB/Season.cs b/TVRename#/TheTVDB/Season.cs
index 3ebc28bb7..4a7619cc1 100644
--- a/TVRename#/TheTVDB/Season.cs
+++ b/TVRename#/TheTVDB/Season.cs
@@ -32,21 +32,19 @@ public Season(SeriesInfo theSeries, int number, int seasonid)
this.Episodes = new System.Collections.Generic.List();
}
- public SeasonStatus Status
+ public SeasonStatus Status(TimeZone tz)
{
- get
- {
if (HasEpisodes)
{
- if (HasAiredEpisodes && !HasUnairedEpisodes)
+ if (HasAiredEpisodes(tz) && !HasUnairedEpisodes(tz))
{
return SeasonStatus.Aired;
}
- else if (HasAiredEpisodes && HasUnairedEpisodes)
+ else if (HasAiredEpisodes(tz) && HasUnairedEpisodes(tz))
{
return SeasonStatus.PartiallyAired;
}
- else if (!HasAiredEpisodes && HasUnairedEpisodes)
+ else if (!HasAiredEpisodes(tz) && HasUnairedEpisodes(tz))
{
return SeasonStatus.NoneAired;
}
@@ -61,53 +59,40 @@ public SeasonStatus Status
{
return SeasonStatus.NoEpisodes;
}
- }
}
- bool HasEpisodes
- {
- get
- {
- return this.Episodes != null && this.Episodes.Count > 0;
- }
- }
+ private bool HasEpisodes => this.Episodes != null && this.Episodes.Count > 0;
- bool HasUnairedEpisodes
+ private bool HasUnairedEpisodes(TimeZone tz)
{
- get
- {
if (HasEpisodes)
{
foreach (Episode e in this.Episodes)
{
- if (e.GetAirDateDT(true).HasValue)
+ if (e.GetAirDateDT(tz).HasValue)
{
- if (e.GetAirDateDT(true).Value > System.DateTime.Now)
+ if (e.GetAirDateDT(tz).Value > System.DateTime.Now)
return true;
}
}
}
return false;
- }
}
- bool HasAiredEpisodes
+ private bool HasAiredEpisodes(TimeZone tz)
{
- get
- {
if (HasEpisodes)
{
foreach (Episode e in this.Episodes)
{
- if (e.GetAirDateDT(true).HasValue)
+ if (e.GetAirDateDT(tz).HasValue)
{
- if (e.GetAirDateDT(true).Value < System.DateTime.Now)
+ if (e.GetAirDateDT(tz).Value < System.DateTime.Now)
return true;
}
}
}
return false;
- }
}
diff --git a/TVRename#/TheTVDB/SeriesInfo.cs b/TVRename#/TheTVDB/SeriesInfo.cs
index 09147ac8a..21bf4a343 100644
--- a/TVRename#/TheTVDB/SeriesInfo.cs
+++ b/TVRename#/TheTVDB/SeriesInfo.cs
@@ -8,7 +8,6 @@
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
-using System.Windows.Forms;
using System.Xml;
using System.Runtime.Serialization;
@@ -19,23 +18,22 @@ public class SeriesInfo
public DateTime? AirsTime;
public bool Dirty; // set to true if local info is known to be older than whats on the server
public DateTime? FirstAired;
- public System.Collections.Generic.Dictionary Items; // e.g. Overview, Banner, Poster, etc.
+ public Dictionary Items; // e.g. Overview, Banner, Poster, etc.
public int LanguageId;
- private string LastFiguredTZ;
public string Name;
public bool BannersLoaded;
- public System.Collections.Generic.Dictionary Seasons;
+ public Dictionary Seasons;
private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
//All Banners
- public System.Collections.Generic.Dictionary AllBanners; // All Banners linked by bannerId.
+ public Dictionary AllBanners; // All Banners linked by bannerId.
//Collections of Posters and Banners per season
- private System.Collections.Generic.Dictionary SeasonBanners; // e.g. Dictionary of the best posters per series.
- private System.Collections.Generic.Dictionary SeasonLangBanners; // e.g. Dictionary of the best posters per series in the correct language.
- private System.Collections.Generic.Dictionary SeasonWideBanners; // e.g. Dictionary of the best wide banners per series.
- private System.Collections.Generic.Dictionary SeasonLangWideBanners; // e.g. Dictionary of the best wide banners per series in the correct language.
+ private Dictionary SeasonBanners; // e.g. Dictionary of the best posters per series.
+ private Dictionary SeasonLangBanners; // e.g. Dictionary of the best posters per series in the correct language.
+ private Dictionary SeasonWideBanners; // e.g. Dictionary of the best wide banners per series.
+ private Dictionary SeasonLangWideBanners; // e.g. Dictionary of the best wide banners per series in the correct language.
//best Banner, Poster and Fanart loaded from the images files (in any language)
private int bestSeriesPosterId;
@@ -47,13 +45,11 @@ public class SeriesInfo
private int bestSeriesLangBannerId;
private int bestSeriesLangFanartId;
- private TimeZone SeriesTZ;
-
- public string ShowTimeZone; // set for us by ShowItem
public long Srv_LastUpdated;
public int TVDBCode;
+ public string tempTimeZone;
+
-
public DateTime? LastAiredDate() {
DateTime? returnValue = null;
foreach (Season s in this.Seasons.Values)
@@ -73,22 +69,22 @@ public class SeriesInfo
public SeriesInfo(string name, int id)
{
- this.SetToDefauts();
+ SetToDefauts();
this.Name = name;
this.TVDBCode = id;
}
public SeriesInfo(XmlReader r)
{
- this.SetToDefauts();
- this.LoadXml(r);
+ SetToDefauts();
+ LoadXml(r);
}
public SeriesInfo(JObject json,int langId)
{
- this.SetToDefauts();
+ SetToDefauts();
this.LanguageId = langId;
- this.LoadJSON(json);
+ LoadJSON(json);
if (String.IsNullOrEmpty(this.Name) ){
logger.Warn("Issue with series " + this.TVDBCode );
@@ -98,9 +94,9 @@ public SeriesInfo(JObject json,int langId)
public SeriesInfo(JObject json, JObject jsonInDefaultLang, int langId)
{
- this.SetToDefauts();
+ SetToDefauts();
this.LanguageId = langId;
- this.LoadJSON(json,jsonInDefaultLang);
+ LoadJSON(json,jsonInDefaultLang);
if (String.IsNullOrEmpty(this.Name) ){
logger.Warn("Issue with series " + this.TVDBCode );
logger.Warn(json.ToString());
@@ -110,27 +106,6 @@ public SeriesInfo(JObject json, JObject jsonInDefaultLang, int langId)
}
- private void FigureOutTimeZone()
- {
- string tzstr = this.ShowTimeZone;
-
- if (string.IsNullOrEmpty(tzstr))
- tzstr = TimeZone.DefaultTimeZone();
-
- this.SeriesTZ = TimeZone.TimeZoneFor(tzstr);
-
- this.LastFiguredTZ = tzstr;
- }
-
- public TimeZone GetTimeZone()
- {
- // we cache the timezone info, as the fetching is a bit slow, and we do this a lot
- if (this.LastFiguredTZ != this.ShowTimeZone)
- this.FigureOutTimeZone();
-
- return this.SeriesTZ;
- }
-
public string[] GetActors()
{
String actors = getValueAcrossVersions("Actors","actors","");
@@ -158,11 +133,8 @@ public void setActors(IEnumerable actors)
public void SetToDefauts()
{
- this.ShowTimeZone = TimeZone.DefaultTimeZone(); // default, is correct for most shows
- this.LastFiguredTZ = "";
-
- this.Items = new System.Collections.Generic.Dictionary();
- this.Seasons = new System.Collections.Generic.Dictionary();
+ this.Items = new Dictionary();
+ this.Seasons = new Dictionary();
this.Dirty = false;
@@ -176,11 +148,11 @@ public void SetToDefauts()
public void resetBanners()
{
this.BannersLoaded = false;
- this.AllBanners = new System.Collections.Generic.Dictionary();
- this.SeasonBanners = new System.Collections.Generic.Dictionary();
- this.SeasonLangBanners = new System.Collections.Generic.Dictionary();
- this.SeasonWideBanners = new System.Collections.Generic.Dictionary();
- this.SeasonLangWideBanners = new System.Collections.Generic.Dictionary();
+ this.AllBanners = new Dictionary();
+ this.SeasonBanners = new Dictionary();
+ this.SeasonLangBanners = new Dictionary();
+ this.SeasonWideBanners = new Dictionary();
+ this.SeasonLangWideBanners = new Dictionary();
this.bestSeriesPosterId = -1;
this.bestSeriesBannerId = -1;
@@ -207,7 +179,7 @@ public void Merge(SeriesInfo o, int preferredLanguageId)
if ((!string.IsNullOrEmpty(o.Name)) && betterLanguage)
this.Name = o.Name;
// this.Items.Clear();
- foreach (System.Collections.Generic.KeyValuePair kvp in o.Items)
+ foreach (KeyValuePair kvp in o.Items)
{
// on offer is non-empty text, in a better language
// or text for something we don't have
@@ -290,7 +262,7 @@ public void LoadXml(XmlReader r)
else if ((r.Name == "LanguageId") || (r.Name == "languageId"))
this.LanguageId = r.ReadElementContentAsInt();
else if (r.Name == "TimeZone")
- this.ShowTimeZone = r.ReadElementContentAsString();
+ this.tempTimeZone = r.ReadElementContentAsString();
else if (r.Name == "Airs_Time")
{
this.AirsTime = DateTime.Parse("20:00");
@@ -532,8 +504,7 @@ public void WriteXml(XmlWriter writer)
XMLHelper.WriteElementToXML(writer, "lastupdated", this.Srv_LastUpdated);
XMLHelper.WriteElementToXML(writer, "LanguageId", this.LanguageId);
XMLHelper.WriteElementToXML(writer, "Airs_Time", this.AirsTime );
- XMLHelper.WriteElementToXML(writer, "TimeZone", this.ShowTimeZone);
-
+
if (this.FirstAired != null)
{
XMLHelper.WriteElementToXML(writer, "FirstAired", this.FirstAired.Value.ToString("yyyy-MM-dd"));
@@ -550,7 +521,7 @@ public void WriteXml(XmlWriter writer)
"LanguageId","TimeZone"
};
- foreach (System.Collections.Generic.KeyValuePair kvp in this.Items)
+ foreach (KeyValuePair kvp in this.Items)
{
if (!skip.Contains(kvp.Key))
{
@@ -580,7 +551,7 @@ public string GetSeasonBannerPath(int snum)
//if not then a season specific one is best
//if not then the poster is the fallback
- System.Diagnostics.Debug.Assert(BannersLoaded);
+ System.Diagnostics.Debug.Assert(this.BannersLoaded);
if (this.SeasonLangBanners.ContainsKey(snum))
return this.SeasonLangBanners[snum].BannerPath;
@@ -597,10 +568,10 @@ public string GetSeriesWideBannerPath()
{
//ry the best one we've found with the correct language
- if (bestSeriesLangBannerId != -1) return AllBanners[bestSeriesLangBannerId].BannerPath;
+ if (this.bestSeriesLangBannerId != -1) return this.AllBanners[this.bestSeriesLangBannerId].BannerPath;
//if there are none with the righ tlanguage then try one from another language
- if (bestSeriesBannerId != -1) return AllBanners[bestSeriesBannerId].BannerPath;
+ if (this.bestSeriesBannerId != -1) return this.AllBanners[this.bestSeriesBannerId].BannerPath;
//then choose the one the TVDB recommended _LOWERED IN PRIORITY AFTER LEVERAGE issue - https://github.com/TV-Rename/tvrename/issues/285
if (!string.IsNullOrEmpty(GetItem("banner"))) return GetItem("banner");
@@ -615,10 +586,10 @@ public string GetSeriesPosterPath()
if (!string.IsNullOrEmpty(GetItem("poster"))) return GetItem("poster");
//then try the best one we've found with the correct language
- if (bestSeriesLangPosterId != -1) return AllBanners[bestSeriesLangPosterId].BannerPath;
+ if (this.bestSeriesLangPosterId != -1) return this.AllBanners[this.bestSeriesLangPosterId].BannerPath;
//if there are none with the righ tlanguage then try one from another language
- if (bestSeriesPosterId != -1) return AllBanners[bestSeriesPosterId].BannerPath;
+ if (this.bestSeriesPosterId != -1) return this.AllBanners[this.bestSeriesPosterId].BannerPath;
//give up
return "";
@@ -630,10 +601,10 @@ public string GetSeriesFanartPath()
if (!string.IsNullOrEmpty(GetItem("fanart"))) return GetItem("fanart");
//then try the best one we've found with the correct language
- if (bestSeriesLangFanartId != -1) return AllBanners[bestSeriesLangFanartId].BannerPath;
+ if (this.bestSeriesLangFanartId != -1) return this.AllBanners[this.bestSeriesLangFanartId].BannerPath;
//if there are none with the righ tlanguage then try one from another language
- if (bestSeriesFanartId != -1) return AllBanners[bestSeriesFanartId].BannerPath;
+ if (this.bestSeriesFanartId != -1) return this.AllBanners[this.bestSeriesFanartId].BannerPath;
//give up
return "";
@@ -645,7 +616,7 @@ public string GetSeasonWideBannerPath(int snum)
//if not then a season specific one is best
//if not then the poster is the fallback
- System.Diagnostics.Debug.Assert(BannersLoaded);
+ System.Diagnostics.Debug.Assert(this.BannersLoaded);
if (this.SeasonLangWideBanners.ContainsKey(snum))
return this.SeasonLangWideBanners[snum].BannerPath;
@@ -661,10 +632,10 @@ public string GetSeasonWideBannerPath(int snum)
public void AddOrUpdateBanner(Banner banner)
{
- if (AllBanners.ContainsKey(banner.BannerId)) {
- AllBanners[banner.BannerId] = banner;
+ if (this.AllBanners.ContainsKey(banner.BannerId)) {
+ this.AllBanners[banner.BannerId] = banner;
} else {
- AllBanners.Add(banner.BannerId, banner);
+ this.AllBanners.Add(banner.BannerId, banner);
}
if (banner.isSeasonPoster()) AddOrUpdateSeasonPoster(banner);
@@ -687,7 +658,7 @@ private int GetBestBannerId(Banner selectedBanner, int bestBannerId)
{
if (bestBannerId == -1) return selectedBanner.BannerId;
- if (AllBanners[bestBannerId].Rating < selectedBanner.Rating)
+ if (this.AllBanners[bestBannerId].Rating < selectedBanner.Rating)
{
//update banner - we have found a better one
return selectedBanner.BannerId;
@@ -707,7 +678,7 @@ public void AddOrUpdateWideSeason(Banner banner)
AddUpdateIntoCollections(banner, this.SeasonWideBanners, this.SeasonLangWideBanners);
}
- private void AddUpdateIntoCollections(Banner banner, System.Collections.Generic.Dictionary coll, System.Collections.Generic.Dictionary langColl)
+ private void AddUpdateIntoCollections(Banner banner, Dictionary coll, Dictionary langColl)
{
//update language specific cache if appropriate
if (banner.LanguageId == this.LanguageId)
@@ -720,7 +691,7 @@ private void AddUpdateIntoCollections(Banner banner, System.Collections.Generic.
}
- private void AddUpdateIntoCollection(Banner banner, System.Collections.Generic.Dictionary coll)
+ private void AddUpdateIntoCollection(Banner banner, Dictionary coll)
{
int seasonOfNewBanner = banner.SeasonID;
@@ -740,7 +711,7 @@ private void AddUpdateIntoCollection(Banner banner, System.Collections.Generic.D
internal Episode getEpisode(int seasF, int epF)
{
- foreach ( Season s in Seasons.Values)
+ foreach ( Season s in this.Seasons.Values)
{
if (s.SeasonNumber == seasF)
{
diff --git a/TVRename#/TheTVDB/TheTVDB.cs b/TVRename#/TheTVDB/TheTVDB.cs
index bc952488e..012957784 100644
--- a/TVRename#/TheTVDB/TheTVDB.cs
+++ b/TVRename#/TheTVDB/TheTVDB.cs
@@ -1806,7 +1806,7 @@ public Episode NextAiring(int code)
foreach (Episode e in s.Episodes)
{
- DateTime? adt = e.GetAirDateDT(true);
+ DateTime? adt = e.GetAirDateDT();
if (adt != null)
{
DateTime dt = (DateTime) adt;
diff --git a/TVRename#/Utility/Sorters.cs b/TVRename#/Utility/Sorters.cs
index 01d5d4b84..ee4cdb83c 100644
--- a/TVRename#/Utility/Sorters.cs
+++ b/TVRename#/Utility/Sorters.cs
@@ -50,7 +50,7 @@ public virtual int Compare(Object x, Object y)
try
{
- d1 = ((Episode) ((x as ListViewItem).Tag)).GetAirDateDT(true);
+ d1 = ((ProcessedEpisode) ((x as ListViewItem).Tag)).GetAirDateDT(true);
}
catch
{
@@ -59,7 +59,7 @@ public virtual int Compare(Object x, Object y)
try
{
- d2 = ((Episode) ((y as ListViewItem).Tag)).GetAirDateDT(true);
+ d2 = ((ProcessedEpisode) ((y as ListViewItem).Tag)).GetAirDateDT(true);
}
catch
{
@@ -173,4 +173,4 @@ public virtual int Compare(Object x, Object y)
#endregion
}
-}
\ No newline at end of file
+}