diff --git a/BasicNodes/BasicNodes.csproj b/BasicNodes/BasicNodes.csproj index 6d02ec0f..1a0ebfbd 100644 Binary files a/BasicNodes/BasicNodes.csproj and b/BasicNodes/BasicNodes.csproj differ diff --git a/ChecksumNodes/ChecksumNodes.csproj b/ChecksumNodes/ChecksumNodes.csproj index 489466bf..246539c9 100644 Binary files a/ChecksumNodes/ChecksumNodes.csproj and b/ChecksumNodes/ChecksumNodes.csproj differ diff --git a/CollectionNodes/CollectionNodes.csproj b/CollectionNodes/CollectionNodes.csproj index 1ed1e759..f5b62424 100644 Binary files a/CollectionNodes/CollectionNodes.csproj and b/CollectionNodes/CollectionNodes.csproj differ diff --git a/DiscordNodes/DiscordNodes.csproj b/DiscordNodes/DiscordNodes.csproj index 078cb559..c62e740e 100644 Binary files a/DiscordNodes/DiscordNodes.csproj and b/DiscordNodes/DiscordNodes.csproj differ diff --git a/EmailNodes/EmailNodes.csproj b/EmailNodes/EmailNodes.csproj index a2979536..01f6877c 100644 Binary files a/EmailNodes/EmailNodes.csproj and b/EmailNodes/EmailNodes.csproj differ diff --git a/Emby/Emby.csproj b/Emby/Emby.csproj index 759cd442..60e9c3df 100644 Binary files a/Emby/Emby.csproj and b/Emby/Emby.csproj differ diff --git a/Emby/Emby.en.json b/Emby/Emby.en.json index 42bee5be..4e711e00 100644 --- a/Emby/Emby.en.json +++ b/Emby/Emby.en.json @@ -7,7 +7,11 @@ "ServerUrl-Placeholder": "http://localhost:8096/", "ServerUrl-Help": "The URL of the Emby server", "AccessToken": "Access Token", - "AccessToken-Help": "An Emby API access token" + "AccessToken-Help": "An Emby API access token", + "Mapping": "Mapping", + "Mapping-Help": "A list of mapping replacement used to paths in FileFlows with the paths that are used in Emby.", + "MappingKey": "FileFlows", + "MappingValue": "Emby" } } }, @@ -18,7 +22,18 @@ "1": "Emby update request sent", "2": "Emby update request failed to send" }, - "Description": "Sends a message to a Emby server to update the library." + "Description": "Sends a message to a Emby server to update the library.", + "Fields": { + "ServerUrl": "Server", + "ServerUrl-Placeholder": "http://localhost:8096/", + "ServerUrl-Help": "The URL of the Emby server.\nNote: Only set this if you want to override the plugin settings Server URL.", + "AccessToken": "Access Token", + "AccessToken-Help": "An Emby API access token.\nNote: Only set this if you want to override the plugin settings access token.", + "Mapping": "Mapping", + "Mapping-Help": "A list of mapping replacement used to paths in FileFlows with the paths that are used in Emby.\nNote: This will not be used unless the Server URL is also set here, otherwise the plugin settings mappings will be used.", + "MappingKey": "FileFlows", + "MappingValue": "Emby" + } } } } diff --git a/Emby/MediaManagement/EmbyUpdater.cs b/Emby/MediaManagement/EmbyUpdater.cs index 0d158f34..636074ac 100644 --- a/Emby/MediaManagement/EmbyUpdater.cs +++ b/Emby/MediaManagement/EmbyUpdater.cs @@ -1,4 +1,5 @@ -using System.Text.RegularExpressions; +using FileFlows.Plugin.Attributes; +using System.Text.RegularExpressions; namespace FileFlows.Emby.MediaManagement; @@ -9,16 +10,30 @@ public class EmbyUpdater: Node public override FlowElementType Type => FlowElementType.Process; public override string Icon => "fas fa-paper-plane"; + public override bool NoEditorOnAdd => true; + + [Text(1)] + public string ServerUrl { get; set; } + + [Text(2)] + public string AccessToken { get; set; } + + [KeyValue(3)] + public List> Mapping { get; set; } + public override int Execute(NodeParameters args) { var settings = args.GetPluginSettings(); + string serverUrl = ServerUrl?.EmptyAsNull() ?? settings.ServerUrl; + string accessToken = AccessToken?.EmptyAsNull() ?? settings.AccessToken; + var mapping = (string.IsNullOrWhiteSpace(ServerUrl) ? settings.Mapping : Mapping) ?? new List>(); - if (string.IsNullOrWhiteSpace(settings?.AccessToken)) + if (string.IsNullOrWhiteSpace(accessToken)) { args.Logger?.WLog("No access token set"); return 2; } - if (string.IsNullOrWhiteSpace(settings?.ServerUrl)) + if (string.IsNullOrWhiteSpace(serverUrl)) { args.Logger?.WLog("No server URL set"); return 2; @@ -27,6 +42,14 @@ public class EmbyUpdater: Node // get the path string path = args.WorkingFile; path = args.UnMapPath(path); + + foreach (var map in mapping) + { + if (string.IsNullOrEmpty(map.Key)) + continue; + path = path.Replace(map.Key, map.Value ?? string.Empty); + } + if (args.IsDirectory == false) { bool windows = path.StartsWith("\\") || Regex.IsMatch(path, @"^[a-zA-Z]:\\"); @@ -34,7 +57,8 @@ public class EmbyUpdater: Node path = path.Substring(0, path.LastIndexOf(pathSeparator)); } - string url = settings.ServerUrl; + + string url = serverUrl; if (url.EndsWith("/") == false) url += "/"; url += "Library/Media/Updated"; @@ -45,7 +69,7 @@ public class EmbyUpdater: Node using var httpClient = new HttpClient(); - var updateResponse = GetWebRequest(httpClient, url, settings.AccessToken, body); + var updateResponse = GetWebRequest(httpClient, url, accessToken, body); if (updateResponse.success == false) { if(string.IsNullOrWhiteSpace(updateResponse.body) == false) diff --git a/Emby/PluginSettings.cs b/Emby/PluginSettings.cs index 32fabc9f..d9771f84 100644 --- a/Emby/PluginSettings.cs +++ b/Emby/PluginSettings.cs @@ -13,5 +13,8 @@ [Text(2)] [Required] public string AccessToken { get; set; } + + [KeyValue(3)] + public List> Mapping { get; set; } } } diff --git a/Emby/Tests/EmbyTests.cs b/Emby/Tests/EmbyTests.cs index 74dda535..51d10bda 100644 --- a/Emby/Tests/EmbyTests.cs +++ b/Emby/Tests/EmbyTests.cs @@ -33,6 +33,19 @@ public class EmbyTests var node = new EmbyUpdater(); Assert.AreEqual(2, node.Execute(args)); } + + [TestMethod] + public void Emby_Mapped() + { + var args = new NodeParameters(@"/mnt/movies/Citizen Kane (1941)/Citizen Kane (1941).mp4", new TestLogger(), false, string.Empty); + args.GetPluginSettingsJson = (string input) => + { + return File.ReadAllText("../../../settings.json"); + }; + + var node = new EmbyUpdater(); + Assert.AreEqual(1, node.Execute(args)); + } } #endif \ No newline at end of file diff --git a/FileFlows.Plugin.dll b/FileFlows.Plugin.dll index 1189e579..f9d8833f 100644 Binary files a/FileFlows.Plugin.dll and b/FileFlows.Plugin.dll differ diff --git a/FileFlows.Plugin.pdb b/FileFlows.Plugin.pdb index 39c4ed68..72c23812 100644 Binary files a/FileFlows.Plugin.pdb and b/FileFlows.Plugin.pdb differ diff --git a/Gotify/Gotify.csproj b/Gotify/Gotify.csproj index 9711ea71..31fdcdad 100644 Binary files a/Gotify/Gotify.csproj and b/Gotify/Gotify.csproj differ diff --git a/MetaNodes/MetaNodes.csproj b/MetaNodes/MetaNodes.csproj index 1a7d2402..a2193392 100644 Binary files a/MetaNodes/MetaNodes.csproj and b/MetaNodes/MetaNodes.csproj differ diff --git a/MusicNodes/MusicNodes.csproj b/MusicNodes/MusicNodes.csproj index b1b387c9..a2fb444a 100644 Binary files a/MusicNodes/MusicNodes.csproj and b/MusicNodes/MusicNodes.csproj differ diff --git a/Plex/MediaManagement/PlexUpdater.cs b/Plex/MediaManagement/PlexUpdater.cs index 5a4f27ab..80319358 100644 --- a/Plex/MediaManagement/PlexUpdater.cs +++ b/Plex/MediaManagement/PlexUpdater.cs @@ -10,16 +10,30 @@ public class PlexUpdater: Node public override FlowElementType Type => FlowElementType.Process; public override string Icon => "fas fa-paper-plane"; + public override bool NoEditorOnAdd => true; + + [Text(1)] + public string ServerUrl { get; set; } + + [Text(2)] + public string AccessToken { get; set; } + + [KeyValue(3)] + public List> Mapping { get; set; } + public override int Execute(NodeParameters args) { var settings = args.GetPluginSettings(); + string serverUrl = ServerUrl?.EmptyAsNull() ?? settings.ServerUrl; + string accessToken = AccessToken?.EmptyAsNull() ?? settings.AccessToken; + var mapping = (string.IsNullOrWhiteSpace(ServerUrl) ? settings.Mapping : Mapping) ?? new List>(); - if (string.IsNullOrWhiteSpace(settings?.AccessToken)) + if (string.IsNullOrWhiteSpace(accessToken)) { args.Logger?.WLog("No access token set"); return 2; } - if (string.IsNullOrWhiteSpace(settings?.ServerUrl)) + if (string.IsNullOrWhiteSpace(serverUrl)) { args.Logger?.WLog("No server URL set"); return 2; @@ -35,14 +49,14 @@ public class PlexUpdater: Node path = path.Substring(0, path.LastIndexOf(pathSeparator)); } - string url = settings.ServerUrl; + string url = serverUrl; if (url.EndsWith("/") == false) url += "/"; url += "library/sections"; using var httpClient = new HttpClient(); - var sectionsResponse= GetWebRequest(httpClient, url + "?X-Plex-Token=" + settings.AccessToken); + var sectionsResponse= GetWebRequest(httpClient, url + "?X-Plex-Token=" + accessToken); if (sectionsResponse.success == false) { args.Logger?.WLog("Failed to retrieve sections" + (string.IsNullOrWhiteSpace(sectionsResponse.body) ? "" : ": " + sectionsResponse.body)); @@ -61,6 +75,14 @@ public class PlexUpdater: Node args.Logger?.ELog("Failed deserializing sections json: " + ex.Message); return 2; } + + foreach(var map in mapping) + { + if (string.IsNullOrEmpty(map.Key)) + continue; + path = path.Replace(map.Key, map.Value ?? string.Empty); + } + string pathLower = path.ToLower(); var section = sections?.MediaContainer?.Directory?.Where(x => { if (x.Location?.Any() != true) diff --git a/Plex/Plex.csproj b/Plex/Plex.csproj index ce19932a..6a632ba4 100644 Binary files a/Plex/Plex.csproj and b/Plex/Plex.csproj differ diff --git a/Plex/Plex.en.json b/Plex/Plex.en.json index 76bd757a..6e1074b9 100644 --- a/Plex/Plex.en.json +++ b/Plex/Plex.en.json @@ -7,7 +7,11 @@ "ServerUrl-Placeholder": "http://localhost:32400/", "ServerUrl-Help": "The URL of the Plex server", "AccessToken": "Access Token", - "AccessToken-Help": "The access token used to communicate with the Plex server.\nhttps://github.com/revenz/Fenrus/wiki/Plex-Token" + "AccessToken-Help": "The access token used to communicate with the Plex server.\nhttps://github.com/revenz/Fenrus/wiki/Plex-Token", + "Mapping": "Mapping", + "Mapping-Help": "A list of mapping replacement used to paths in FileFlows with the paths that are used in Plex.", + "MappingKey": "FileFlows", + "MappingValue": "Plex" } } }, @@ -18,7 +22,18 @@ "1": "Plex update request sent", "2": "Plex update request failed to send" }, - "Description": "Sends a message to a Plex server to update the library." + "Description": "Sends a message to a Plex server to update the library.", + "Fields": { + "ServerUrl": "Server", + "ServerUrl-Placeholder": "http://localhost:32400/", + "ServerUrl-Help": "The URL of the Plex server. If blank will use the Server defined in the Plugin settings.\nNote: Only set this if you want to override the plugin settings server URL.", + "AccessToken": "Access Token", + "AccessToken-Help": "The access token used to communicate with the Plex server.\nhttps://github.com/revenz/Fenrus/wiki/Plex-Token\nNote: Only set this if you want to override the plugin settings access token.", + "Mapping": "Mapping", + "Mapping-Help": "A list of mapping replacement used to paths in FileFlows with the paths that are used in Plex.\nNote: This will not be used unless the Server URL is also set here, otherwise the plugin settings mappings will be used.", + "MappingKey": "FileFlows", + "MappingValue": "Plex" + } } } } diff --git a/Plex/PluginSettings.cs b/Plex/PluginSettings.cs index 656f7939..94d3f6ef 100644 --- a/Plex/PluginSettings.cs +++ b/Plex/PluginSettings.cs @@ -14,5 +14,8 @@ [Text(2)] [Required] public string AccessToken { get; set; } + + [KeyValue(3)] + public List> Mapping { get; set; } } } diff --git a/Plex/Tests/PlexTests.cs b/Plex/Tests/PlexTests.cs index a1db8f74..7ca55f4a 100644 --- a/Plex/Tests/PlexTests.cs +++ b/Plex/Tests/PlexTests.cs @@ -33,6 +33,24 @@ public class PlexTests var node = new PlexUpdater(); Assert.AreEqual(2, node.Execute(args)); } + + [TestMethod] + public void Plex_Mapping() + { + var args = new NodeParameters(@"/mnt/movies/Citizen Kane (1941)/Citizen Kane (1941).mp4", new TestLogger(), false, string.Empty); + var settings = new PluginSettings(); + settings.Mapping = new List>(); + settings.Mapping.Add(new KeyValuePair("/mnt/movies", "/media/movies")); + + args.GetPluginSettingsJson = (string input) => + { + return File.ReadAllText("../../../settings.json"); + }; + + var node = new PlexUpdater(); + Assert.AreEqual(1, node.Execute(args)); + } + } #endif \ No newline at end of file diff --git a/VideoNodes/VideoNodes.csproj b/VideoNodes/VideoNodes.csproj index 953ec111..c4f285c0 100644 Binary files a/VideoNodes/VideoNodes.csproj and b/VideoNodes/VideoNodes.csproj differ diff --git a/build/utils/PluginInfoGenerator/FileFlows.Plugin.dll b/build/utils/PluginInfoGenerator/FileFlows.Plugin.dll index 37bba332..2115cd36 100644 Binary files a/build/utils/PluginInfoGenerator/FileFlows.Plugin.dll and b/build/utils/PluginInfoGenerator/FileFlows.Plugin.dll differ diff --git a/build/utils/PluginInfoGenerator/FileFlows.Plugin.pdb b/build/utils/PluginInfoGenerator/FileFlows.Plugin.pdb index 1396a077..0e42da96 100644 Binary files a/build/utils/PluginInfoGenerator/FileFlows.Plugin.pdb and b/build/utils/PluginInfoGenerator/FileFlows.Plugin.pdb differ diff --git a/build/utils/PluginInfoGenerator/FileFlows.ServerShared.dll b/build/utils/PluginInfoGenerator/FileFlows.ServerShared.dll index ea75e37c..c6683349 100644 Binary files a/build/utils/PluginInfoGenerator/FileFlows.ServerShared.dll and b/build/utils/PluginInfoGenerator/FileFlows.ServerShared.dll differ diff --git a/build/utils/PluginInfoGenerator/FileFlows.ServerShared.pdb b/build/utils/PluginInfoGenerator/FileFlows.ServerShared.pdb index 2beb29d5..d7ffb30b 100644 Binary files a/build/utils/PluginInfoGenerator/FileFlows.ServerShared.pdb and b/build/utils/PluginInfoGenerator/FileFlows.ServerShared.pdb differ diff --git a/build/utils/PluginInfoGenerator/FileFlows.Shared.dll b/build/utils/PluginInfoGenerator/FileFlows.Shared.dll index d6fb6afe..f04c8977 100644 Binary files a/build/utils/PluginInfoGenerator/FileFlows.Shared.dll and b/build/utils/PluginInfoGenerator/FileFlows.Shared.dll differ diff --git a/build/utils/PluginInfoGenerator/FileFlows.Shared.pdb b/build/utils/PluginInfoGenerator/FileFlows.Shared.pdb index e3e6f6a4..e46e35aa 100644 Binary files a/build/utils/PluginInfoGenerator/FileFlows.Shared.pdb and b/build/utils/PluginInfoGenerator/FileFlows.Shared.pdb differ diff --git a/build/utils/PluginInfoGenerator/PluginInfoGenerator.dll b/build/utils/PluginInfoGenerator/PluginInfoGenerator.dll index dd137d44..83b26d5b 100644 Binary files a/build/utils/PluginInfoGenerator/PluginInfoGenerator.dll and b/build/utils/PluginInfoGenerator/PluginInfoGenerator.dll differ diff --git a/build/utils/PluginInfoGenerator/PluginInfoGenerator.pdb b/build/utils/PluginInfoGenerator/PluginInfoGenerator.pdb index 7613d7cb..7645dc6f 100644 Binary files a/build/utils/PluginInfoGenerator/PluginInfoGenerator.pdb and b/build/utils/PluginInfoGenerator/PluginInfoGenerator.pdb differ