From 103ae81b8b63f8b4efb52367b526e7571c2f3cad Mon Sep 17 00:00:00 2001 From: Frank Skare Date: Sat, 29 Jun 2019 12:36:35 +0200 Subject: [PATCH] - --- Changelog.md | 3 ++- addons/RatingAddon/RatingAddon.cs | 2 +- mpv.net/mpv/mp.cs | 22 +++++++++++++++------- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/Changelog.md b/Changelog.md index 85ec604..47eb9ef 100644 --- a/Changelog.md +++ b/Changelog.md @@ -4,8 +4,9 @@ - the manifest was missing the company attribute which caused mpv.net not appearing in the 'Open with' menu of the Windows File Explorer, thanks to 44vince44 for pointing this out!!! -- a new Python script example was added to the wiki and the scripting and +- new Python and C# script examples were added to the wiki and the scripting and add-on documentation was improved +- invalid command line arguments were ignored, now an error message is shown ### 4.4 diff --git a/addons/RatingAddon/RatingAddon.cs b/addons/RatingAddon/RatingAddon.cs index 87dcc9b..27ebfc1 100644 --- a/addons/RatingAddon/RatingAddon.cs +++ b/addons/RatingAddon/RatingAddon.cs @@ -50,7 +50,7 @@ namespace RatingAddon //handles keys defined in input.conf void ClientMessage(string[] args) { - if (args.Length != 2 || args[0] != "rate-file" || ! int.TryParse(args[1], out int rating)) + if (args[0] != "rate-file" || ! int.TryParse(args[1], out int rating)) return; Dic[mp.get_property_string("path")] = rating; mp.commandv("show-text", $"Rating: {rating}"); diff --git a/mpv.net/mpv/mp.cs b/mpv.net/mpv/mp.cs index cfe20e4..2019f2b 100644 --- a/mpv.net/mpv/mp.cs +++ b/mpv.net/mpv/mp.cs @@ -285,6 +285,7 @@ namespace mpvnet i.Action.Invoke(args.Skip(2).ToArray()); } } + if (!found) { List names = mpvnet.Command.Commands.Select((item) => item.Name).ToList(); @@ -523,7 +524,7 @@ namespace mpvnet foreach (string i in args) { - if (!i.StartsWith("--") && (File.Exists(i) || i == "-" || i.StartsWith("http"))) + if (!i.StartsWith("--") && (i == "-" || i.StartsWith("http") || File.Exists(i))) { files.Add(i); if (i.StartsWith("http")) @@ -537,14 +538,21 @@ namespace mpvnet { if (i.StartsWith("--")) { - if (i.Contains("=")) + try { - string left = i.Substring(2, i.IndexOf("=") - 2); - string right = i.Substring(left.Length + 3); - set_property_string(left, right); + if (i.Contains("=")) + { + string left = i.Substring(2, i.IndexOf("=") - 2); + string right = i.Substring(left.Length + 3); + set_property_string(left, right, true); + } + else + set_property_string(i.Substring(2), "yes", true); + } + catch (Exception e) + { + Msg.ShowException(e); } - else - set_property_string(i.Substring(2), "yes"); } } }