diff --git a/TVRename#/Custom Controls/TheTVDBCodeFinder.cs b/TVRename#/Custom Controls/TheTVDBCodeFinder.cs index 0c3d01bfb..5c95cde09 100644 --- a/TVRename#/Custom Controls/TheTVDBCodeFinder.cs +++ b/TVRename#/Custom Controls/TheTVDBCodeFinder.cs @@ -46,7 +46,9 @@ public void SetHint(string s) this.mInternal = true; this.txtFindThis.Text = s; this.mInternal = false; + Search(); this.DoFind(true); + } public int SelectedCode() @@ -125,6 +127,7 @@ private void DoFind(bool chooseOnlyMatch) bool numberMatch = numeric && num == matchnum; string searchTerm = Regex.Replace(what, "[^\\w ]", ""); + searchTerm = searchTerm.Trim(); if (numberMatch || (!numeric && (simpleS.Contains(searchTerm))) || (numeric && show.Contains(what))) { ListViewItem lvi = new ListViewItem(); @@ -156,6 +159,11 @@ private void DoFind(bool chooseOnlyMatch) } private void bnGoSearch_Click(object sender, EventArgs e) + { + Search(); + } + + private void Search() { // search on thetvdb.com site this.txtSearchStatus.Text = "Searching on TheTVDB.com"; diff --git a/TVRename#/DownloadIdentifers/DownloadEpisodeJPG.cs b/TVRename#/DownloadIdentifers/DownloadEpisodeJPG.cs index 5c5902812..f943af77b 100644 --- a/TVRename#/DownloadIdentifers/DownloadEpisodeJPG.cs +++ b/TVRename#/DownloadIdentifers/DownloadEpisodeJPG.cs @@ -32,7 +32,7 @@ public override ItemList ProcessEpisode(ProcessedEpisode dbep, FileInfo filo, bo FileInfo imgjpg = FileHelper.FileInFolder(filo.Directory, basefn + ".jpg"); if (forceRefresh || !imgjpg.Exists) - TheActionList.Add(new ActionDownload(dbep.SI, dbep, imgjpg, ban, TVSettings.Instance.ShrinkLargeMede8erImages)); + TheActionList.Add(new ActionDownloadImage(dbep.SI, dbep, imgjpg, ban, TVSettings.Instance.ShrinkLargeMede8erImages)); } return TheActionList; diff --git a/TVRename#/DownloadIdentifers/DownloadFanartJPG.cs b/TVRename#/DownloadIdentifers/DownloadFanartJPG.cs index d5c6c30b7..df5aab21a 100644 --- a/TVRename#/DownloadIdentifers/DownloadFanartJPG.cs +++ b/TVRename#/DownloadIdentifers/DownloadFanartJPG.cs @@ -32,7 +32,7 @@ public override ItemList ProcessShow(ShowItem si, bool forceRefresh) string bannerPath = si.TheSeries().GetSeriesFanartPath(); if (!string.IsNullOrEmpty(bannerPath)) - TheActionList.Add(new ActionDownload(si, null, fi, bannerPath, false)); + TheActionList.Add(new ActionDownloadImage(si, null, fi, bannerPath, false)); doneFanartJPG.Add(fi.FullName); } return TheActionList; diff --git a/TVRename#/DownloadIdentifers/DownloadJolderJPG.cs b/TVRename#/DownloadIdentifers/DownloadJolderJPG.cs index 90455674b..6a37d8844 100644 --- a/TVRename#/DownloadIdentifers/DownloadJolderJPG.cs +++ b/TVRename#/DownloadIdentifers/DownloadJolderJPG.cs @@ -44,7 +44,7 @@ public override ItemList ProcessShow(ShowItem si, bool forceRefresh) if (!string.IsNullOrEmpty(downloadPath)) - TheActionList.Add(new ActionDownload(si, null, fi, downloadPath, false)); + TheActionList.Add(new ActionDownloadImage(si, null, fi, downloadPath, false)); doneFolderJPG.Add(fi.FullName); } return TheActionList; @@ -78,7 +78,7 @@ public override ItemList ProcessSeason(ShowItem si, string folder, int snum, boo bannerPath = si.TheSeries().GetImage(TVSettings.Instance.ItemForFolderJpg()); } if (!string.IsNullOrEmpty(bannerPath)) - TheActionList.Add(new ActionDownload(si, null, fi, bannerPath, + TheActionList.Add(new ActionDownloadImage(si, null, fi, bannerPath, TVSettings.Instance.ShrinkLargeMede8erImages)); doneFolderJPG.Add(fi.FullName); } diff --git a/TVRename#/DownloadIdentifers/DownloadSeriesJPG.cs b/TVRename#/DownloadIdentifers/DownloadSeriesJPG.cs index f95842f71..b6bcf92ff 100644 --- a/TVRename#/DownloadIdentifers/DownloadSeriesJPG.cs +++ b/TVRename#/DownloadIdentifers/DownloadSeriesJPG.cs @@ -28,7 +28,7 @@ public override ItemList ProcessSeason(ShowItem si, string folder, int snum, boo { string bannerPath = si.TheSeries().GetSeasonBannerPath(snum); if (!string.IsNullOrEmpty(bannerPath)) - TheActionList.Add(new ActionDownload(si, null, fi, bannerPath, TVSettings.Instance.ShrinkLargeMede8erImages)); + TheActionList.Add(new ActionDownloadImage(si, null, fi, bannerPath, TVSettings.Instance.ShrinkLargeMede8erImages)); doneJPG.Add(fi.FullName); } return TheActionList; diff --git a/TVRename#/DownloadIdentifers/DownloadXBMCImages.cs b/TVRename#/DownloadIdentifers/DownloadXBMCImages.cs index ca1c729bc..42f8b6e6d 100644 --- a/TVRename#/DownloadIdentifers/DownloadXBMCImages.cs +++ b/TVRename#/DownloadIdentifers/DownloadXBMCImages.cs @@ -56,7 +56,7 @@ public override ItemList ProcessShow(ShowItem si, bool forceRefresh) string path = si.TheSeries().GetSeriesPosterPath(); if (!string.IsNullOrEmpty(path)) { - TheActionList.Add(new ActionDownload(si, null, posterJPG, path, false)); + TheActionList.Add(new ActionDownloadImage(si, null, posterJPG, path, false)); donePosterJPG.Add(si.AutoAdd_FolderBase); } } @@ -66,7 +66,7 @@ public override ItemList ProcessShow(ShowItem si, bool forceRefresh) string path = si.TheSeries().GetSeriesWideBannerPath(); if (!string.IsNullOrEmpty(path)) { - TheActionList.Add(new ActionDownload(si, null, bannerJPG, path, false)); + TheActionList.Add(new ActionDownloadImage(si, null, bannerJPG, path, false)); doneBannerJPG.Add(si.AutoAdd_FolderBase); } } @@ -76,7 +76,7 @@ public override ItemList ProcessShow(ShowItem si, bool forceRefresh) string path = si.TheSeries().GetSeriesFanartPath(); if (!string.IsNullOrEmpty(path)) { - TheActionList.Add(new ActionDownload(si, null, fanartJPG, path)); + TheActionList.Add(new ActionDownloadImage(si, null, fanartJPG, path)); doneFanartJPG.Add(si.AutoAdd_FolderBase); } } @@ -122,7 +122,7 @@ public override ItemList ProcessSeason(ShowItem si, string folder, int snum, boo { string path = si.TheSeries().GetSeasonBannerPath(snum); if (!string.IsNullOrEmpty(path)) - TheActionList.Add(new ActionDownload(si, null, posterJPG, path)); + TheActionList.Add(new ActionDownloadImage(si, null, posterJPG, path)); } FileInfo bannerJPG = FileHelper.FileInFolder(folder, filenamePrefix + "banner.jpg"); @@ -130,7 +130,7 @@ public override ItemList ProcessSeason(ShowItem si, string folder, int snum, boo { string path = si.TheSeries().GetSeasonWideBannerPath(snum); if (!string.IsNullOrEmpty(path)) - TheActionList.Add(new ActionDownload(si, null, bannerJPG, path)); + TheActionList.Add(new ActionDownloadImage(si, null, bannerJPG, path)); } } if (TVSettings.Instance.DownloadEdenImages()) @@ -146,7 +146,7 @@ public override ItemList ProcessSeason(ShowItem si, string folder, int snum, boo { string path = si.TheSeries().GetSeasonBannerPath(snum); if (!string.IsNullOrEmpty(path)) - TheActionList.Add(new ActionDownload(si, null, posterTBN, path)); + TheActionList.Add(new ActionDownloadImage(si, null, posterTBN, path)); } } return TheActionList; @@ -171,13 +171,13 @@ public override ItemList ProcessEpisode(ProcessedEpisode dbep, FileInfo filo, bo string filename = TVSettings.Instance.FilenameFriendly( TVSettings.Instance.NamingStyle.GetTargetEpisodeName(sourceEp,dbep.SI.ShowName, dbep.SI.GetTimeZone(), dbep.SI.DVDOrder)); - ActionDownload b = DoEpisode(dbep.SI,sourceEp,new FileInfo(foldername+"/"+filename), ".jpg", forceRefresh); + ActionDownloadImage b = DoEpisode(dbep.SI,sourceEp,new FileInfo(foldername+"/"+filename), ".jpg", forceRefresh); if (b != null) theActionList.Add(b); } } else { - ActionDownload a = DoEpisode(dbep.SI, dbep, filo, ".tbn", forceRefresh); + ActionDownloadImage a = DoEpisode(dbep.SI, dbep, filo, ".tbn", forceRefresh); if (a != null) theActionList.Add(a); } @@ -186,7 +186,7 @@ public override ItemList ProcessEpisode(ProcessedEpisode dbep, FileInfo filo, bo return base.ProcessEpisode(dbep, filo, forceRefresh); } - private ActionDownload DoEpisode(ShowItem si, Episode ep, FileInfo filo,string extension, bool forceRefresh) + private ActionDownloadImage DoEpisode(ShowItem si, Episode ep, FileInfo filo,string extension, bool forceRefresh) { string ban = ep.GetFilename(); if (!string.IsNullOrEmpty(ban)) @@ -198,7 +198,7 @@ private ActionDownload DoEpisode(ShowItem si, Episode ep, FileInfo filo,string e { this.doneTBN.Add(imgtbn.FullName); - return new ActionDownload(si, (ep is ProcessedEpisode) ? (ProcessedEpisode)ep : new ProcessedEpisode(ep,si ), imgtbn, ban); + return new ActionDownloadImage(si, (ep is ProcessedEpisode) ? (ProcessedEpisode)ep : new ProcessedEpisode(ep,si ), imgtbn, ban); } } diff --git a/TVRename#/DownloadIdentifers/IncorrectFileDates.cs b/TVRename#/DownloadIdentifers/IncorrectFileDates.cs index 0176dae56..5e5943d36 100644 --- a/TVRename#/DownloadIdentifers/IncorrectFileDates.cs +++ b/TVRename#/DownloadIdentifers/IncorrectFileDates.cs @@ -25,7 +25,7 @@ public override ItemList ProcessShow(ShowItem si, bool forceRefresh) if ((di.LastWriteTimeUtc != newUpdateTime.Value)&&(!this.doneFilesAndFolders.Contains(di.FullName))) { this.doneFilesAndFolders.Add(di.FullName); - return new ItemList() { new ItemDateTouch(di, si, newUpdateTime.Value) }; + return new ItemList() { new ActionDateTouch(di, si, newUpdateTime.Value) }; } } return null; @@ -46,7 +46,7 @@ public override ItemList ProcessSeason(ShowItem si, string folder, int snum, boo if ((di.LastWriteTimeUtc != newUpdateTime.Value) &&(!this.doneFilesAndFolders.Contains(di.FullName))) { this.doneFilesAndFolders.Add(di.FullName); - return new ItemList() { new ItemDateTouch(di, si, newUpdateTime.Value) }; + return new ItemList() { new ActionDateTouch(di, si, newUpdateTime.Value) }; } } @@ -66,7 +66,7 @@ public override ItemList ProcessEpisode(ProcessedEpisode dbep, FileInfo filo, bo if ((filo.LastWriteTimeUtc != newUpdateTime) && (!this.doneFilesAndFolders.Contains(filo.FullName))) { this.doneFilesAndFolders.Add(filo.FullName); - return new ItemList() { new ItemDateTouch(filo,dbep, newUpdateTime) }; + return new ItemList() { new ActionDateTouch(filo,dbep, newUpdateTime) }; } } return null; diff --git a/TVRename#/Forms/AutoAddShow.cs b/TVRename#/Forms/AutoAddShow.cs index 8abee20c0..515553654 100644 --- a/TVRename#/Forms/AutoAddShow.cs +++ b/TVRename#/Forms/AutoAddShow.cs @@ -5,7 +5,7 @@ namespace TVRename.Forms { public partial class AutoAddShow : Form { - private ShowItem mSI; + private readonly ShowItem mSI; private readonly TheTVDBCodeFinder mTCCF; public AutoAddShow(string hint) @@ -41,7 +41,9 @@ private void SetShowItem() this.mSI.TVDBCode = code; this.mSI.AutoAdd_FolderBase = this.cbDirectory.Text+this.lblDirectoryName.Text; - + this.mSI.PadSeasonToTwoDigits = true; + //Set Default Timezone based on Network?? + //this.mSI.ShowTimeZone } private void btnOK_Click(object sender, EventArgs e) diff --git a/TVRename#/Forms/UI.Designer.cs b/TVRename#/Forms/UI.Designer.cs index 7142e2552..7427c5095 100644 --- a/TVRename#/Forms/UI.Designer.cs +++ b/TVRename#/Forms/UI.Designer.cs @@ -39,20 +39,20 @@ public void InitializeComponent() { this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(UI)); - System.Windows.Forms.ListViewGroup listViewGroup1 = new System.Windows.Forms.ListViewGroup("Missing", System.Windows.Forms.HorizontalAlignment.Left); - System.Windows.Forms.ListViewGroup listViewGroup2 = new System.Windows.Forms.ListViewGroup("Rename", System.Windows.Forms.HorizontalAlignment.Left); - System.Windows.Forms.ListViewGroup listViewGroup3 = new System.Windows.Forms.ListViewGroup("Copy", System.Windows.Forms.HorizontalAlignment.Left); - System.Windows.Forms.ListViewGroup listViewGroup4 = new System.Windows.Forms.ListViewGroup("Move", System.Windows.Forms.HorizontalAlignment.Left); - System.Windows.Forms.ListViewGroup listViewGroup5 = new System.Windows.Forms.ListViewGroup("Remove", System.Windows.Forms.HorizontalAlignment.Left); - System.Windows.Forms.ListViewGroup listViewGroup6 = new System.Windows.Forms.ListViewGroup("Download RSS", System.Windows.Forms.HorizontalAlignment.Left); - System.Windows.Forms.ListViewGroup listViewGroup7 = new System.Windows.Forms.ListViewGroup("Download", System.Windows.Forms.HorizontalAlignment.Left); - System.Windows.Forms.ListViewGroup listViewGroup8 = new System.Windows.Forms.ListViewGroup("Media Center Metadata", System.Windows.Forms.HorizontalAlignment.Left); - System.Windows.Forms.ListViewGroup listViewGroup9 = new System.Windows.Forms.ListViewGroup("Update File Metadata", System.Windows.Forms.HorizontalAlignment.Left); - System.Windows.Forms.ListViewGroup listViewGroup10 = new System.Windows.Forms.ListViewGroup("Downloading", System.Windows.Forms.HorizontalAlignment.Left); - System.Windows.Forms.ListViewGroup listViewGroup11 = new System.Windows.Forms.ListViewGroup("Recently Aired", System.Windows.Forms.HorizontalAlignment.Left); - System.Windows.Forms.ListViewGroup listViewGroup12 = new System.Windows.Forms.ListViewGroup("Next 7 Days", System.Windows.Forms.HorizontalAlignment.Left); - System.Windows.Forms.ListViewGroup listViewGroup13 = new System.Windows.Forms.ListViewGroup("Future Episodes", System.Windows.Forms.HorizontalAlignment.Left); - System.Windows.Forms.ListViewGroup listViewGroup14 = new System.Windows.Forms.ListViewGroup("Later", System.Windows.Forms.HorizontalAlignment.Left); + System.Windows.Forms.ListViewGroup listViewGroup15 = new System.Windows.Forms.ListViewGroup("Missing", System.Windows.Forms.HorizontalAlignment.Left); + System.Windows.Forms.ListViewGroup listViewGroup16 = new System.Windows.Forms.ListViewGroup("Rename", System.Windows.Forms.HorizontalAlignment.Left); + System.Windows.Forms.ListViewGroup listViewGroup17 = new System.Windows.Forms.ListViewGroup("Copy", System.Windows.Forms.HorizontalAlignment.Left); + System.Windows.Forms.ListViewGroup listViewGroup18 = new System.Windows.Forms.ListViewGroup("Move", System.Windows.Forms.HorizontalAlignment.Left); + System.Windows.Forms.ListViewGroup listViewGroup19 = new System.Windows.Forms.ListViewGroup("Remove", System.Windows.Forms.HorizontalAlignment.Left); + System.Windows.Forms.ListViewGroup listViewGroup20 = new System.Windows.Forms.ListViewGroup("Download RSS", System.Windows.Forms.HorizontalAlignment.Left); + System.Windows.Forms.ListViewGroup listViewGroup21 = new System.Windows.Forms.ListViewGroup("Download", System.Windows.Forms.HorizontalAlignment.Left); + System.Windows.Forms.ListViewGroup listViewGroup22 = new System.Windows.Forms.ListViewGroup("Media Center Metadata", System.Windows.Forms.HorizontalAlignment.Left); + System.Windows.Forms.ListViewGroup listViewGroup23 = new System.Windows.Forms.ListViewGroup("Update File Metadata", System.Windows.Forms.HorizontalAlignment.Left); + System.Windows.Forms.ListViewGroup listViewGroup24 = new System.Windows.Forms.ListViewGroup("Downloading", System.Windows.Forms.HorizontalAlignment.Left); + System.Windows.Forms.ListViewGroup listViewGroup1 = new System.Windows.Forms.ListViewGroup("Recently Aired", System.Windows.Forms.HorizontalAlignment.Left); + System.Windows.Forms.ListViewGroup listViewGroup2 = new System.Windows.Forms.ListViewGroup("Next 7 Days", System.Windows.Forms.HorizontalAlignment.Left); + System.Windows.Forms.ListViewGroup listViewGroup3 = new System.Windows.Forms.ListViewGroup("Future Episodes", System.Windows.Forms.HorizontalAlignment.Left); + System.Windows.Forms.ListViewGroup listViewGroup4 = new System.Windows.Forms.ListViewGroup("Later", System.Windows.Forms.HorizontalAlignment.Left); this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.exportToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -178,6 +178,7 @@ public void InitializeComponent() this.quickTimer = new System.Windows.Forms.Timer(this.components); this.tmrPeriodicScan = new System.Windows.Forms.Timer(this.components); this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); + this.timezoneInconsistencyLOGToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.menuStrip1.SuspendLayout(); this.tabControl1.SuspendLayout(); this.tbMyShows.SuspendLayout(); @@ -379,7 +380,8 @@ public void InitializeComponent() this.toolStripSeparator4, this.torrentMatchToolStripMenuItem, this.uTorrentToolStripMenuItem, - this.duplicateFinderLOGToolStripMenuItem}); + this.duplicateFinderLOGToolStripMenuItem, + this.timezoneInconsistencyLOGToolStripMenuItem}); this.betaToolsToolStripMenuItem.Name = "betaToolsToolStripMenuItem"; this.betaToolsToolStripMenuItem.Size = new System.Drawing.Size(42, 20); this.betaToolsToolStripMenuItem.Text = "Beta"; @@ -421,8 +423,8 @@ public void InitializeComponent() // duplicateFinderLOGToolStripMenuItem // this.duplicateFinderLOGToolStripMenuItem.Name = "duplicateFinderLOGToolStripMenuItem"; - this.duplicateFinderLOGToolStripMenuItem.Size = new System.Drawing.Size(194, 22); - this.duplicateFinderLOGToolStripMenuItem.Text = "Duplicate Finder (LOG)"; + this.duplicateFinderLOGToolStripMenuItem.Size = new System.Drawing.Size(235, 22); + this.duplicateFinderLOGToolStripMenuItem.Text = "Duplicate Finder"; this.duplicateFinderLOGToolStripMenuItem.Click += new System.EventHandler(this.duplicateFinderLOGToolStripMenuItem_Click); // // helpToolStripMenuItem @@ -1001,37 +1003,37 @@ public void InitializeComponent() this.columnHeader56, this.columnHeader58}); this.lvAction.FullRowSelect = true; - listViewGroup1.Header = "Missing"; - listViewGroup1.Name = "lvgActionMissing"; - listViewGroup2.Header = "Rename"; - listViewGroup2.Name = "lvgActionRename"; - listViewGroup3.Header = "Copy"; - listViewGroup3.Name = "lvgActionCopy"; - listViewGroup4.Header = "Move"; - listViewGroup4.Name = "lvgActionMove"; - listViewGroup5.Header = "Remove"; - listViewGroup5.Name = "lvgActionDelete"; - listViewGroup6.Header = "Download RSS"; - listViewGroup6.Name = "lvgActionDownloadRSS"; - listViewGroup7.Header = "Download"; - listViewGroup7.Name = "lvgActionDownload"; - listViewGroup8.Header = "Media Center Metadata"; - listViewGroup8.Name = "lvgActionMeta"; - listViewGroup9.Header = "Update File Metadata"; - listViewGroup9.Name = "lvgUpdateFileDates"; - listViewGroup10.Header = "Downloading"; - listViewGroup10.Name = "lvgDownloading"; + listViewGroup15.Header = "Missing"; + listViewGroup15.Name = "lvgActionMissing"; + listViewGroup16.Header = "Rename"; + listViewGroup16.Name = "lvgActionRename"; + listViewGroup17.Header = "Copy"; + listViewGroup17.Name = "lvgActionCopy"; + listViewGroup18.Header = "Move"; + listViewGroup18.Name = "lvgActionMove"; + listViewGroup19.Header = "Remove"; + listViewGroup19.Name = "lvgActionDelete"; + listViewGroup20.Header = "Download RSS"; + listViewGroup20.Name = "lvgActionDownloadRSS"; + listViewGroup21.Header = "Download"; + listViewGroup21.Name = "lvgActionDownload"; + listViewGroup22.Header = "Media Center Metadata"; + listViewGroup22.Name = "lvgActionMeta"; + listViewGroup23.Header = "Update File Metadata"; + listViewGroup23.Name = "lvgUpdateFileDates"; + listViewGroup24.Header = "Downloading"; + listViewGroup24.Name = "lvgDownloading"; this.lvAction.Groups.AddRange(new System.Windows.Forms.ListViewGroup[] { - listViewGroup1, - listViewGroup2, - listViewGroup3, - listViewGroup4, - listViewGroup5, - listViewGroup6, - listViewGroup7, - listViewGroup8, - listViewGroup9, - listViewGroup10}); + listViewGroup15, + listViewGroup16, + listViewGroup17, + listViewGroup18, + listViewGroup19, + listViewGroup20, + listViewGroup21, + listViewGroup22, + listViewGroup23, + listViewGroup24}); this.lvAction.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; this.lvAction.HideSelection = false; this.lvAction.Location = new System.Drawing.Point(0, 35); @@ -1242,21 +1244,21 @@ public void InitializeComponent() this.columnHeader34, this.columnHeader35}); this.lvWhenToWatch.FullRowSelect = true; - listViewGroup11.Header = "Recently Aired"; - listViewGroup11.Name = "justPassed"; - listViewGroup12.Header = "Next 7 Days"; - listViewGroup12.Name = "next7days"; - listViewGroup12.Tag = "1"; - listViewGroup13.Header = "Future Episodes"; - listViewGroup13.Name = "futureEps"; - listViewGroup14.Header = "Later"; - listViewGroup14.Name = "later"; - listViewGroup14.Tag = "2"; + listViewGroup1.Header = "Recently Aired"; + listViewGroup1.Name = "justPassed"; + listViewGroup2.Header = "Next 7 Days"; + listViewGroup2.Name = "next7days"; + listViewGroup2.Tag = "1"; + listViewGroup3.Header = "Future Episodes"; + listViewGroup3.Name = "futureEps"; + listViewGroup4.Header = "Later"; + listViewGroup4.Name = "later"; + listViewGroup4.Tag = "2"; this.lvWhenToWatch.Groups.AddRange(new System.Windows.Forms.ListViewGroup[] { - listViewGroup11, - listViewGroup12, - listViewGroup13, - listViewGroup14}); + listViewGroup1, + listViewGroup2, + listViewGroup3, + listViewGroup4}); this.lvWhenToWatch.HideSelection = false; this.lvWhenToWatch.Location = new System.Drawing.Point(0, 35); this.lvWhenToWatch.Name = "lvWhenToWatch"; @@ -1435,7 +1437,7 @@ public void InitializeComponent() // this.showRightClickMenu.Name = "menuSearchSites"; this.showRightClickMenu.ShowImageMargin = false; - this.showRightClickMenu.Size = new System.Drawing.Size(128, 26); + this.showRightClickMenu.Size = new System.Drawing.Size(36, 4); this.showRightClickMenu.Opening += new System.ComponentModel.CancelEventHandler(this.showRightClickMenu_Opening); this.showRightClickMenu.ItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.showRightClickMenu_ItemClicked); // @@ -1473,6 +1475,13 @@ public void InitializeComponent() this.tmrPeriodicScan.Enabled = true; this.tmrPeriodicScan.Tick += new System.EventHandler(this.tmrPeriodicScan_Tick); // + // timezoneInconsistencyLOGToolStripMenuItem + // + this.timezoneInconsistencyLOGToolStripMenuItem.Name = "timezoneInconsistencyLOGToolStripMenuItem"; + this.timezoneInconsistencyLOGToolStripMenuItem.Size = new System.Drawing.Size(235, 22); + this.timezoneInconsistencyLOGToolStripMenuItem.Text = "Timezone Inconsistency (LOG)"; + this.timezoneInconsistencyLOGToolStripMenuItem.Click += new System.EventHandler(this.timezoneInconsistencyLOGToolStripMenuItem_Click); + // // UI // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -1646,5 +1655,6 @@ public void InitializeComponent() private System.Windows.Forms.ToolStripMenuItem duplicateFinderLOGToolStripMenuItem; private System.Windows.Forms.Timer tmrPeriodicScan; private System.Windows.Forms.ToolTip toolTip1; + private System.Windows.Forms.ToolStripMenuItem timezoneInconsistencyLOGToolStripMenuItem; } } diff --git a/TVRename#/Forms/UI.cs b/TVRename#/Forms/UI.cs index 09c074d27..c883de0a1 100644 --- a/TVRename#/Forms/UI.cs +++ b/TVRename#/Forms/UI.cs @@ -18,6 +18,7 @@ using File = Alphaleonis.Win32.Filesystem.File; using System.IO; using System.Linq; +using System.Text; using System.Text.RegularExpressions; using TVRename.Ipc; @@ -238,11 +239,11 @@ public void ProcessArgs() // TODO: Unify command line handling between here and in Program.cs if (this.mDoc.Args.Scan) - this.Scan(); + this.Scan(true); if (this.mDoc.Args.QuickScan ) - this.QuickScan(); + this.QuickScan(true); if (this.mDoc.Args.RecentScan ) - this.RecentScan(); + this.RecentScan(true); if (this.mDoc.Args.DoAll) this.ProcessAll(); if (this.mDoc.Args.Quit || this.mDoc.Args.Hide) @@ -1332,7 +1333,7 @@ public void lvWhenToWatch_DoubleClick(object sender, System.EventArgs e) this.bnWTWBTSearch_Click(null, null); break; case TVSettings.WTWDoubleClickAction.Scan: - this.Scan(new List {ei.SI}); + this.Scan(new List {ei.SI},false); this.tabControl1.SelectTab(this.tbAllInOne); break; } @@ -1484,6 +1485,11 @@ public void FocusWindow() this.Activate(); } + public void Scan() + { + Scan(true); + } + public void notifyIcon1_DoubleClick(object sender, MouseEventArgs e) { this.tmrShowUpcomingPopup.Stop(); @@ -1897,7 +1903,7 @@ public void showRightClickMenu_ItemClicked(object sender, System.Windows.Forms.T { if (mLastShowsClicked != null) { - this.Scan(mLastShowsClicked); + this.Scan(mLastShowsClicked,false); this.tabControl1.SelectTab(this.tbAllInOne); } @@ -1989,16 +1995,22 @@ public void showRightClickMenu_ItemClicked(object sender, System.Windows.Forms.T { // make new Item for copying/moving to specified location FileInfo from = new FileInfo(this.openFile.FileName); + FileInfo to = new FileInfo(mi.TheFileNoExt + from.Extension); this.mDoc.TheActionList.Add( new ActionCopyMoveRename( TVSettings.Instance.LeaveOriginals ? ActionCopyMoveRename.Op.Copy - : ActionCopyMoveRename.Op.Move, from, - new FileInfo(mi.TheFileNoExt + from.Extension), mi.Episode, + : ActionCopyMoveRename.Op.Move, from,to + , mi.Episode, TVSettings.Instance.Tidyup,mi)); // and remove old Missing item this.mDoc.TheActionList.Remove(mi); - } + + DownloadIdentifiersController di = new DownloadIdentifiersController(); + + // if we're copying/moving a file across, we might also want to make a thumbnail or NFO for it + this.mDoc.TheActionList.Add(di.ProcessEpisode(mi.Episode, to)); + } } this.mLastActionsClicked = null; @@ -2953,26 +2965,37 @@ private void UI_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) private void bnActionCheck_Click(object sender, System.EventArgs e) { - this.Scan(); + this.Scan(false); } - public void Scan() + public void Scan(bool unattended) { this.tabControl1.SelectedTab = this.tbAllInOne; - this.Scan(null); + this.Scan(null, unattended); this.mDoc.ExportMissingXML(); //Save missing shows to XML } + public void QuickScan() + { + QuickScan(true); + } public void RecentScan() { - Scan(this.mDoc.getRecentShows()); + RecentScan(true); + } + + + public void RecentScan(bool unattended) + { + Scan(this.mDoc.getRecentShows(),unattended ); } - private void Scan(List shows) + private void Scan(List shows,bool unattended) { logger.Info("*******************************"); logger.Info("Starting Scan for {0} shows...", shows?.Count > 0 ? shows.Count.ToString() : "all"); + GetNewShows(unattended); this.MoreBusy(); this.mDoc.ActionGo(shows); this.LessBusy(); @@ -2980,7 +3003,7 @@ private void Scan(List shows) this.FillActionList(); } - private void GetNewShows() + private void GetNewShows(bool unattended) { //for each directory in settings directory //for each file in directory @@ -2989,6 +3012,9 @@ private void GetNewShows() //if so add series to list of series scanned if (!TVSettings.Instance.AutoSearchForDownloadedFiles) return; + //Dont support unattended mode + if (unattended) return; + List possibleShowNames = new List(); foreach (string dirPath in this.mDoc.SearchFolders) @@ -3004,59 +3030,97 @@ private void GetNewShows() if (!TVSettings.Instance.UsefulExtension(fi.Extension, false)) continue; // move on - if (TVSettings.Instance.IgnoreSamples && Helpers.Contains(fi.FullName, "sample", StringComparison.OrdinalIgnoreCase) && ((fi.Length / (1024 * 1024)) < TVSettings.Instance.SampleFileMaxSizeMB)) + if (TVSettings.Instance.IgnoreSamples && + Helpers.Contains(fi.FullName, "sample", StringComparison.OrdinalIgnoreCase) && + ((fi.Length / (1024 * 1024)) < TVSettings.Instance.SampleFileMaxSizeMB)) continue; - if (!LookForSeries(fi.Name)) possibleShowNames.Add(fi.RemoveExtension()+"."); + if (!LookForSeries(fi.Name)) possibleShowNames.Add(fi.RemoveExtension() + "."); } - foreach (string subDirPath in Directory.GetDirectories(dirPath, "*", System.IO.SearchOption.AllDirectories)) - { - if (!Directory.Exists(subDirPath)) continue; - - DirectoryInfo di = new DirectoryInfo(subDirPath); +// foreach (string subDirPath in Directory.GetDirectories(dirPath, "*", +// System.IO.SearchOption.AllDirectories)) +// { +// if (!Directory.Exists(subDirPath)) continue; +// +// DirectoryInfo di = new DirectoryInfo(subDirPath); +// +// if (!LookForSeries(di.Name)) possibleShowNames.Add(di.Name); +// } - if (!LookForSeries(di.Name)) possibleShowNames.Add(di.Name); - } + } + List addedShows = new List(); + + foreach (string hint in possibleShowNames) + { + //MessageBox.Show($"Search for {hint}"); + //if hint doesn't match existing added shows + if (LookForSeries(hint, addedShows)) continue; - List addedShows = new List(); + //If the hint contains certain terms then we'll ignore it + if (IgnoreHint(hint)) continue; - foreach (string hint in possibleShowNames) - { - //MessageBox.Show($"Search for {hint}"); - //if hint doesn't match existing added shows - if (LookForSeries(hint, addedShows)) continue; + //Remove anything we can from hint to make it cleaner and hence more likely to match + string refinedHint = RemoveSeriesEpisodeIndicators(hint); - //Remove anything we can from hint to make it cleaner and hence more likely to match - string refinedHint = RemoveSeriesEpisodeIndicators(hint); + logger.Info("****************"); + logger.Info("Auto Adding New Show"); + this.MoreBusy(); - //popup dialog - AutoAddShow askForMatch = new AutoAddShow(refinedHint); - if (askForMatch.ShowDialog() == DialogResult.OK) - { - //If added add show to collection - addedShows.Add(askForMatch.ShowItem); - } + TheTVDB.Instance.GetLock("AutoAddShow"); + //popup dialog + AutoAddShow askForMatch = new AutoAddShow(refinedHint); + System.Windows.Forms.DialogResult dr = askForMatch.ShowDialog(); + TheTVDB.Instance.Unlock("AutoAddShow"); + if (dr == System.Windows.Forms.DialogResult.OK) + { + //If added add show to collection + addedShows.Add(askForMatch.ShowItem); } - this.mDoc.ShowItems.AddRange(addedShows); + else logger.Info("Cancelled Auto adding new show"); + + + this.LessBusy(); } + + this.mDoc.GetShowItems(true).AddRange(addedShows); + + this.mDoc.UnlockShowItems(); + this.ShowAddedOrEdited(true); + + if (addedShows.Count <= 0) return; + + this.SelectShow(addedShows.Last()); + logger.Info("Added new shows called: {0}", string.Join(",", addedShows.Select(s => s.ShowName))); + + } + + private static bool IgnoreHint(string hint) + { + string[] removeHintsContaining = new string[] { "dvdrip", "camrip", "screener", "dvdscr", "r5", "bluray" }; + + return removeHintsContaining.Any(hint.Contains); } private string RemoveSeriesEpisodeIndicators(string hint) { + string[] removeAfterTerms = new string[] {"1080p","720p"}; + string hint2 = Helpers.RemoveDiacritics(hint); hint2 = RemoveSE(hint2); hint2 = hint2.ToLower(); hint2 = hint2.Replace("'", ""); hint2 = hint2.Replace("&", "and"); hint2 = Regex.Replace(hint2, "[_\\W]+", " "); - hint2 = hint2.RemoveAfter("1080p") ; - hint2 = hint2.RemoveAfter("720p"); + foreach (string term in removeAfterTerms) + { + hint2 = hint2.RemoveAfter(term); + } foreach (string seasonWord in this.mDoc.SeasonWords()) { hint2 = hint2.RemoveAfter(seasonWord ); @@ -3115,14 +3179,14 @@ private bool LookForSeries(string test,IEnumerable shows) return false; } - public void QuickScan() + public void QuickScan(bool unattended) { logger.Info("*******************************"); logger.Info("Starting QuickScan..."); + GetNewShows(unattended); this.MoreBusy(); this.mDoc.QuickScan(); this.LessBusy(); - GetNewShows(); this.FillMyShows(); // scanning can download more info to be displayed in my shows this.FillActionList(); } @@ -3236,13 +3300,13 @@ private void FillActionList() else if (op == ActionCopyMoveRename.Op.Rename) renameCount++; } - else if (Action is ActionDownload) + else if (Action is ActionDownloadImage) downloadCount++; else if (Action is ActionRSS) rssCount++; else if (Action is ActionWriteMetadata) // base interface that all metadata actions are derived from metaCount++; - else if (Action is ItemDateTouch) + else if (Action is ActionDateTouch) fileMetaCount++; else if (Action is ItemuTorrenting || Action is ItemSABnzbd) dlCount++; @@ -3324,20 +3388,33 @@ private void Revert(bool checkedNotSelected) this.mDoc.TheActionList.Add(m2); this.mDoc.TheActionList.Remove(i2); - List toRemove = new List(); + List toRemove = new List(); //We can remove any CopyMoveActions that are closely related too foreach (Item a in this.mDoc.TheActionList) { - if (!(a is ActionCopyMoveRename i1)) continue; + if (a is ItemMissing) continue; - if (i1.From.RemoveExtension(true).StartsWith(i2.From.RemoveExtension(true))) + if ((a is ActionCopyMoveRename i1)) { - toRemove.Add(i1); + if (i1.From.RemoveExtension(true).StartsWith(i2.From.RemoveExtension(true))) + { + toRemove.Add(i1); + + } + } + else if (a is ScanListItem ad) + { + if ((ad.Episode?.AppropriateEpNum == i2.Episode?.AppropriateEpNum) && + (ad.Episode?.AppropriateSeasonNumber == i2.Episode?.AppropriateSeasonNumber)) + toRemove.Add(a); } + else + { + continue;} } //Remove all similar items - foreach (ActionCopyMoveRename i in toRemove) this.mDoc.TheActionList.Remove(i); + foreach (Item i in toRemove) this.mDoc.TheActionList.Remove(i); } this.FillActionList(); @@ -3696,7 +3773,7 @@ private void cbActionDownloads_Click(object sender, System.EventArgs e) foreach (ListViewItem lvi in this.lvAction.Items) { Item i = (Item) (lvi.Tag); - if ((i != null) && (i is ActionDownload)) + if ((i != null) && (i is ActionDownloadImage)) lvi.Checked = cs == CheckState.Checked; } @@ -3830,14 +3907,20 @@ private void lvAction_DragDrop(object sender, DragEventArgs e) // Only want the first file if multiple files were dragged across. FileInfo from = new FileInfo(files[0]); ItemMissing mi = (ItemMissing) lvi.Tag; + FileInfo to = new FileInfo(mi.TheFileNoExt + from.Extension); + this.mDoc.TheActionList.Add( new ActionCopyMoveRename( TVSettings.Instance.LeaveOriginals ? ActionCopyMoveRename.Op.Copy - : ActionCopyMoveRename.Op.Move, from, - new FileInfo(mi.TheFileNoExt + from.Extension), mi.Episode, TVSettings.Instance.Tidyup,mi)); + : ActionCopyMoveRename.Op.Move, from,to + , mi.Episode, TVSettings.Instance.Tidyup,mi)); // and remove old Missing item this.mDoc.TheActionList.Remove(mi); + DownloadIdentifiersController di = new DownloadIdentifiersController(); + + // if we're copying/moving a file across, we might also want to make a thumbnail or NFO for it + this.mDoc.TheActionList.Add(di.ProcessEpisode(mi.Episode, to)); this.FillActionList(); } } @@ -3940,13 +4023,13 @@ private void RunAutoScan(string scanType) switch (TVSettings.Instance.MonitoredFoldersScanType) { case TVRename.TVSettings.ScanType.Full: - Scan(); + Scan(true); break; case TVRename.TVSettings.ScanType.Recent: - RecentScan(); + RecentScan(true); break; case TVRename.TVSettings.ScanType.Quick: - QuickScan(); + QuickScan(true); break; } @@ -3968,5 +4051,52 @@ private void showRightClickMenu_Opening(object sender, System.ComponentModel.Can { } + + private void timezoneInconsistencyLOGToolStripMenuItem_Click(object sender, EventArgs e) + { + + TimeZoneTracker results = new TimeZoneTracker(); + foreach (ShowItem si in this.mDoc.ShowItems) + { + SeriesInfo ser = si.TheSeries(); + + //si.ShowTimeZone = TimeZone.TimeZoneForNetwork(ser.getNetwork()); + + results.Add(ser.getNetwork() ,si.ShowTimeZone,si.ShowName); + } + logger.Info(results.PrintVersion()); + } + + private class TimeZoneTracker + { + private readonly Dictionary>> _s = new Dictionary>>(); + internal void Add(string network, string timezone, string show) + { + if (!this._s.ContainsKey(network)) this._s.Add(network,new Dictionary>()); + Dictionary> snet = this._s[network]; + + if (!snet.ContainsKey(timezone)) snet.Add(timezone , new List()); + List snettz = snet[timezone]; + + snettz.Add(show); + } + + internal string PrintVersion() + { + StringBuilder sb = new StringBuilder(); + sb.AppendLine("***********************************"); + sb.AppendLine("****Timezone Comparison *****"); + sb.AppendLine("***********************************"); + foreach (KeyValuePair>> kvp in this._s) + { + foreach (KeyValuePair> kvp2 in kvp.Value) + { + sb.AppendLine($"{kvp.Key,-30}{kvp2.Key,-30}{string.Join(",", kvp2.Value )}"); + } + } + + return sb.ToString(); + } + } } } diff --git a/TVRename#/Forms/UI.resx b/TVRename#/Forms/UI.resx index 6d053cb10..5633b786c 100644 --- a/TVRename#/Forms/UI.resx +++ b/TVRename#/Forms/UI.resx @@ -128,7 +128,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAADk - HQAAAk1TRnQBSQFMAgEBEwEAASABAwEgAQMBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo + HQAAAk1TRnQBSQFMAgEBEwEAASgBAwEoAQMBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo AwABQAMAAVADAAEBAQABCAYAARQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5 AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA @@ -274,7 +274,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAACa - GAAAAk1TRnQBSQFMAgEBCgEAATwBAwE8AQMBEgEAAQ0BAAT/ARkBAAj/AUIBTQE2BwABNgMAASgDAAFI + GAAAAk1TRnQBSQFMAgEBCgEAAUQBAwFEAQMBEgEAAQ0BAAT/ARkBAAj/AUIBTQE2BwABNgMAASgDAAFI AwABJwMAAQEBAAEYBQAB6AEgGAAD7wMSBjADCQYwAw8DKgMwAxsD0Q8AASEB1gEIASEB1gEIASEB1gEI ASEB1gEImQAD7wM8A58D5gMwA+ADzgNPA9gDtwOPA9EMAAEhAdYBCAEhAdYBCAEhAdYBCAEhAdYBCAEh AdYBCAEhAdYBCJYAA+8DNgOPA+IDMAPbA8YDTwPOA0ADjwPRDAABIQHWAQgBIQHWAQgBIQHWAQgBIQHW diff --git a/TVRename#/ItemsAndActions/ItemDateTouch.cs b/TVRename#/ItemsAndActions/ActionDateTouch.cs similarity index 90% rename from TVRename#/ItemsAndActions/ItemDateTouch.cs rename to TVRename#/ItemsAndActions/ActionDateTouch.cs index b80d1b2d5..2713477cb 100644 --- a/TVRename#/ItemsAndActions/ItemDateTouch.cs +++ b/TVRename#/ItemsAndActions/ActionDateTouch.cs @@ -12,7 +12,7 @@ namespace TVRename using DirectoryInfo = Alphaleonis.Win32.Filesystem.DirectoryInfo; using FileInfo = Alphaleonis.Win32.Filesystem.FileInfo; - public class ItemDateTouch : Item, Action, ScanListItem + public class ActionDateTouch : Item, Action, ScanListItem { public ShowItem SI; // if for an entire show, rather than specific episode public Season SN; // if for an entire show, rather than specific episode @@ -20,14 +20,14 @@ public class ItemDateTouch : Item, Action, ScanListItem public DirectoryInfo WhereDirectory; private readonly DateTime updateTime; - public ItemDateTouch(FileInfo f, ProcessedEpisode pe, DateTime date) + public ActionDateTouch(FileInfo f, ProcessedEpisode pe, DateTime date) { this.Episode = pe; this.WhereFile = f; this.updateTime = date; } - public ItemDateTouch(DirectoryInfo dir, Season sn, DateTime date) + public ActionDateTouch(DirectoryInfo dir, Season sn, DateTime date) { this.SN = sn; this.WhereDirectory = dir; @@ -35,7 +35,7 @@ public ItemDateTouch(DirectoryInfo dir, Season sn, DateTime date) } - public ItemDateTouch(DirectoryInfo dir, ShowItem si, DateTime date) + public ActionDateTouch(DirectoryInfo dir, ShowItem si, DateTime date) { this.SI = si; this.WhereDirectory = dir; @@ -91,12 +91,12 @@ public bool Go(ref bool pause, TVRenameStats stats) public bool SameAs(Item o) { - return (o is ItemDateTouch) && ((o as ItemDateTouch).WhereFile == this.WhereFile) && ((o as ItemDateTouch).WhereDirectory == this.WhereDirectory); + return (o is ActionDateTouch) && ((o as ActionDateTouch).WhereFile == this.WhereFile) && ((o as ActionDateTouch).WhereDirectory == this.WhereDirectory); } public int Compare(Item o) { - ItemDateTouch nfo = o as ItemDateTouch; + ActionDateTouch nfo = o as ActionDateTouch; if (this.Episode == null) return 1; diff --git a/TVRename#/ItemsAndActions/ActionDownload.cs b/TVRename#/ItemsAndActions/ActionDownloadImage.cs similarity index 89% rename from TVRename#/ItemsAndActions/ActionDownload.cs rename to TVRename#/ItemsAndActions/ActionDownloadImage.cs index a5adcc8e3..806e0d0ad 100644 --- a/TVRename#/ItemsAndActions/ActionDownload.cs +++ b/TVRename#/ItemsAndActions/ActionDownloadImage.cs @@ -1,223 +1,223 @@ -// -// Main website for TVRename is http://tvrename.com -// -// Source code available at https://github.com/TV-Rename/tvrename -// -// This code is released under GPLv3 https://github.com/TV-Rename/tvrename/blob/master/LICENSE.md -// - -using System.Drawing; -using System.Drawing.Drawing2D; -using System.Drawing.Imaging; - -namespace TVRename -{ - using System; - using System.Windows.Forms; - using FileInfo = Alphaleonis.Win32.Filesystem.FileInfo; - using System.IO; - - public class ActionDownload : Item, Action, ScanListItem - { - private readonly string Path; - private readonly FileInfo Destination; - private readonly ShowItem SI; - private readonly bool ShrinkLargeMede8erImage; - - public ActionDownload(ShowItem si, ProcessedEpisode pe, FileInfo dest, string path) : this(si, pe, dest, path, false) { } - - public ActionDownload(ShowItem si, ProcessedEpisode pe, FileInfo dest, string path, bool mede8erShrink) - { - this.Episode = pe; - this.SI = si; - this.Destination = dest; - this.Path = path; - ShrinkLargeMede8erImage = mede8erShrink; - } - - #region Action Members - - public bool Done { get; set; } - public bool Error { get; set; } - public string ErrorText { get; set; } - - public string Name => "Download"; - - public string ProgressText => this.Destination.Name; - - public double PercentDone => this.Done ? 100 : 0; - - public string produces => this.Destination.FullName; - - // 0 to 100 - public long SizeOfWork => 1000000; - - // http://www.codeproject.com/Articles/2941/Resizing-a-Photographic-image-with-GDI-for-NET - static Image MaxSize(Image imgPhoto, int Width, int Height) - { - int sourceWidth = imgPhoto.Width; - int sourceHeight = imgPhoto.Height; - - float nPercentW = ((float)Width / (float)sourceWidth); - float nPercentH = ((float)Height / (float)sourceHeight); - - //float nPercent = Math.Min(nPercentH, nPercentW); - int destWidth, destHeight; - - if (nPercentH < nPercentW) - { - destHeight = Height; - destWidth = (int)(sourceWidth * nPercentH); - } - else - { - destHeight = (int)(sourceHeight * nPercentW); - destWidth = Width; - } - - Bitmap bmPhoto = new Bitmap(destWidth, destHeight, PixelFormat.Format24bppRgb); - bmPhoto.SetResolution(imgPhoto.HorizontalResolution, imgPhoto.VerticalResolution); - - Graphics grPhoto = Graphics.FromImage(bmPhoto); - grPhoto.Clear(Color.Black); - grPhoto.InterpolationMode = InterpolationMode.HighQualityBicubic; - - grPhoto.DrawImage(imgPhoto, - new Rectangle(0, 0, destWidth, destHeight), - new Rectangle(0, 0, sourceWidth, sourceHeight), - GraphicsUnit.Pixel); - - grPhoto.Dispose(); - return bmPhoto; - } - - public bool Go(ref bool pause, TVRenameStats stats) - { - byte[] theData = TheTVDB.Instance.GetTVDBDownload(this.Path); - if ((theData == null) || (theData.Length == 0)) - { - this.ErrorText = "Unable to download " + this.Path; - this.Error = true; - this.Done = true; - return false; - } - - if (ShrinkLargeMede8erImage) - { - // shrink images down to a maximum size of 156x232 - Image im = new Bitmap(new MemoryStream(theData)); - if ((im.Width > 156) || (im.Height > 232)) - { - im = MaxSize(im, 156, 232); - - using (MemoryStream m = new MemoryStream()) - { - im.Save(m, ImageFormat.Jpeg); - theData = m.ToArray(); - } - } - } - - try - { - FileStream fs = new FileStream(this.Destination.FullName, FileMode.Create); - fs.Write(theData, 0, theData.Length); - fs.Close(); - } - catch (Exception e) - { - this.ErrorText = e.Message; - this.Error = true; - this.Done = true; - return false; - } - - - this.Done = true; - return true; - } - - #endregion - - #region Item Members - - public bool SameAs(Item o) - { - return (o is ActionDownload) && ((o as ActionDownload).Destination == this.Destination); - } - - public int Compare(Item o) - { - ActionDownload dl = o as ActionDownload; - return dl == null ? 0 : this.Destination.FullName.CompareTo(dl.Destination.FullName); - } - - #endregion - - #region ScanListItem Members - - public int IconNumber => 5; - - public ProcessedEpisode Episode { get; set; } - - public IgnoreItem Ignore - { - get - { - if (this.Destination == null) - return null; - return new IgnoreItem(this.Destination.FullName); - } - } - - public ListViewItem ScanListViewItem - { - get - { - ListViewItem lvi = new ListViewItem { - Text = (this.Episode != null) ? this.Episode.SI.ShowName : ((this.SI != null) ? this.SI.ShowName : "") - }; - - lvi.SubItems.Add(this.Episode?.AppropriateSeasonNumber.ToString() ?? ""); - lvi.SubItems.Add(this.Episode?.NumsAsString() ?? ""); - - if (this.Episode != null) - { - DateTime? dt = this.Episode.GetAirDateDT(true); - if ((dt != null) && (dt.Value.CompareTo(DateTime.MaxValue) != 0)) - lvi.SubItems.Add(dt.Value.ToShortDateString()); - else - lvi.SubItems.Add(""); - } - else - lvi.SubItems.Add(""); - - lvi.SubItems.Add(this.Destination.DirectoryName); - lvi.SubItems.Add(this.Path); - - if (string.IsNullOrEmpty(this.Path)) - lvi.BackColor = Helpers.WarningColor(); - - lvi.SubItems.Add(this.Destination.Name); - - lvi.Tag = this; - - return lvi; - } - } - - public string ScanListViewGroup => "lvgActionDownload"; - - public string TargetFolder - { - get - { - if (this.Destination == null) - return null; - return this.Destination.DirectoryName; - } - } - - #endregion - } -} +// +// Main website for TVRename is http://tvrename.com +// +// Source code available at https://github.com/TV-Rename/tvrename +// +// This code is released under GPLv3 https://github.com/TV-Rename/tvrename/blob/master/LICENSE.md +// + +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Drawing.Imaging; + +namespace TVRename +{ + using System; + using System.Windows.Forms; + using FileInfo = Alphaleonis.Win32.Filesystem.FileInfo; + using System.IO; + + public class ActionDownloadImage : Item, Action, ScanListItem + { + private readonly string Path; + private readonly FileInfo Destination; + private readonly ShowItem SI; + private readonly bool ShrinkLargeMede8erImage; + + public ActionDownloadImage(ShowItem si, ProcessedEpisode pe, FileInfo dest, string path) : this(si, pe, dest, path, false) { } + + public ActionDownloadImage(ShowItem si, ProcessedEpisode pe, FileInfo dest, string path, bool mede8erShrink) + { + this.Episode = pe; + this.SI = si; + this.Destination = dest; + this.Path = path; + this.ShrinkLargeMede8erImage = mede8erShrink; + } + + #region Action Members + + public bool Done { get; set; } + public bool Error { get; set; } + public string ErrorText { get; set; } + + public string Name => "Download"; + + public string ProgressText => this.Destination.Name; + + public double PercentDone => this.Done ? 100 : 0; + + public string produces => this.Destination.FullName; + + // 0 to 100 + public long SizeOfWork => 1000000; + + // http://www.codeproject.com/Articles/2941/Resizing-a-Photographic-image-with-GDI-for-NET + static Image MaxSize(Image imgPhoto, int Width, int Height) + { + int sourceWidth = imgPhoto.Width; + int sourceHeight = imgPhoto.Height; + + float nPercentW = ((float)Width / (float)sourceWidth); + float nPercentH = ((float)Height / (float)sourceHeight); + + //float nPercent = Math.Min(nPercentH, nPercentW); + int destWidth, destHeight; + + if (nPercentH < nPercentW) + { + destHeight = Height; + destWidth = (int)(sourceWidth * nPercentH); + } + else + { + destHeight = (int)(sourceHeight * nPercentW); + destWidth = Width; + } + + Bitmap bmPhoto = new Bitmap(destWidth, destHeight, PixelFormat.Format24bppRgb); + bmPhoto.SetResolution(imgPhoto.HorizontalResolution, imgPhoto.VerticalResolution); + + Graphics grPhoto = Graphics.FromImage(bmPhoto); + grPhoto.Clear(Color.Black); + grPhoto.InterpolationMode = InterpolationMode.HighQualityBicubic; + + grPhoto.DrawImage(imgPhoto, + new Rectangle(0, 0, destWidth, destHeight), + new Rectangle(0, 0, sourceWidth, sourceHeight), + GraphicsUnit.Pixel); + + grPhoto.Dispose(); + return bmPhoto; + } + + public bool Go(ref bool pause, TVRenameStats stats) + { + byte[] theData = TheTVDB.Instance.GetTVDBDownload(this.Path); + if ((theData == null) || (theData.Length == 0)) + { + this.ErrorText = "Unable to download " + this.Path; + this.Error = true; + this.Done = true; + return false; + } + + if (ShrinkLargeMede8erImage) + { + // shrink images down to a maximum size of 156x232 + Image im = new Bitmap(new MemoryStream(theData)); + if ((im.Width > 156) || (im.Height > 232)) + { + im = MaxSize(im, 156, 232); + + using (MemoryStream m = new MemoryStream()) + { + im.Save(m, ImageFormat.Jpeg); + theData = m.ToArray(); + } + } + } + + try + { + FileStream fs = new FileStream(this.Destination.FullName, FileMode.Create); + fs.Write(theData, 0, theData.Length); + fs.Close(); + } + catch (Exception e) + { + this.ErrorText = e.Message; + this.Error = true; + this.Done = true; + return false; + } + + + this.Done = true; + return true; + } + + #endregion + + #region Item Members + + public bool SameAs(Item o) + { + return (o is ActionDownloadImage) && ((o as ActionDownloadImage).Destination == this.Destination); + } + + public int Compare(Item o) + { + ActionDownloadImage dl = o as ActionDownloadImage; + return dl == null ? 0 : this.Destination.FullName.CompareTo(dl.Destination.FullName); + } + + #endregion + + #region ScanListItem Members + + public int IconNumber => 5; + + public ProcessedEpisode Episode { get; set; } + + public IgnoreItem Ignore + { + get + { + if (this.Destination == null) + return null; + return new IgnoreItem(this.Destination.FullName); + } + } + + public ListViewItem ScanListViewItem + { + get + { + ListViewItem lvi = new ListViewItem { + Text = (this.Episode != null) ? this.Episode.SI.ShowName : ((this.SI != null) ? this.SI.ShowName : "") + }; + + lvi.SubItems.Add(this.Episode?.AppropriateSeasonNumber.ToString() ?? ""); + lvi.SubItems.Add(this.Episode?.NumsAsString() ?? ""); + + if (this.Episode != null) + { + DateTime? dt = this.Episode.GetAirDateDT(true); + if ((dt != null) && (dt.Value.CompareTo(DateTime.MaxValue) != 0)) + lvi.SubItems.Add(dt.Value.ToShortDateString()); + else + lvi.SubItems.Add(""); + } + else + lvi.SubItems.Add(""); + + lvi.SubItems.Add(this.Destination.DirectoryName); + lvi.SubItems.Add(this.Path); + + if (string.IsNullOrEmpty(this.Path)) + lvi.BackColor = Helpers.WarningColor(); + + lvi.SubItems.Add(this.Destination.Name); + + lvi.Tag = this; + + return lvi; + } + } + + public string ScanListViewGroup => "lvgActionDownload"; + + public string TargetFolder + { + get + { + if (this.Destination == null) + return null; + return this.Destination.DirectoryName; + } + } + + #endregion + } +} diff --git a/TVRename#/ItemsAndActions/ActionItemSorter.cs b/TVRename#/ItemsAndActions/ActionItemSorter.cs index a8fb41c6b..319f56da1 100644 --- a/TVRename#/ItemsAndActions/ActionItemSorter.cs +++ b/TVRename#/ItemsAndActions/ActionItemSorter.cs @@ -26,7 +26,7 @@ private static int TypeNumber(Item a) return 2; if (a is ActionRSS) return 3; - if (a is ActionDownload) + if (a is ActionDownloadImage) return 4; if (a is ActionNFO) return 5; diff --git a/TVRename#/ItemsAndActions/ActionMede8erViewXML.cs b/TVRename#/ItemsAndActions/ActionMede8erViewXML.cs index c0caf2087..c863e5ad7 100644 --- a/TVRename#/ItemsAndActions/ActionMede8erViewXML.cs +++ b/TVRename#/ItemsAndActions/ActionMede8erViewXML.cs @@ -1,4 +1,4 @@ -// +// // Main website for TVRename is http://tvrename.com // // Source code available at https://github.com/TV-Rename/tvrename @@ -23,7 +23,7 @@ public ActionMede8erViewXML(FileInfo nfo, ShowItem si) { this.SI = si; this.Where = nfo; - snum = -1; + this.snum = -1; } public ActionMede8erViewXML(FileInfo nfo, ShowItem si, int snum) @@ -33,36 +33,21 @@ public ActionMede8erViewXML(FileInfo nfo, ShowItem si, int snum) this.snum = snum; } - public string produces - { - get { return this.Where.FullName; } - } + public string produces => this.Where.FullName; #region Action Members - public string Name - { - get { return "Write Mede8er View Data"; } - } + public string Name => "Write Mede8er View Data"; public bool Done { get; private set; } public bool Error { get; private set; } public string ErrorText { get; set; } - public string ProgressText - { - get { return this.Where.Name; } - } + public string ProgressText => this.Where.Name; - public double PercentDone - { - get { return this.Done ? 100 : 0; } - } + public double PercentDone => this.Done ? 100 : 0; - public long SizeOfWork - { - get { return 10000; } - } + public long SizeOfWork => 10000; public bool Go(ref bool pause, TVRenameStats stats) { @@ -148,7 +133,7 @@ public ListViewItem ScanListViewItem ListViewItem lvi = new ListViewItem(); lvi.Text = this.SI.ShowName; - if (snum > 0) { lvi.SubItems.Add(snum.ToString()); } else { lvi.SubItems.Add(""); } + lvi.SubItems.Add(this.snum > 0 ? this.snum.ToString() : ""); lvi.SubItems.Add(""); lvi.SubItems.Add(""); @@ -161,29 +146,15 @@ public ListViewItem ScanListViewItem } } - string ScanListItem.TargetFolder - { - get - { - if (this.Where == null) - return null; - return this.Where.DirectoryName; - } - } + string ScanListItem.TargetFolder => this.Where == null ? null : this.Where.DirectoryName; - public string ScanListViewGroup - { - get { return "lvgActionMeta"; } - } + public string ScanListViewGroup => "lvgActionMeta"; - public int IconNumber - { - get { return 7; } - } + public int IconNumber => 7; public ProcessedEpisode Episode { get; private set; } #endregion } -} \ No newline at end of file +} diff --git a/TVRename#/ItemsAndActions/ActionPyTivoMeta.cs b/TVRename#/ItemsAndActions/ActionPyTivoMeta.cs index 0e08cabdc..7cf8a167d 100644 --- a/TVRename#/ItemsAndActions/ActionPyTivoMeta.cs +++ b/TVRename#/ItemsAndActions/ActionPyTivoMeta.cs @@ -23,36 +23,21 @@ public ActionPyTivoMeta(FileInfo nfo, ProcessedEpisode pe) this.Where = nfo; } - public string produces - { - get { return this.Where.FullName; } - } + public string produces => this.Where.FullName; #region Action Members - public string Name - { - get { return "Write pyTivo Meta"; } - } + public string Name => "Write pyTivo Meta"; public bool Done { get; private set; } public bool Error { get; private set; } public string ErrorText { get; set; } - public string ProgressText - { - get { return this.Where.Name; } - } + public string ProgressText => this.Where.Name; - public double PercentDone - { - get { return this.Done ? 100 : 0; } - } + public double PercentDone => this.Done ? 100 : 0; - public long SizeOfWork - { - get { return 10000; } - } + public long SizeOfWork => 10000; public bool Go( ref bool pause, TVRenameStats stats) { @@ -74,15 +59,16 @@ public bool Go( ref bool pause, TVRenameStats stats) } // See: http://pytivo.sourceforge.net/wiki/index.php/Metadata - writer.WriteLine(string.Format("title : {0}", this.Episode.SI.ShowName)); - writer.WriteLine(string.Format("seriesTitle : {0}", this.Episode.SI.ShowName)); - writer.WriteLine(string.Format("episodeTitle : {0}", this.Episode.Name)); - writer.WriteLine(string.Format("episodeNumber : {0}{1:0#}", this.Episode.AppropriateSeasonNumber, this.Episode.AppropriateEpNum)); + writer.WriteLine($"title : {this.Episode.SI.ShowName}"); + writer.WriteLine($"seriesTitle : {this.Episode.SI.ShowName}"); + writer.WriteLine($"episodeTitle : {this.Episode.Name}"); + writer.WriteLine( + $"episodeNumber : {this.Episode.AppropriateSeasonNumber}{this.Episode.AppropriateEpNum:0#}"); writer.WriteLine("isEpisode : true"); - writer.WriteLine(string.Format("description : {0}", this.Episode.Overview)); + writer.WriteLine($"description : {this.Episode.Overview}"); if (this.Episode.FirstAired != null) - writer.WriteLine(string.Format("originalAirDate : {0:yyyy-MM-dd}T00:00:00Z",this.Episode.FirstAired.Value)); - writer.WriteLine(string.Format("callsign : {0}", this.Episode.SI.TheSeries().getNetwork())); + writer.WriteLine($"originalAirDate : {this.Episode.FirstAired.Value:yyyy-MM-dd}T00:00:00Z"); + writer.WriteLine($"callsign : {this.Episode.SI.TheSeries().getNetwork()}"); WriteEntries(writer, "vDirector", this.Episode.EpisodeDirector); WriteEntries(writer, "vWriter", this.Episode.Writer); @@ -100,12 +86,12 @@ private void WriteEntries(StreamWriter writer, string Heading, string Entries) if (string.IsNullOrEmpty(Entries)) return; if (!Entries.Contains("|")) - writer.WriteLine(string.Format("{0} : {1}", Heading, Entries)); + writer.WriteLine($"{Heading} : {Entries}"); else { foreach (string entry in Entries.Split('|')) if (!string.IsNullOrEmpty(entry)) - writer.WriteLine(string.Format("{0} : {1}", Heading, entry)); + writer.WriteLine($"{Heading} : {entry}"); } } @@ -177,15 +163,9 @@ string ScanListItem.TargetFolder } } - public string ScanListViewGroup - { - get { return "lvgActionMeta"; } - } + public string ScanListViewGroup => "lvgActionMeta"; - public int IconNumber - { - get { return 7; } - } + public int IconNumber => 7; public ProcessedEpisode Episode { get; private set; } diff --git a/TVRename#/ItemsAndActions/ActionRSS.cs b/TVRename#/ItemsAndActions/ActionRSS.cs index 8b46e538d..fe7d6d546 100644 --- a/TVRename#/ItemsAndActions/ActionRSS.cs +++ b/TVRename#/ItemsAndActions/ActionRSS.cs @@ -11,7 +11,7 @@ namespace TVRename using Alphaleonis.Win32.Filesystem; using System.Windows.Forms; - // MS_TODO: derive this from ActionDownload? + // MS_TODO: derive this from ActionDownloadImage? public class ActionRSS : Item, Action, ScanListItem { public RSSItem RSS; diff --git a/TVRename#/ItemsAndActions/ActionWriteMetadata.cs b/TVRename#/ItemsAndActions/ActionWriteMetadata.cs index 03bf99099..ea6557aab 100644 --- a/TVRename#/ItemsAndActions/ActionWriteMetadata.cs +++ b/TVRename#/ItemsAndActions/ActionWriteMetadata.cs @@ -1,4 +1,4 @@ -namespace TVRename +namespace TVRename { interface ActionWriteMetadata { diff --git a/TVRename#/TVRename#.csproj b/TVRename#/TVRename#.csproj index 5dc09f17a..40360877a 100644 --- a/TVRename#/TVRename#.csproj +++ b/TVRename#/TVRename#.csproj @@ -168,7 +168,7 @@ - + @@ -273,7 +273,7 @@ - + diff --git a/TVRename#/TVRename/LVResults.cs b/TVRename#/TVRename/LVResults.cs index 84c2a8b22..5614f1c66 100644 --- a/TVRename#/TVRename/LVResults.cs +++ b/TVRename#/TVRename/LVResults.cs @@ -26,7 +26,7 @@ public enum WhichResults public System.Collections.Generic.List CopyMove; public int Count; - public System.Collections.Generic.List Download; + public System.Collections.Generic.List Download; public ScanListItemList FlatList; public System.Collections.Generic.List Missing; public System.Collections.Generic.List NFO; @@ -52,7 +52,7 @@ public void Go(ListView lv, WhichResults which) this.RSS = new System.Collections.Generic.List(); this.CopyMove = new System.Collections.Generic.List(); this.Rename = new System.Collections.Generic.List(); - this.Download = new System.Collections.Generic.List(); + this.Download = new System.Collections.Generic.List(); this.NFO = new System.Collections.Generic.List(); this.PyTivoMeta = new System.Collections.Generic.List(); this.FlatList = new ScanListItemList(); @@ -104,8 +104,8 @@ public void Go(ListView lv, WhichResults which) else // copy/move this.CopyMove.Add(cmr); } - else if (action is ActionDownload) - this.Download.Add((ActionDownload) (action)); + else if (action is ActionDownloadImage) + this.Download.Add((ActionDownloadImage) (action)); else if (action is ActionRSS) this.RSS.Add((ActionRSS) (action)); else if (action is ItemMissing) diff --git a/TVRename#/TVRename/TVDoc.cs b/TVRename#/TVRename/TVDoc.cs index f6854f84c..7369ca50c 100644 --- a/TVRename#/TVRename/TVDoc.cs +++ b/TVRename#/TVRename/TVDoc.cs @@ -1577,9 +1577,9 @@ public ActionQueue[] ActionProcessorMakeQueues(ScanListItemList theList) if (action == null) continue; // skip non-actions - if ((action is ActionWriteMetadata) || (action is ItemDateTouch )) // base interface that all metadata actions are derived from + if ((action is ActionWriteMetadata) || (action is ActionDateTouch )) // base interface that all metadata actions are derived from queues[2].Actions.Add(action); - else if ((action is ActionDownload) || (action is ActionRSS)) + else if ((action is ActionDownloadImage) || (action is ActionRSS)) queues[3].Actions.Add(action); else if (action is ActionCopyMoveRename) queues[(action as ActionCopyMoveRename).QuickOperation() ? 1 : 0].Actions.Add(action); diff --git a/TVRename#/TheTVDB/TheTVDB.cs b/TVRename#/TheTVDB/TheTVDB.cs index ec96afb96..6aa584f2c 100644 --- a/TVRename#/TheTVDB/TheTVDB.cs +++ b/TVRename#/TheTVDB/TheTVDB.cs @@ -1353,9 +1353,7 @@ private SeriesInfo DownloadSeriesNow(int code, bool episodesToo, bool bannersToo } catch (WebException ex) { //no images for chosen language - logger.Trace("No images found for {0} in language {1}", APIRoot + "/series/" + code + "/images", TVSettings.Instance.PreferredLanguage); - logger.Warn(ex.Message); - + logger.Warn(ex, $"No images found for {APIRoot}/series/{code}/images in language {TVSettings.Instance.PreferredLanguage}"); } diff --git a/TVRename#/Utility/Timezone.cs b/TVRename#/Utility/Timezone.cs index e728b68f0..0b8b27c93 100644 --- a/TVRename#/Utility/Timezone.cs +++ b/TVRename#/Utility/Timezone.cs @@ -6,7 +6,7 @@ // This code is released under GPLv3 https://github.com/TV-Rename/tvrename/blob/master/LICENSE.md // using System; - +using System.Linq; using Microsoft.Win32; // for RegistryKey // Do conversions between timezones, handling daylight savings time (summer time) at both ends. @@ -79,6 +79,16 @@ public static string DefaultTimeZone() return "Eastern Standard Time"; } + public static string TimeZoneForNetwork(string network) + { + 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" }; + string[] AusTV = { "ABC4Kids", "Stan", "Showcase (AU)", "PBS Kids Sprout", "SBS (AU)", "Nine Network", "ABC1", "ABC (AU)" }; + if (UKTV.Contains(network)) return "GMT Standard Time"; + if (AusTV.Contains(network)) return "AUS Eastern Standard Time"; + + return DefaultTimeZone(); + } + public static DateTime AdjustTZTimeToLocalTime(DateTime dt, TimeZone theirTimeZone) // set tz to 0 to not correct for timezone { if (theirTimeZone == null)