natural-harmonia-gropius / recent-menu

Recently played menu for mpv-player.
MIT License
33 stars 2 forks source link

how to enable or disable recentmenu for Streaming video and audio #22

Closed candrapersada closed 9 months ago

candrapersada commented 9 months ago

how to enable and disable recentmenu for Streaming video and audio?

natural-harmonia-gropius commented 9 months ago

Quick patch for disable it. but can you tell me why you want to disable it?

diff --git a/recentmenu.lua b/recentmenu.lua
index 2176590..c4ac8e4 100644
--- a/recentmenu.lua
+++ b/recentmenu.lua
@@ -319,8 +319,10 @@ function play_last()
 end

 function on_load()
+    current_item = { nil, nil, nil }
     local path = mp.get_property("path")
     if not path then return end
+    if is_protocol(path) then return end
     local filename = mp.get_property("filename")
     local dir, filename_without_ext, ext = split_path(filename)
     local title = mp.get_property("media-title") or path
@@ -345,6 +347,9 @@ function on_end(e)
     if not (e and e.reason and e.reason == "quit") then
         return
     end
+    if not current_item[1] then
+        return
+    end
     append_item(unpack(current_item))
 end
candrapersada commented 9 months ago

because the streaming link has expired and cannot be played again. It is possible to disable logging of specific URL with any criteria that can be queried through auto profiles.

natural-harmonia-gropius commented 9 months ago

I'll think about how to do it.

natural-harmonia-gropius commented 9 months ago

Can you try this?

diff --git a/recentmenu.lua b/recentmenu.lua
index ddf58a2..83d2082 100644
--- a/recentmenu.lua
+++ b/recentmenu.lua
@@ -2,12 +2,13 @@ local utils = require("mp.utils")
 local options = require("mp.options")

 local o = {
+    enabled = true,
     path = "~~/recent.json",
     length = 10,
     width = 88,
     ignore_same_series = true,
 }
-options.read_options(o)
+options.read_options(o, _, function() end)

 local path = mp.command_native({ "expand-path", o.path })

@@ -324,6 +325,7 @@ end

 function on_load()
     current_item = { nil, nil, nil }
+    if not o.enabled then return end
     local path = mp.get_property("path")
     if not path then return end
     local filename = mp.get_property("filename")
[youtube]
profile-cond=path:find("youtube")
script-opts-append=recentmenu-enabled=no
candrapersada commented 9 months ago

Yes working