Skip to content

Commit

Permalink
Merge pull request #359 from MarkSummerville/DVDOrderFix
Browse files Browse the repository at this point in the history
Latest Updates
  • Loading branch information
SirSparkles authored Mar 15, 2018
2 parents c7457ce + e1d66f9 commit 8d358fb
Show file tree
Hide file tree
Showing 128 changed files with 2,548 additions and 972 deletions.
3 changes: 1 addition & 2 deletions TVRename#/App/ApplicationBase.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Alphaleonis.Win32.Filesystem;
using Microsoft.VisualBasic.ApplicationServices;
Expand Down Expand Up @@ -115,7 +114,7 @@ protected override void OnCreateMainForm()
convertSeriesTimeZones(doc, TheTVDB.Instance);

// Show user interface
UI ui = new UI(doc, (TVRenameSplash)this.SplashScreen);
UI ui = new UI(doc, (TVRenameSplash)this.SplashScreen, !clargs.Unattended && !clargs.Hide);

// Bind IPC actions to the form, this allows another instance to trigger form actions
RemoteClient.Bind(ui, doc);
Expand Down
3 changes: 1 addition & 2 deletions TVRename#/App/AutoFolderMonitor.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.IO;
using Alphaleonis.Win32.Filesystem;
using Directory = Alphaleonis.Win32.Filesystem.Directory;
using File = Alphaleonis.Win32.Filesystem.File;

Expand Down
3 changes: 2 additions & 1 deletion TVRename#/App/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ static void GlobalExceptionHandler(object sender, UnhandledExceptionEventArgs ar
{
Exception e = (Exception) args.ExceptionObject;
Logger.Fatal(e,"UNHANDLED ERROR");
}
Environment.Exit(1);
}
}

}
4 changes: 2 additions & 2 deletions TVRename#/Custom Controls/ListViewFlickerFree.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//
// Main website for TVRename is http://tvrename.com
//
// Source code available at http://code.google.com/p/tvrename/
// Source code available at https://github.com/TV-Rename/tvrename
//
// This code is released under GPLv3 http://www.gnu.org/licenses/gpl.html
// This code is released under GPLv3 https://github.com/TV-Rename/tvrename/blob/master/LICENSE.md
//
namespace TVRename
{
Expand Down
4 changes: 2 additions & 2 deletions TVRename#/Custom Controls/MyListView.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//
// Main website for TVRename is http://tvrename.com
//
// Source code available at http://code.google.com/p/tvrename/
// Source code available at https://github.com/TV-Rename/tvrename
//
// This code is released under GPLv3 http://www.gnu.org/licenses/gpl.html
// This code is released under GPLv3 https://github.com/TV-Rename/tvrename/blob/master/LICENSE.md
//

using System;
Expand Down
4 changes: 2 additions & 2 deletions TVRename#/Custom Controls/TheTVDBCodeFinder.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions TVRename#/Custom Controls/TheTVDBCodeFinder.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//
// Main website for TVRename is http://tvrename.com
//
// Source code available at http://code.google.com/p/tvrename/
// Source code available at https://github.com/TV-Rename/tvrename
//
// This code is released under GPLv3 http://www.gnu.org/licenses/gpl.html
// This code is released under GPLv3 https://github.com/TV-Rename/tvrename/blob/master/LICENSE.md
//
using System;
using System.Text.RegularExpressions;
Expand Down Expand Up @@ -105,13 +105,13 @@ private void DoFind(bool chooseOnlyMatch)
int num = kvp.Key;
string show = kvp.Value.Name;
show = Helpers.RemoveDiacritics(show);
string s = num + " " + show;
string s = num + " " + show.Replace(".", " ");

string simpleS = Regex.Replace(s.ToLower(), "[^\\w ]", "");

bool numberMatch = numeric && num == matchnum;

if (numberMatch || (!numeric && (simpleS.Contains(Regex.Replace(what, "[^\\w ]", "")))) || (numeric && show.Contains(what)))
string searchTerm = Regex.Replace(what, "[^\\w ]", "");
if (numberMatch || (!numeric && (simpleS.Contains(searchTerm))) || (numeric && show.Contains(what)))
{
ListViewItem lvi = new ListViewItem();
lvi.Text = num.ToString();
Expand Down
2 changes: 0 additions & 2 deletions TVRename#/DownloadIdentifers/DownloadEpisodeJPG.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using FileInfo = Alphaleonis.Win32.Filesystem.FileInfo;


Expand Down
2 changes: 0 additions & 2 deletions TVRename#/DownloadIdentifers/DownloadFanartJPG.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using FileInfo = Alphaleonis.Win32.Filesystem.FileInfo;

namespace TVRename
Expand Down
3 changes: 0 additions & 3 deletions TVRename#/DownloadIdentifers/DownloadIdentifier.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using System;
using System.Collections.Generic;
using System.Text;
using FileInfo = Alphaleonis.Win32.Filesystem.FileInfo;

namespace TVRename
Expand Down
2 changes: 0 additions & 2 deletions TVRename#/DownloadIdentifers/DownloadIdentifiersController.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using FileInfo = Alphaleonis.Win32.Filesystem.FileInfo;

namespace TVRename
Expand Down
2 changes: 0 additions & 2 deletions TVRename#/DownloadIdentifers/DownloadJolderJPG.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using FileInfo = Alphaleonis.Win32.Filesystem.FileInfo;

namespace TVRename
Expand Down
9 changes: 2 additions & 7 deletions TVRename#/DownloadIdentifers/DownloadMede8erMetaData.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using FileSystemInfo = Alphaleonis.Win32.Filesystem.FileSystemInfo;
using Directory = Alphaleonis.Win32.Filesystem.Directory;
using DirectoryInfo = Alphaleonis.Win32.Filesystem.DirectoryInfo;
using FileInfo = Alphaleonis.Win32.Filesystem.FileInfo;

namespace TVRename
Expand Down Expand Up @@ -40,7 +35,7 @@ public override ItemList ProcessShow(ShowItem si, bool forceRefresh)


//Updates requested by [email protected] on 18/4/2013
FileInfo viewxml = FileHelper.FileInFolder(si.AutoAdd_FolderBase, "view.xml");
FileInfo viewxml = FileHelper.FileInFolder(si.AutoAdd_FolderBase, "View.xml");
if ((!viewxml.Exists) && (!this.doneFiles.Contains(viewxml.FullName)))
{
this.doneFiles.Add(viewxml.FullName);
Expand All @@ -61,7 +56,7 @@ public override ItemList ProcessSeason(ShowItem si, string folder, int snum, boo
ItemList TheActionList = new ItemList();

//Updates requested by [email protected] on 18/4/2013
FileInfo viewxml = FileHelper.FileInFolder(folder, "view.xml");
FileInfo viewxml = FileHelper.FileInFolder(folder, "View.xml");
if (!viewxml.Exists) TheActionList.Add(new ActionMede8erViewXML(viewxml, si, snum));


Expand Down
2 changes: 0 additions & 2 deletions TVRename#/DownloadIdentifers/DownloadSeriesJPG.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using FileInfo = Alphaleonis.Win32.Filesystem.FileInfo;

namespace TVRename
Expand Down
3 changes: 1 addition & 2 deletions TVRename#/DownloadIdentifers/DownloadXBMCImages.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Globalization;
using FileInfo = Alphaleonis.Win32.Filesystem.FileInfo;

Expand Down Expand Up @@ -171,7 +170,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, dbep.SI.GetTimeZone()));
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);
if (b != null) theActionList.Add(b);
}
Expand Down
3 changes: 1 addition & 2 deletions TVRename#/DownloadIdentifers/DownloadXBMCMetaData.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System;
using System.Collections.Generic;
using System.Text;
using System.Globalization;
using FileInfo = Alphaleonis.Win32.Filesystem.FileInfo;

Expand Down
3 changes: 0 additions & 3 deletions TVRename#/DownloadIdentifers/DownloadpyTivoMetaData.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using System;
using System.Collections.Generic;
using System.Text;
using FileInfo = Alphaleonis.Win32.Filesystem.FileInfo;

namespace TVRename
Expand Down
2 changes: 1 addition & 1 deletion TVRename#/DownloadIdentifers/IncorrectFileDates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public override ItemList ProcessShow(ShowItem si, bool forceRefresh)

public override ItemList ProcessSeason(ShowItem si, string folder, int snum, bool forceRefresh)
{
DateTime? newUpdateTime = si.TheSeries().Seasons[snum].LastAiredDate();
DateTime? newUpdateTime = si.GetSeason(snum).LastAiredDate();

if (TVSettings.Instance.CorrectFileDates && newUpdateTime.HasValue)
{
Expand Down
1 change: 0 additions & 1 deletion TVRename#/Exporter/Exporter.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;

namespace TVRename
Expand Down
7 changes: 2 additions & 5 deletions TVRename#/Exporter/MissingXML.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Xml;

namespace TVRename
Expand Down Expand Up @@ -36,8 +33,8 @@ public override void Run(ItemList TheActionList)

XMLHelper.WriteElementToXML(writer,"id",Missing.Episode.SI.TVDBCode);
XMLHelper.WriteElementToXML(writer, "title",Missing.Episode.TheSeries.Name);
XMLHelper.WriteElementToXML(writer, "season", Helpers.pad(Missing.Episode.SeasonNumber));
XMLHelper.WriteElementToXML(writer, "episode", Helpers.pad(Missing.Episode.EpNum));
XMLHelper.WriteElementToXML(writer, "season", Helpers.pad(Missing.Episode.AppropriateSeasonNumber));
XMLHelper.WriteElementToXML(writer, "episode", Helpers.pad(Missing.Episode.AppropriateEpNum));
XMLHelper.WriteElementToXML(writer, "episodeName",Missing.Episode.Name);
XMLHelper.WriteElementToXML(writer, "description",Missing.Episode.Overview);

Expand Down
3 changes: 0 additions & 3 deletions TVRename#/Exporter/ShowsTXT.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace TVRename
{
Expand Down
6 changes: 2 additions & 4 deletions TVRename#/Exporter/UpcomingRSS.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Xml;

namespace TVRename
Expand Down Expand Up @@ -41,9 +39,9 @@ protected override bool Generate(System.IO.Stream str, List<ProcessedEpisode> el

writer.WriteStartElement("item");

XMLHelper.WriteElementToXML(writer,"title",ei.HowLong() + " " + ei.DayOfWeek() + " " + ei.TimeOfDay() + " " + niceName);
XMLHelper.WriteElementToXML(writer,"title",ei.HowLong() + " " + ei.DayOfWeek() + " " + ei.TimeOfDay() + " " + ei.SI.ShowName + " " + niceName);
XMLHelper.WriteElementToXML(writer, "link", TheTVDB.Instance.WebsiteURL(ei.TheSeries.TVDBCode, ei.SeasonID, false));
XMLHelper.WriteElementToXML(writer,"description",niceName + "<br/>" + ei.Overview);
XMLHelper.WriteElementToXML(writer,"description", ei.SI.ShowName + "<br/>" + niceName + "<br/>" + ei.Overview);

writer.WriteStartElement("pubDate");
DateTime? dt = ei.GetAirDateDT(true);
Expand Down
6 changes: 2 additions & 4 deletions TVRename#/Exporter/UpcomingXML.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Xml;
using System.Windows.Forms;
using FileInfo = Alphaleonis.Win32.Filesystem.FileInfo;
Expand Down Expand Up @@ -35,8 +33,8 @@ protected override bool Generate(System.IO.Stream str, List<ProcessedEpisode> e
writer.WriteStartElement("item");
XMLHelper.WriteElementToXML(writer,"id",ei.TheSeries.TVDBCode);
XMLHelper.WriteElementToXML(writer,"SeriesName",ei.TheSeries.Name);
XMLHelper.WriteElementToXML(writer,"SeasonNumber",Helpers.pad(ei.SeasonNumber));
XMLHelper.WriteElementToXML(writer, "EpisodeNumber", Helpers.pad(ei.EpNum));
XMLHelper.WriteElementToXML(writer,"SeasonNumber",Helpers.pad(ei.AppropriateSeasonNumber));
XMLHelper.WriteElementToXML(writer, "EpisodeNumber", Helpers.pad(ei.AppropriateEpNum));
XMLHelper.WriteElementToXML(writer,"EpisodeName",ei.Name);

writer.WriteStartElement("available");
Expand Down
59 changes: 48 additions & 11 deletions TVRename#/Finders/FileFinder.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Text.RegularExpressions;
using FileInfo = Alphaleonis.Win32.Filesystem.FileInfo;
using DirectoryInfo = Alphaleonis.Win32.Filesystem.DirectoryInfo;
using System.Linq;
Expand Down Expand Up @@ -223,10 +221,9 @@ public void KeepTogether(ItemList Actionlist)
// if so, add a rcitem for copy to "fi"
public bool FindMissingEp(DirCache dirCache, ItemMissing me, ItemList addTo, ActionCopyMoveRename.Op whichOp)
{
int season = me.Episode.SeasonNumber;
int season = me.Episode.AppropriateSeasonNumber;

//String ^toName = FilenameFriendly(Settings->NamingStyle->NameFor(me->PE));
int epnum = me.Episode.EpNum;
int epnum = me.Episode.AppropriateEpNum;

// TODO: find a 'best match', or use first ?

Expand All @@ -249,22 +246,62 @@ public bool FindMissingEp(DirCache dirCache, ItemMissing me, ItemList addTo, Act

if (matched)
{
if ((TVDoc.FindSeasEp(dce.TheFile, out int seasF, out int epF, me.Episode.SI) && (seasF == season) && (epF == epnum)) || (me.Episode.SI.UseSequentialMatch && TVDoc.MatchesSequentialNumber(dce.TheFile.Name, ref seasF, ref epF, me.Episode) && (seasF == season) && (epF == epnum)))
if ((TVDoc.FindSeasEp(dce.TheFile, out int seasF, out int epF, out int maxEp, me.Episode.SI) && (seasF == season) && (epF == epnum)) ||
(me.Episode.SI.UseSequentialMatch && TVDoc.MatchesSequentialNumber(dce.TheFile.Name, ref seasF, ref epF, me.Episode) && (seasF == season) && (epF == epnum)))
{
FileInfo fi = new FileInfo(me.TheFileNoExt + dce.TheFile.Extension);

FileInfo fi;
if (maxEp !=-1 && TVSettings.Instance.AutoMergeEpisodes)
{
ShowRule sr = new ShowRule();
sr.DoWhatNow = RuleAction.kMerge;
sr.First = epF;
sr.Second = maxEp;
if (!me.Episode.SI.SeasonRules.ContainsKey(seasF)) me.Episode.SI.SeasonRules[seasF] = new List<ShowRule>();

me.Episode.SI.SeasonRules[seasF].Add(sr);
logger.Info($"Added new rule automatically for {sr}");

//Regenerate the episodes with the new rule added
this.mDoc.GenerateEpisodeDict(me.Episode.SI);

//Get the newly created processed episode we are after
List<ProcessedEpisode> newSeason = this.mDoc.GetShowItem(me.Episode.SI.TVDBCode).SeasonEpisodes[seasF];
ProcessedEpisode newPE = me.Episode;

foreach (ProcessedEpisode pe in newSeason)
{
if (pe.AppropriateEpNum == epF && pe.EpNum2 == maxEp) newPE = pe;
}


me = new ItemMissing(newPE, me.TargetFolder, TVSettings.Instance.FilenameFriendly(TVSettings.Instance.NamingStyle.NameForExt(newPE)));
}
fi = new FileInfo(me.TheFileNoExt + dce.TheFile.Extension);



if (TVSettings.Instance.PreventMove )
{
//We do not want to move the file, just rename it
fi = new FileInfo(dce.TheFile.DirectoryName + System.IO.Path.DirectorySeparatorChar + me.filename + dce.TheFile.Extension);
}

// don't remove the base search folders
bool doTidyup = true;
foreach (String folder in this.mDoc.SearchFolders)
foreach (string folder in this.mDoc.SearchFolders)
{
// http://stackoverflow.com/questions/1794025/how-to-check-whether-2-directoryinfo-objects-are-pointing-to-the-same-directory
if (String.Compare(folder.ToLower().TrimEnd('\\'), fi.Directory.FullName.ToLower().TrimEnd('\\'), StringComparison.InvariantCultureIgnoreCase) == 0)

if (folder.SameDirectoryLocation(fi.Directory.FullName))


{
doTidyup = false;
break;
}
}
addTo.Add(new ActionCopyMoveRename(whichOp, dce.TheFile, fi, me.Episode, doTidyup ? TVSettings.Instance.Tidyup : null));
if(dce.TheFile.FullName != fi.FullName)
addTo.Add(new ActionCopyMoveRename(whichOp, dce.TheFile, fi, me.Episode, doTidyup ? TVSettings.Instance.Tidyup : null));

DownloadIdentifiersController di = new DownloadIdentifiersController();

Expand Down
4 changes: 0 additions & 4 deletions TVRename#/Finders/Finder.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace TVRename
{
abstract class Finder
Expand Down
Loading

0 comments on commit 8d358fb

Please sign in to comment.