diff --git a/MetaNodes/Tests/TheMovieDb/TVEpisodeLookupTests.cs b/MetaNodes/Tests/TheMovieDb/TVEpisodeLookupTests.cs
index 969d8747..35ee89d7 100644
--- a/MetaNodes/Tests/TheMovieDb/TVEpisodeLookupTests.cs
+++ b/MetaNodes/Tests/TheMovieDb/TVEpisodeLookupTests.cs
@@ -11,6 +11,20 @@ namespace MetaNodes.Tests.TheMovieDb;
[TestClass]
public class TVEpisodeLookupTests
{
+ ///
+ /// The test context instance
+ ///
+ private TestContext testContextInstance;
+
+ ///
+ /// Gets or sets the test context
+ ///
+ public TestContext TestContext
+ {
+ get { return testContextInstance; }
+ set { testContextInstance = value; }
+ }
+
[TestMethod]
public void TheBatman_s02e01()
{
@@ -47,6 +61,28 @@ public class TVEpisodeLookupTests
Assert.IsFalse(string.IsNullOrWhiteSpace(args.Variables["tvepisode.Overview"] as string));
}
+ [TestMethod]
+ public void WithYear()
+ {
+ var logger = new TestLogger();
+ var args = new FileFlows.Plugin.NodeParameters("/test/tv/Paradise PD (2018) - S04E04 - Good Jeans (1080p NF WEB-DL x265 t3nzin).mkv", logger, false, string.Empty, null);
+
+ var element = new TVEpisodeLookup();
+
+ var result = element.Execute(args);
+ TestContext.WriteLine(logger.ToString());
+
+ Assert.AreEqual(1, result);
+
+
+ Assert.AreEqual("Paradise PD", args.Variables["tvepisode.Title"]);
+ Assert.AreEqual(4, args.Variables["tvepisode.Season"]);
+ Assert.AreEqual(4, args.Variables["tvepisode.Episode"]);
+ Assert.AreEqual("Good Jeans", args.Variables["tvepisode.Subtitle"]);
+ Assert.IsFalse(string.IsNullOrWhiteSpace(args.Variables["tvepisode.Overview"] as string));
+
+ }
+
[TestMethod]
public void TheBatman_3x01_2()
{
diff --git a/MetaNodes/TheMovieDb/TVEpisodeLookup.cs b/MetaNodes/TheMovieDb/TVEpisodeLookup.cs
index dc01819e..6dbb555f 100644
--- a/MetaNodes/TheMovieDb/TVEpisodeLookup.cs
+++ b/MetaNodes/TheMovieDb/TVEpisodeLookup.cs
@@ -65,8 +65,8 @@ public class TVEpisodeLookup : Node
public override int Execute(NodeParameters args)
{
string filename = args.FileName.Replace("\\", "/");
- filename = filename.Substring(filename.LastIndexOf("/") + 1);
- filename = filename.Substring(0, filename.LastIndexOf("."));
+ filename = filename.Substring(filename.LastIndexOf("/", StringComparison.Ordinal) + 1);
+ filename = filename.Substring(0, filename.LastIndexOf(".", StringComparison.Ordinal));
(string lookupName, string year) = TVShowLookup.GetLookupName(filename, false);
diff --git a/MetaNodes/TheMovieDb/TVShowLookup.cs b/MetaNodes/TheMovieDb/TVShowLookup.cs
index 6feacd1e..69da193e 100644
--- a/MetaNodes/TheMovieDb/TVShowLookup.cs
+++ b/MetaNodes/TheMovieDb/TVShowLookup.cs
@@ -147,7 +147,7 @@ public class TVShowLookup : Node
}
// remove double spaces in case they were added when removing the year
- while (lookupName.IndexOf(" ") > 0)
+ while (lookupName.IndexOf(" ", StringComparison.Ordinal) > 0)
lookupName = lookupName.Replace(" ", " ");
return (lookupName, year);
@@ -204,13 +204,22 @@ public class TVShowLookup : Node
// Replace "1x02" format with "s1e02"
text = Regex.Replace(text, @"(?\d+)x(?\d+)", "s${season}e${episode}", RegexOptions.IgnoreCase);
+ string year = null;
+ var reYear = Regex.Match(text, @"(19|20)[\d]{2}", RegexOptions.CultureInvariant);
+ if (reYear.Success)
+ {
+ year = reYear.Value;
+ text = text.Replace("(" + year + ")", string.Empty);
+ text = text.Replace(year, string.Empty);
+ }
+
string pattern = @"^(?[\w\s.-]+)[. _-]?(?:(s|S)(?\d+)(e|E)(?\d+)(?:-(?\d+))?)";
Match match = Regex.Match(text, pattern);
if (match.Success == false)
return (text, null, null, null);
-
+
string show = match.Groups["showName"].Value.Replace(".", " ").TrimEnd();
if (show.EndsWith(" -"))
show = show[..^2];
@@ -219,6 +228,9 @@ public class TVShowLookup : Node
string lastEpisodeStr = match.Groups["lastEpisode"].Value;
int? lastEpisode = string.IsNullOrEmpty(lastEpisodeStr) ? (int?)null : int.Parse(lastEpisodeStr);
+ if (year != null)
+ show += " (" + year + ")";
+
return (show, season, episode, lastEpisode);
}
}
\ No newline at end of file
diff --git a/VideoNodes/Tests/_TestBase.cs b/VideoNodes/Tests/_TestBase.cs
index cdecfd38..6362ffc5 100644
--- a/VideoNodes/Tests/_TestBase.cs
+++ b/VideoNodes/Tests/_TestBase.cs
@@ -11,8 +11,14 @@ namespace VideoNodes.Tests;
[TestClass]
public abstract class TestBase
{
+ ///
+ /// The test context instance
+ ///
private TestContext testContextInstance;
+ ///
+ /// Gets or sets the test context
+ ///
public TestContext TestContext
{
get { return testContextInstance; }