From 69c5213867a5de06d07440ddd6e687a526d6122f Mon Sep 17 00:00:00 2001 From: datasone Date: Sat, 12 Mar 2022 18:41:34 +0800 Subject: [PATCH] Change mpv link title detection (online files doesn't have metadata) --- MPVMediaControl/PipeServer.cs | 2 +- notify_media.lua | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/MPVMediaControl/PipeServer.cs b/MPVMediaControl/PipeServer.cs index 10ee698..589e5af 100644 --- a/MPVMediaControl/PipeServer.cs +++ b/MPVMediaControl/PipeServer.cs @@ -98,7 +98,7 @@ private static string FromHexString(string hexString) return Encoding.UTF8.GetString(bytes); // returns: "Hello world" for "48656C6C6F20776F726C64" } - private static void ParseFile(MediaController controller, Dictionary parameters, bool nonHexPath = false) + private static void ParseFile(MediaController controller, Dictionary parameters) { var title = FromHexString(parameters["title"]); var artist = FromHexString(parameters["artist"]); diff --git a/notify_media.lua b/notify_media.lua index 889cfad..fa8d8ef 100644 --- a/notify_media.lua +++ b/notify_media.lua @@ -117,7 +117,7 @@ function notify_metadata_updated() end if not title or title == "" then - title = mp.get_property_native("filename/no-ext") + title = mp.get_property_native("media-title") end path = mp.get_property_native("path") @@ -180,6 +180,7 @@ end mp.set_property("options/input-ipc-server", "\\\\.\\pipe\\mpvsocket_" .. pid) mp.register_event("file-loaded", notify_current_file) +mp.observe_property("media-title", nil, notify_metadata_updated) mp.observe_property("metadata", nil, notify_metadata_updated) mp.observe_property("chapter", nil, notify_metadata_updated) mp.register_event("end-file", play_state_changed)