Skip to content

Commit

Permalink
Merge pull request #331 from MarkSummerville/master
Browse files Browse the repository at this point in the history
Latest bug fixes
  • Loading branch information
SirSparkles authored Feb 14, 2018
2 parents 8ff785c + 2309e63 commit 8b987dc
Show file tree
Hide file tree
Showing 18 changed files with 320 additions and 242 deletions.
23 changes: 16 additions & 7 deletions TVRename#/DownloadIdentifers/DownloadMede8erMetaData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ namespace TVRename
{
class DownloadMede8erMetaData : DownloadIdentifier
{

public DownloadMede8erMetaData()
private List<string> doneFiles;
public DownloadMede8erMetaData()
{
reset();
}
Expand All @@ -21,7 +21,7 @@ public override DownloadType GetDownloadType()
return DownloadType.downloadMetaData;
}

public override ItemList ProcessShow(ShowItem si,bool forceRefresh)
public override ItemList ProcessShow(ShowItem si, bool forceRefresh)
{
if (TVSettings.Instance.Mede8erXML)
{
Expand All @@ -32,12 +32,20 @@ public override ItemList ProcessShow(ShowItem si,bool forceRefresh)
bool needUpdate = !tvshowxml.Exists ||
(si.TheSeries().Srv_LastUpdated > TimeZone.Epoch(tvshowxml.LastWriteTime));

if (forceRefresh || needUpdate)
if ((forceRefresh || needUpdate) && (!this.doneFiles.Contains(tvshowxml.FullName)))
{
this.doneFiles.Add(tvshowxml.FullName);
TheActionList.Add(new ActionMede8erXML(tvshowxml, si));
}


//Updates requested by [email protected] on 18/4/2013
FileInfo viewxml = FileHelper.FileInFolder(si.AutoAdd_FolderBase, "view.xml");
if (!viewxml.Exists) TheActionList.Add(new ActionMede8erViewXML(viewxml,si));
if ((!viewxml.Exists) && (!this.doneFiles.Contains(viewxml.FullName)))
{
this.doneFiles.Add(viewxml.FullName);
TheActionList.Add(new ActionMede8erViewXML(viewxml, si));
}


return TheActionList;
Expand All @@ -54,7 +62,7 @@ public override ItemList ProcessSeason(ShowItem si, string folder, int snum, boo

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


return TheActionList;
Expand Down Expand Up @@ -84,7 +92,8 @@ public override ItemList ProcessEpisode(ProcessedEpisode dbep, FileInfo filo, bo

public override void reset()
{
base.reset();
this.doneFiles = new List<string>();
base.reset();
}

}
Expand Down
57 changes: 44 additions & 13 deletions TVRename#/DownloadIdentifers/DownloadXBMCImages.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Text;
using System.Globalization;
Expand Down Expand Up @@ -160,24 +160,55 @@ public override ItemList ProcessEpisode(ProcessedEpisode dbep, FileInfo filo, bo
{
if (TVSettings.Instance.EpTBNs || TVSettings.Instance.KODIImages)
{
ItemList TheActionList = new ItemList();
string ban = dbep.GetFilename();
if (!string.IsNullOrEmpty(ban))
ItemList theActionList = new ItemList();


if (dbep.type == ProcessedEpisode.ProcessedEpisodeType.merged)
{
string basefn = filo.Name;
basefn = basefn.Substring(0, basefn.Length - filo.Extension.Length); //remove extension
FileInfo imgtbn = FileHelper.FileInFolder(filo.Directory, basefn + ".tbn");
if (!imgtbn.Exists ||forceRefresh)
if (!(this.doneTBN.Contains(imgtbn.FullName))){
TheActionList.Add(new ActionDownload(dbep.SI, dbep, imgtbn, ban));
doneTBN.Add(filo.FullName);
}
//We have a merged episode, so we'll also download the images for the episodes had they been separate.
foreach (Episode sourceEp in dbep.sourceEpisodes)
{
string foldername = filo.DirectoryName;
string filename =
TVSettings.Instance.FilenameFriendly(
TVSettings.Instance.NamingStyle.GetTargetEpisodeName(sourceEp,dbep.SI.ShowName));
ActionDownload b = DoEpisode(dbep.SI,sourceEp,new FileInfo(foldername+"/"+filename), ".jpg", forceRefresh);
if (b != null) theActionList.Add(b);
}
}
return TheActionList;
else
{
ActionDownload a = DoEpisode(dbep.SI, dbep, filo, ".tbn", forceRefresh);
if (a != null) theActionList.Add(a);
}

return theActionList;
}
return base.ProcessEpisode(dbep, filo, forceRefresh);
}

private ActionDownload DoEpisode(ShowItem si, Episode ep, FileInfo filo,string extension, bool forceRefresh)
{
string ban = ep.GetFilename();
if (!string.IsNullOrEmpty(ban))
{
string basefn = filo.Name;
basefn = basefn.Substring(0, basefn.Length - filo.Extension.Length); //remove extension
FileInfo imgtbn = FileHelper.FileInFolder(filo.Directory, basefn + extension);
if (!imgtbn.Exists || forceRefresh)
if (!(this.doneTBN.Contains(imgtbn.FullName)))
{
this.doneTBN.Add(imgtbn.FullName);

return new ActionDownload(si, (ep is ProcessedEpisode) ? (ProcessedEpisode)ep : new ProcessedEpisode(ep,si ), imgtbn, ban);

}
}

return null;

}

public override void reset()
{
doneBannerJPG = new List<String>();
Expand Down
2 changes: 1 addition & 1 deletion TVRename#/Exporter/UpcomingRSS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected override bool Generate(System.IO.Stream str, List<ProcessedEpisode> el

foreach (ProcessedEpisode ei in elist)
{
string niceName = TVSettings.Instance.NamingStyle.NameForExt(ei, null, 0);
string niceName = TVSettings.Instance.NamingStyle.NameForExt(ei);

writer.WriteStartElement("item");

Expand Down
3 changes: 1 addition & 2 deletions TVRename#/Exporter/UpcomingXML.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ protected override bool Generate(System.IO.Stream str, List<ProcessedEpisode> e

foreach (ProcessedEpisode ei in elist)
{
string niceName = TVSettings.Instance.NamingStyle.NameForExt(ei, null, 0);


writer.WriteStartElement("item");
XMLHelper.WriteElementToXML(writer,"id",ei.TheSeries.TVDBCode);
XMLHelper.WriteElementToXML(writer,"SeriesName",ei.TheSeries.Name);
Expand Down
2 changes: 1 addition & 1 deletion TVRename#/Finders/FileFinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public void KeepTogether(ItemList Actionlist)

// do case insensitive replace
string n = fi.Name;
int p = n.ToUpper().IndexOf(basename.ToUpper());
int p = n.IndexOf(basename, StringComparison.OrdinalIgnoreCase);
string newName = n.Substring(0, p) + toname + n.Substring(p + basename.Length);
if ((TVSettings.Instance.RenameTxtToSub) && (newName.EndsWith(".txt")))
newName = newName.Substring(0, newName.Length - 4) + ".sub";
Expand Down
4 changes: 2 additions & 2 deletions TVRename#/Forms/CustomNameDesigner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private void FillExamples()
foreach (ProcessedEpisode pe in this.Eps)
{
ListViewItem lvi = new ListViewItem();
string fn = TVSettings.Instance.FilenameFriendly(this.CN.NameForExt(pe, null, 0));
string fn = TVSettings.Instance.FilenameFriendly(this.CN.NameForExt(pe));
lvi.Text = fn;

bool ok = false;
Expand Down Expand Up @@ -141,4 +141,4 @@ private void lvTest_SelectedIndexChanged(object sender, System.EventArgs e)
this.FillCombos();
}
}
}
}
4 changes: 2 additions & 2 deletions TVRename#/Forms/EditRules.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ private void FillPreview()
this.lbEpsPreview.BeginUpdate();
this.lbEpsPreview.Items.Clear();
foreach (ProcessedEpisode pe in pel)
this.lbEpsPreview.Items.Add(this.NameStyle.NameForExt(pe, null, 0));
this.lbEpsPreview.Items.Add(this.NameStyle.NameForExt(pe));
this.lbEpsPreview.EndUpdate();
}
}
}
}
119 changes: 61 additions & 58 deletions TVRename#/Forms/UI.Designer.cs

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

Loading

0 comments on commit 8b987dc

Please sign in to comment.