From e7fd2689273bc80bf67af46d83192afaeaef9c96 Mon Sep 17 00:00:00 2001 From: Frank Skare Date: Thu, 27 Jun 2019 02:43:17 +0200 Subject: [PATCH] - --- Changelog.md | 4 ++++ addons/RatingAddon/RatingAddon.cs | 14 ++++++-------- mpv.net/Misc/Command.cs | 10 +++++++--- mpv.net/WinForms/MainForm.cs | 4 ++-- mpv.net/mpv/mp.cs | 3 +-- 5 files changed, 20 insertions(+), 15 deletions(-) diff --git a/Changelog.md b/Changelog.md index e1dcea0..37b8249 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,7 @@ +### + +- opening a URL manually no longer uses a input box but uses the clipboard directly + ### 4.4 - clipboard-monitoring was replaced by url-whitelist: diff --git a/addons/RatingAddon/RatingAddon.cs b/addons/RatingAddon/RatingAddon.cs index bb415fd..bd4042b 100644 --- a/addons/RatingAddon/RatingAddon.cs +++ b/addons/RatingAddon/RatingAddon.cs @@ -14,11 +14,11 @@ namespace RatingAddon public RatingAddon() { - mp.ClientMessage += mpv_ClientMessage; - mp.Shutdown += mpv_Shutdown; + mp.ClientMessage += ClientMessage; + mp.Shutdown += Shutdown; } - void mpv_Shutdown() + void Shutdown() { foreach (var i in Dic) { @@ -44,12 +44,10 @@ namespace RatingAddon } } - void mpv_ClientMessage(string[] args) + void ClientMessage(string[] args) { - if (args == null || - args.Length != 2 || - args[0] != "rate-file" || - !int.TryParse(args[1], out int rating)) + if (args == null || args.Length != 2 || args[0] != "rate-file" || + ! int.TryParse(args[1], out int rating)) return; diff --git a/mpv.net/Misc/Command.cs b/mpv.net/Misc/Command.cs index fa798e3..b8152de 100644 --- a/mpv.net/Misc/Command.cs +++ b/mpv.net/Misc/Command.cs @@ -218,9 +218,13 @@ namespace mpvnet public static void open_url(string[] args) { MainForm.Instance.Invoke(new Action(() => { - string command = VB.Interaction.InputBox("Enter URL to be opened."); - if (string.IsNullOrEmpty(command)) return; - mp.Load(new [] { command }, false, Control.ModifierKeys.HasFlag(Keys.Control)); + string clipboard = Clipboard.GetText(); + if (string.IsNullOrEmpty(clipboard) || !clipboard.Contains("://") || clipboard.Contains("\n") || clipboard.Contains(" ")) + { + Msg.ShowError("The clipboard does not contain a valid URL, it has to contain :// and is not allowed to contain a newline or space character."); + return; + } + mp.Load(new [] { clipboard }, false, Control.ModifierKeys.HasFlag(Keys.Control)); })); } diff --git a/mpv.net/WinForms/MainForm.cs b/mpv.net/WinForms/MainForm.cs index 21c98ac..f9c9387 100644 --- a/mpv.net/WinForms/MainForm.cs +++ b/mpv.net/WinForms/MainForm.cs @@ -533,8 +533,8 @@ namespace mpvnet foreach (string url in App.UrlWhitelist) { - if (clipboard.Contains("://") && !clipboard.Contains("\n") && - clipboard.Contains(url.ToLower()) && + if (clipboard.Contains("://") && ! clipboard.Contains("\n") && + ! clipboard.Contains(" ") && clipboard.Contains(url.ToLower()) && RegHelp.GetString(App.RegPath, "LastURL") != clipboard && Visible) { RegHelp.SetObject(App.RegPath, "LastURL", clipboard); diff --git a/mpv.net/mpv/mp.cs b/mpv.net/mpv/mp.cs index 082123e..73820d1 100644 --- a/mpv.net/mpv/mp.cs +++ b/mpv.net/mpv/mp.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.Drawing; using System.Drawing.Drawing2D; using System.Drawing.Imaging; @@ -213,7 +212,7 @@ namespace mpvnet if (WindowHandle == IntPtr.Zero) WindowHandle = FindWindowEx(MainForm.Hwnd, IntPtr.Zero, "mpv", null); - //Debug.WriteLine(evt.event_id.ToString()); + //System.Diagnostics.Debug.WriteLine(evt.event_id.ToString()); try {