Skip to content

Commit

Permalink
Merge pull request #363 from MarkSummerville/master
Browse files Browse the repository at this point in the history
Latest Changes
  • Loading branch information
SirSparkles authored Mar 19, 2018
2 parents e1b5388 + e6d8488 commit 21f259a
Show file tree
Hide file tree
Showing 19 changed files with 889 additions and 32 deletions.
16 changes: 15 additions & 1 deletion TVRename#/Custom Controls/TheTVDBCodeFinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

namespace TVRename
{
/// <inheritdoc />
/// <summary>
/// Summary for TheTVDBCodeFinder
/// </summary>
Expand Down Expand Up @@ -62,6 +63,19 @@ public int SelectedCode()
return -1;
}
}
public string SelectedShowName()
{
try
{
if (this.lvMatches.SelectedItems.Count == 0) return "";

return (string)(this.lvMatches.SelectedItems[0].SubItems[1].Text);
}
catch
{
return "";
}
}

private void txtFindThis_TextChanged(object sender, EventArgs e)
{
Expand Down Expand Up @@ -186,4 +200,4 @@ private void lvMatches_ColumnClick(object sender, ColumnClickEventArgs e)
lvMatches.Sort();
}
}
}
}
3 changes: 1 addition & 2 deletions TVRename#/DownloadIdentifers/DownloadEpisodeJPG.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ public override ItemList ProcessEpisode(ProcessedEpisode dbep, FileInfo filo, bo
string ban = dbep.GetFilename();
if (!string.IsNullOrEmpty(ban))
{
string basefn = filo.Name;
basefn = basefn.Substring(0, basefn.Length - filo.Extension.Length); //remove extension
string basefn = filo.RemoveExtension();

FileInfo imgjpg = FileHelper.FileInFolder(filo.Directory, basefn + ".jpg");

Expand Down
4 changes: 1 addition & 3 deletions TVRename#/DownloadIdentifers/DownloadMede8erMetaData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@ public override ItemList ProcessEpisode(ProcessedEpisode dbep, FileInfo filo, bo
if (TVSettings.Instance.Mede8erXML)
{
ItemList TheActionList = new ItemList();
string fn = filo.Name;
fn = fn.Substring(0, fn.Length - filo.Extension.Length);
fn += ".xml";
string fn = filo.RemoveExtension() + ".xml";
FileInfo nfo = FileHelper.FileInFolder(filo.Directory, fn);

if (forceRefresh || !nfo.Exists || (dbep.Srv_LastUpdated > TimeZone.Epoch(nfo.LastWriteTime)))
Expand Down
3 changes: 1 addition & 2 deletions TVRename#/DownloadIdentifers/DownloadXBMCImages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,7 @@ private ActionDownload DoEpisode(ShowItem si, Episode ep, FileInfo filo,string e
string ban = ep.GetFilename();
if (!string.IsNullOrEmpty(ban))
{
string basefn = filo.Name;
basefn = basefn.Substring(0, basefn.Length - filo.Extension.Length); //remove extension
string basefn = filo.RemoveExtension();
FileInfo imgtbn = FileHelper.FileInFolder(filo.Directory, basefn + extension);
if (!imgtbn.Exists || forceRefresh)
if (!(this.doneTBN.Contains(imgtbn.FullName)))
Expand Down
4 changes: 1 addition & 3 deletions TVRename#/DownloadIdentifers/DownloadXBMCMetaData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ public override ItemList ProcessEpisode(ProcessedEpisode dbep, FileInfo filo,boo
{
ItemList TheActionList = new ItemList();

string fn = filo.Name;
fn = fn.Substring(0, fn.Length - filo.Extension.Length);
fn += ".nfo";
string fn = filo.RemoveExtension() + ".nfo";
FileInfo nfo = FileHelper.FileInFolder(filo.Directory, fn);

if (!nfo.Exists || (dbep.Srv_LastUpdated > TimeZone.Epoch(nfo.LastWriteTime)) || forceRefresh)
Expand Down
4 changes: 2 additions & 2 deletions TVRename#/Finders/FileFinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public void KeepTogether(ItemList Actionlist)
if ((TVSettings.Instance.RenameTxtToSub) && (newName.EndsWith(".txt")))
newName = newName.Substring(0, newName.Length - 4) + ".sub";

ActionCopyMoveRename newitem = new ActionCopyMoveRename(Action.Operation, fi, FileHelper.FileInFolder(Action.To.Directory, newName), Action.Episode, null); // tidyup on main action, not this
ActionCopyMoveRename newitem = new ActionCopyMoveRename(Action.Operation, fi, FileHelper.FileInFolder(Action.To.Directory, newName), Action.Episode, null,null); // tidyup on main action, not this



Expand Down Expand Up @@ -301,7 +301,7 @@ public bool FindMissingEp(DirCache dirCache, ItemMissing me, ItemList addTo, Act
}
}
if(dce.TheFile.FullName != fi.FullName)
addTo.Add(new ActionCopyMoveRename(whichOp, dce.TheFile, fi, me.Episode, doTidyup ? TVSettings.Instance.Tidyup : null));
addTo.Add(new ActionCopyMoveRename(whichOp, dce.TheFile, fi, me.Episode, doTidyup ? TVSettings.Instance.Tidyup : null,me));

DownloadIdentifiersController di = new DownloadIdentifiersController();

Expand Down
137 changes: 137 additions & 0 deletions TVRename#/Forms/AutoAddShow.Designer.cs

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

75 changes: 75 additions & 0 deletions TVRename#/Forms/AutoAddShow.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
using System;
using System.Windows.Forms;

namespace TVRename.Forms
{
public partial class AutoAddShow : Form
{
private ShowItem mSI;
private readonly TheTVDBCodeFinder mTCCF;

public AutoAddShow(string hint)
{
InitializeComponent();
this.mSI = new ShowItem();
this.mTCCF = new TheTVDBCodeFinder("") {Dock = DockStyle.Fill};
this.mTCCF.SetHint(hint);
this.mTCCF.SelectionChanged += MTCCF_SelectionChanged;
this.pnlCF.SuspendLayout();
this.pnlCF.Controls.Add(this.mTCCF);
this.pnlCF.ResumeLayout();
this.ActiveControl = this.mTCCF; // set initial focus to the code entry/show finder control

this.cbDirectory.SuspendLayout();
this.cbDirectory.Items.Clear();
this.cbDirectory.Items.AddRange(TVSettings.Instance.MonitorFoldersNames.ToArray());
this.cbDirectory.SelectedIndex = 0;
this.cbDirectory.ResumeLayout();
}

private void MTCCF_SelectionChanged(object sender, EventArgs e)
{
this.lblDirectoryName.Text = System.IO.Path.DirectorySeparatorChar + TVSettings.Instance.FilenameFriendly(FileHelper.MakeValidPath(this.mTCCF.SelectedShowName( )));
}

public ShowItem ShowItem => this.mSI;

private void SetShowItem()
{
int code = this.mTCCF.SelectedCode();


this.mSI.TVDBCode = code;
this.mSI.AutoAdd_FolderBase = this.cbDirectory.Text+this.lblDirectoryName.Text;

}

private void btnOK_Click(object sender, EventArgs e)
{
if (!OkToClose())
{
this.DialogResult = DialogResult.None;
return;
}

SetShowItem();
this.DialogResult = DialogResult.OK;
Close();
}

private bool OkToClose()
{
if (TheTVDB.Instance.HasSeries(this.mTCCF.SelectedCode())) return true;

DialogResult dr = MessageBox.Show("tvdb code unknown, close anyway?", "TVRename Add/Edit Show",
MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

return dr != DialogResult.No;
}

private void AutoAddShow_Load(object sender, EventArgs e)
{

}
}
}
Loading

0 comments on commit 21f259a

Please sign in to comment.