FF-1423 - added use folder name to tv episode lookup

This commit is contained in:
John Andrews
2024-04-14 16:59:44 +12:00
parent 5dbbb6b90d
commit 84f0a0c0d2
6 changed files with 18 additions and 7 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -1,6 +1,7 @@
using DM.MovieApi;
using DM.MovieApi.MovieDb.TV;
using FileFlows.Plugin;
using FileFlows.Plugin.Attributes;
namespace MetaNodes.TheMovieDb;
@@ -36,6 +37,12 @@ public class TVEpisodeLookup : Node
/// Gets the Variables this flow element provides
/// </summary>
public override Dictionary<string, object> Variables => _Variables;
/// <summary>
/// Gets or sets if the folder name should be used
/// </summary>
[Boolean(1)]
public bool UseFolderName { get; set; }
/// <summary>
/// Constructs a new instance of this flow element
@@ -65,10 +72,10 @@ public class TVEpisodeLookup : Node
public override int Execute(NodeParameters args)
{
string filename = args.FileName.Replace("\\", "/");
filename = filename.Substring(filename.LastIndexOf("/", StringComparison.Ordinal) + 1);
filename = filename.Substring(0, filename.LastIndexOf(".", StringComparison.Ordinal));
filename = filename[(filename.LastIndexOf("/", StringComparison.Ordinal) + 1)..];
filename = filename[..filename.LastIndexOf(".", StringComparison.Ordinal)];
(string lookupName, string year) = TVShowLookup.GetLookupName(filename, false);
(string lookupName, string year) = TVShowLookup.GetLookupName(filename, UseFolderName);
(string showName, int? season, int? episode, int? lastEpisode, string year2) = TVShowLookup.GetTVShowInfo(filename);

View File

@@ -127,7 +127,7 @@ public class TVShowLookup : Node
if (useFolderName)
{
lookupName = fileInfo.Directory.Name;
if (Regex.IsMatch(lookupName, "^(Season|Staffel|Saison)", RegexOptions.IgnoreCase))
if (Regex.IsMatch(lookupName, "^(Season|Staffel|Saison|Specials)", RegexOptions.IgnoreCase))
lookupName = fileInfo.Directory.Parent.Name;
}
else

View File

@@ -67,6 +67,10 @@
"Outputs": {
"1": "TV Episode found",
"2": "TV Episode NOT found"
},
"Fields": {
"UseFolderName": "Use Folder Name",
"UseFolderName-Help": "If the folder name should be used instead of the filename.\n\nNote if the folder starts with Season or Staffel or Saison the parent folder will be used."
}
}
}

View File

@@ -44,9 +44,9 @@ public class VideoHasStream : VideoNode
{
_StreamTypeOptions = new List<ListOption>
{
new ListOption { Label = "Video", Value = "Video" },
new ListOption { Label = "Audio", Value = "Audio" },
new ListOption { Label = "Subtitle", Value = "Subtitle" }
new () { Label = "Video", Value = "Video" },
new () { Label = "Audio", Value = "Audio" },
new () { Label = "Subtitle", Value = "Subtitle" }
};
}
return _StreamTypeOptions;