po5 / thumbfast

High-performance on-the-fly thumbnailer script for mpv
Mozilla Public License 2.0
758 stars 34 forks source link

frontends: better support for mpv.net #113

Open stax76 opened 6 months ago

stax76 commented 6 months ago

I submit this pull request to improve mpv.net support. It works without the need of user configuration.

dyphire commented 3 months ago

A simpler and more effective patch:

---
 thumbfast.lua | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/thumbfast.lua b/thumbfast.lua
index fce7f6e..c7c7ab7 100644
--- a/thumbfast.lua
+++ b/thumbfast.lua
@@ -275,6 +275,13 @@ options.scale_factor = math.floor(options.scale_factor)

 local mpv_path = options.mpv_path

+if mpv_path == "mpv" then
+    local frontend_name = mp.get_property_native("user-data/frontend/name")
+    if frontend_name == "mpv.net" then
+        mpv_path = mp.get_property_native("user-data/frontend/process-path")
+    end
+end
+
 if mpv_path == "mpv" and os_name == "darwin" and unique then
     -- TODO: look into ~~osxbundle/
     mpv_path = string.gsub(subprocess({"ps", "-o", "comm=", "-p", tostring(unique)}).stdout, "[\n\r]", "")
@@ -520,10 +527,6 @@ local function spawn(time)
                             end
                         else
                             mp.commandv("show-text", "thumbfast: ERROR! cannot create mpv subprocess", 5000)
-                            if os_name == "windows" then
-                                mp.commandv("script-message-to", "mpvnet", "show-text", "thumbfast: ERROR! install standalone mpv, see README", 5000, 20)
-                                mp.commandv("script-message", "mpv.net", "show-text", "thumbfast: ERROR! install standalone mpv, see README", 5000, 20)
-                            end
                         end
                     else
                         mp.commandv("show-text", "thumbfast: ERROR! cannot create mpv subprocess", 5000)
--