Skip to content

Commit

Permalink
Merge pull request #380 from MarkSummerville/25
Browse files Browse the repository at this point in the history
Quick updates
  • Loading branch information
SirSparkles authored Apr 29, 2018
2 parents d4aeb93 + 6842192 commit f3e200f
Show file tree
Hide file tree
Showing 13 changed files with 81 additions and 80 deletions.
3 changes: 1 addition & 2 deletions TVRename#/App/AutoFolderMonitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ void mScanDelayTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)

mUI.Invoke(mUI.AFMDoAll);

if (TVSettings.Instance.MonitoredFoldersScanType == TVSettings.ScanType.Full)
mDoc.ExportMissingXML(TVSettings.Instance.MonitoredFoldersScanType); // Export Missing episodes to XML if we scanned all
mDoc.OutputActionXML(TVSettings.Instance.MonitoredFoldersScanType); // Export Missing episodes to XML

}

Expand Down
6 changes: 4 additions & 2 deletions TVRename#/App/CommandLineArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public enum MissingFolderBehavior
Create
}

public bool Help { get; }
public bool Hide { get; }
public MissingFolderBehavior MissingFolder { get; set; } // TODO: Make read only
public bool RenameCheck { get; }
Expand All @@ -38,6 +39,7 @@ public enum MissingFolderBehavior
/// <param name="args">The command line arguments.</param>
public CommandLineArgs(ReadOnlyCollection<string> args)
{
this.Help = args.Contains("/?", StringComparer.OrdinalIgnoreCase);
this.Hide = args.Contains("/hide", StringComparer.OrdinalIgnoreCase);
this.RenameCheck = !args.Contains("/norenamecheck", StringComparer.OrdinalIgnoreCase);
this.Quit = args.Contains("/quit", StringComparer.OrdinalIgnoreCase);
Expand Down Expand Up @@ -76,11 +78,11 @@ public static string Helptext()
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("/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("/norenamecheck requests an existing TV Rename session to scan without renaming.");
output.AppendLine("");
output.AppendLine("Further information is available at http://www.tvrename.com/cmd-line");

Expand Down
5 changes: 3 additions & 2 deletions TVRename#/App/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ private static void Main(string[] args)
if (args.Contains("/?", StringComparer.OrdinalIgnoreCase))
{
Logger.Info(CommandLineArgs.Helptext());
Console.WriteLine(CommandLineArgs.Helptext());
}
Console.Out.WriteLine(CommandLineArgs.Helptext());
return;
}
// Check if an application instance is already running
Mutex mutex = new Mutex(true, "TVRename", out bool newInstance);

Expand Down
12 changes: 2 additions & 10 deletions TVRename#/Finders/FileFinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,23 +257,15 @@ private bool ReviewFile(ItemMissing me, ItemList addTo, DirCacheEntry dce)

try
{
if (!dce.HasUsefulExtension_NotOthersToo) // not a useful file extension
return false;
if (TVSettings.Instance.IgnoreSamples && dce.LowerName.Contains("sample") &&
((dce.Length / (1024 * 1024)) < TVSettings.Instance.SampleFileMaxSizeMB))
return false;
if (FileHelper.IgnoreFile(dce.TheFile))return false;

//do any of the possible names for the series match the filename?
matched = (me.Episode.SI.getSimplifiedPossibleShowNames()
.Any(name => FileHelper.SimplifyAndCheckFilename(dce.SimplifiedFullName, name)));

if (matched)
{
if (dce.LowerName.StartsWith("-.") && (dce.Length / 1024 < 10))
{
logger.Info($"Ignoring matched file {dce.TheFile.FullName} as it looks like a Mac Temp File");
return false;
}


if ((TVDoc.FindSeasEp(dce.TheFile, out int seasF, out int epF, out int maxEp, me.Episode.SI) && (seasF == season) &&
(epF == epnum)) ||
Expand Down
4 changes: 4 additions & 0 deletions TVRename#/Forms/AutoAddShow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public partial class AutoAddShow : Form
{
private readonly ShowItem mSI;
private readonly TheTVDBCodeFinder mTCCF;
private readonly string originalHint;

public AutoAddShow(string hint)
{
Expand All @@ -25,6 +26,8 @@ public AutoAddShow(string hint)
this.cbDirectory.Items.AddRange(TVSettings.Instance.LibraryFoldersNames.ToArray());
this.cbDirectory.SelectedIndex = 0;
this.cbDirectory.ResumeLayout();

this.originalHint = hint;
}

private void MTCCF_SelectionChanged(object sender, EventArgs e)
Expand All @@ -44,6 +47,7 @@ private void SetShowItem()
this.mSI.PadSeasonToTwoDigits = true;
//Set Default Timezone based on Network
this.mSI.ShowTimeZone = TimeZone.TimeZoneForNetwork(this.mTCCF.SelectedShow()?.getNetwork());
if (!this.originalHint.Contains(this.mTCCF.SelectedShow().Name, StringComparison.OrdinalIgnoreCase)) this.mSI.AliasNames.Add(this.originalHint);

}

Expand Down
49 changes: 24 additions & 25 deletions TVRename#/Forms/BugReport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,36 +42,35 @@ private void bnCreate_Click(object sender, System.EventArgs e)

if (this.cbSettings.Checked)
{
txt.Append("==== Settings Files ====" + "\r\n");
txt.Append("\r\n");
txt.Append("---- TVRenameSettings.xml" + "\r\n");
txt.Append("\r\n");
txt.AppendLine("==== Settings Files ====" );
txt.AppendLine();
txt.AppendLine("---- TVRenameSettings.xml" );
txt.AppendLine();
try
{
using (StreamReader sr = new StreamReader(PathManager.TVDocSettingsFile.FullName))
txt.Append(sr.ReadToEnd());
txt.AppendLine(sr.ReadToEnd());

txt.Append("\r\n");
}
catch
{
txt.Append("Error reading TVRenameSettings.xml\r\n");
txt.AppendLine("Error reading TVRenameSettings.xml");
}
txt.Append("\r\n");
txt.AppendLine("");
}

if (this.cbFOScan.Checked || this.cbFolderScan.Checked)
{
txt.Append("==== Filename processors ====\r\n");
txt.AppendLine("==== Filename processors ====");
foreach (FilenameProcessorRE s in TVSettings.Instance.FNPRegexs)
txt.Append((s.Enabled ? "Enabled" : "Disabled") + " \"" + s.RE + "\" " + (s.UseFullPath ? "(FullPath)" : "") + "\r\n");
txt.Append("\r\n");
txt.AppendLine((s.Enabled ? "Enabled" : "Disabled") + " \"" + s.RE + "\" " + (s.UseFullPath ? "(FullPath)" : "") );
txt.AppendLine();
}

if (this.cbFOScan.Checked)
{
txt.Append("==== Finding & Organising Directory Scan ====" + "\r\n");
txt.Append("\r\n");
txt.AppendLine( "==== Finding & Organising Directory Scan ====");
txt.AppendLine();

DirCache dirC = new DirCache();
foreach (string efi in this.mDoc.SearchFolders)
Expand All @@ -80,15 +79,15 @@ private void bnCreate_Click(object sender, System.EventArgs e)
foreach (DirCacheEntry fi in dirC)
{
bool r = TVDoc.FindSeasEp(fi.TheFile, out int seas, out int ep, out int maxEp, null);
bool useful = fi.HasUsefulExtension_NotOthersToo;
txt.Append(fi.TheFile.FullName + " (" + (r ? "OK" : "No") + " " + seas + "," + ep + "," + maxEp + " " + (useful ? fi.TheFile.Extension : "-") + ")" + "\r\n");
bool useful = TVSettings.Instance.UsefulExtension(fi.TheFile.Extension, false);
txt.AppendLine(fi.TheFile.FullName + " (" + (r ? "OK" : "No") + " " + seas + "," + ep + "," + maxEp + " " + (useful ? fi.TheFile.Extension : "-") + ")" );
}
txt.Append("\r\n");
txt.AppendLine();
}

if (this.cbFolderScan.Checked)
{
txt.Append("==== Media Folders Directory Scan ====" + "\r\n");
txt.AppendLine("==== Media Folders Directory Scan ====" );

foreach (ShowItem si in this.mDoc.GetShowItems(true))
{
Expand All @@ -100,26 +99,26 @@ private void bnCreate_Click(object sender, System.EventArgs e)

foreach (string folder in si.AllFolderLocations()[snum])
{
txt.Append(si.TVDBCode + " : " + si.ShowName + " : S" + snum + "\r\n");
txt.Append("Folder: " + folder);
txt.Append("\r\n");
txt.AppendLine(si.TVDBCode + " : " + si.ShowName + " : S" + snum );
txt.AppendLine("Folder: " + folder);

DirCache files = new DirCache();
if (Directory.Exists(folder))
files.AddFolder(null, 0, 0, folder, true);
foreach (DirCacheEntry fi in files)
{
bool r = TVDoc.FindSeasEp(fi.TheFile, out int seas, out int ep, out int maxEp, si);
bool useful = fi.HasUsefulExtension_NotOthersToo;
txt.Append(fi.TheFile.FullName + " (" + (r ? "OK" : "No") + " " + seas + "," + ep + "," + maxEp + " " + (useful ? fi.TheFile.Extension : "-") + ")" + "\r\n");
bool useful = TVSettings.Instance.UsefulExtension(fi.TheFile.Extension, false);
txt.AppendLine(fi.TheFile.FullName + " (" + (r ? "OK" : "No") + " " + seas + "," + ep + "," + maxEp + " " + (useful ? fi.TheFile.Extension : "-") + ")" );
}
txt.Append("\r\n");
txt.AppendLine();
}
}
txt.Append("\r\n");
txt.AppendLine();
}
this.mDoc.UnlockShowItems();

txt.Append("\r\n");
txt.AppendLine();
}

this.txtEmailText.Text = txt.ToString();
Expand Down
17 changes: 7 additions & 10 deletions TVRename#/Forms/UI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1314,6 +1314,7 @@ public void lvWhenToWatch_DoubleClick(object sender, System.EventArgs e)
break;
case TVSettings.WTWDoubleClickAction.Scan:
this.Scan(new List<ShowItem> {ei.SI},false);
this.mDoc.OutputActionXML(TVSettings.ScanType.SingleShow);
this.tabControl1.SelectTab(this.tbAllInOne);
break;
}
Expand Down Expand Up @@ -1885,7 +1886,8 @@ public void showRightClickMenu_ItemClicked(object sender, System.Windows.Forms.T
{
this.Scan(mLastShowsClicked,false);
this.tabControl1.SelectTab(this.tbAllInOne);
}
this.mDoc.OutputActionXML(TVSettings.ScanType.SingleShow);
}

break;
}
Expand Down Expand Up @@ -2952,7 +2954,7 @@ public void Scan(bool unattended)
{
this.tabControl1.SelectedTab = this.tbAllInOne;
this.Scan(null, unattended);
this.mDoc.ExportMissingXML(TVSettings.ScanType.Full ); //Save missing shows to XML
this.mDoc.OutputActionXML(TVSettings.ScanType.Full ); //Save missing shows to XML
}

public void QuickScan()
Expand All @@ -2969,6 +2971,7 @@ public void RecentScan()
public void RecentScan(bool unattended)
{
Scan(this.mDoc.getRecentShows(),unattended );
this.mDoc.OutputActionXML(TVSettings.ScanType.Recent);
}

private void Scan(List<ShowItem> shows,bool unattended)
Expand Down Expand Up @@ -3007,13 +3010,7 @@ private void GetNewShows(bool unattended)

FileInfo fi = new FileInfo(filePath);

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))
continue;
if (FileHelper.IgnoreFile(fi)) continue;

if (!LookForSeries(fi.Name)) possibleShowNames.Add(fi.RemoveExtension() + ".");

Expand Down Expand Up @@ -3181,7 +3178,7 @@ public void QuickScan(bool unattended)
this.LessBusy();
this.FillMyShows(); // scanning can download more info to be displayed in my shows
this.FillActionList();
this.mDoc.ExportMissingXML(TVSettings.ScanType.Quick); //Save missing shows to XML
this.mDoc.OutputActionXML(TVSettings.ScanType.Quick); //Save missing shows to XML
}


Expand Down
16 changes: 12 additions & 4 deletions TVRename#/ItemsAndActions/ActionItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,16 @@ protected void DoTidyup(DirectoryInfo di)
return;

//if there are sub-directories then we shouldn't remove this one
if (di.GetDirectories().Length > 0)
return;
DirectoryInfo[] directories = di.GetDirectories();
foreach (DirectoryInfo subdi in directories)
{
bool okToDelete = this.Tidyup.EmptyIgnoreWordsArray.Any(word => subdi.Name.Contains(word,StringComparison.OrdinalIgnoreCase));

if (!okToDelete)
return;
}
//we know that each subfolder is OK to delete


//if the directory is the root download folder do not delete
if (TVSettings.Instance.DownloadFoldersNames.Contains(di.FullName))
Expand All @@ -141,7 +149,7 @@ protected void DoTidyup(DirectoryInfo di)
if (files.Length == 0)
{
// its empty, so just delete it
di.Delete();
DeleteOrRecycleFolder(di);
return;
}

Expand All @@ -158,7 +166,7 @@ protected void DoTidyup(DirectoryInfo di)
continue; // onto the next file

// look in the filename
if (this.Tidyup.EmptyIgnoreWordsArray.Any(word => fi.Name.Contains(word)))
if (this.Tidyup.EmptyIgnoreWordsArray.Any(word => fi.Name.Contains(word,StringComparison.OrdinalIgnoreCase)))
okToDelete = true;

if (!okToDelete)
Expand Down
6 changes: 3 additions & 3 deletions TVRename#/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
[assembly: Guid("3b5746c1-a5f7-48c2-a8de-95619489049b")]
[assembly: NeutralResourcesLanguageAttribute("")]

[assembly: AssemblyVersion("2.4.1.0")]
[assembly: AssemblyFileVersion("2.4.1")]
[assembly: AssemblyInformationalVersion("2.4.1")] // Display version
[assembly: AssemblyVersion("2.4.2.0")]
[assembly: AssemblyFileVersion("2.4.2")]
[assembly: AssemblyInformationalVersion("2.4.2")] // Display version
3 changes: 2 additions & 1 deletion TVRename#/Settings/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,8 @@ public enum ScanType
{
Full,
Recent,
Quick
Quick,
SingleShow
}

#endregion
Expand Down
14 changes: 3 additions & 11 deletions TVRename#/TVRename/TVDoc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1449,7 +1449,7 @@ public bool LoadXMLSettings(FileInfo from)
return true;
}

public void ExportMissingXML(TVSettings.ScanType st)
public void OutputActionXML(TVSettings.ScanType st)
{

List<ActionListExporter> lup = new List<ActionListExporter> { new MissingXML(TheActionList),new MissingCSV(this.TheActionList),new CopyMoveXML(this.TheActionList),new RenamingXML(this.TheActionList) };
Expand Down Expand Up @@ -2248,11 +2248,7 @@ public void FindUnusedFilesInDLDirectory(List<ShowItem> showList)

FileInfo fi = new FileInfo(filePath);

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))
continue;
if (FileHelper.IgnoreFile(fi)) continue;

List<ShowItem> matchingShows = new List<ShowItem>();

Expand Down Expand Up @@ -2979,11 +2975,7 @@ private List<ShowItem> getShowsThatHaveDownloads()

FileInfo fi = new FileInfo(filePath);

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))
continue;
if (FileHelper.IgnoreFile(fi)) continue;

foreach (ShowItem si in this.ShowItems)
{
Expand Down
10 changes: 0 additions & 10 deletions TVRename#/Utility/DirCacheEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,15 @@ namespace TVRename
{
public class DirCacheEntry
{
public bool HasUsefulExtension_NotOthersToo;
public bool HasUsefulExtension_OthersToo;
public Int64 Length;
public string LowerName;
public string SimplifiedFullName;
public FileInfo TheFile;

public DirCacheEntry(FileInfo f)
{
this.TheFile = f;
this.SimplifiedFullName = Helpers.SimplifyName(f.FullName);
this.LowerName = f.Name.ToLower();
this.Length = f.Length;

if (TVSettings.Instance == null)
return;

this.HasUsefulExtension_NotOthersToo = TVSettings.Instance.UsefulExtension(f.Extension, false);
this.HasUsefulExtension_OthersToo = this.HasUsefulExtension_NotOthersToo | TVSettings.Instance.UsefulExtension(f.Extension, true);
}
}
}
Loading

0 comments on commit f3e200f

Please sign in to comment.