Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detection of deleted files and folders #61

Closed
stax76 opened this issue Jun 6, 2022 · 5 comments
Closed

Detection of deleted files and folders #61

stax76 opened this issue Jun 6, 2022 · 5 comments
Labels
enhancement New feature or request use custom-keybinds request should be completed using custom keybinds use-addons request should be completed with an addon

Comments

@stax76
Copy link

stax76 commented Jun 6, 2022

Deleting files might be a common use case. I download everything with a Chrome extension called External Application Launcher and yt-dlp.

I have my own script for file deletion and found two other.

https://github.com/jonniek/mpv-scripts/blob/master/trashfileonend.lua

https://github.com/zenyd/mpv-scripts/blob/master/delete_file.lua

https://github.com/stax76/mpv-scripts/blob/main/delete-current-file.lua

If you like the idea, and it's easy to do, maybe you could detect deletions by checking all files if the folder hasn't too many files (people often have fast SSD drives). Or react to a script message from my script. What do you think?

@CogentRedTester
Copy link
Owner

CogentRedTester commented Jun 7, 2022

Detecting changes in the filesystem is definitely out of scope for this script.

You can of course manually refresh the directory with the Ctrl+r keybind. You can also refresh the page with the script-binding file_browser/dynamic/reload command. But that may only work while file-browser is open.

@CogentRedTester
Copy link
Owner

If that isn't enough I could maybe add another script message that refreshes the directory even when the browser is closed.

@CogentRedTester
Copy link
Owner

CogentRedTester commented Jun 7, 2022

In the meantime you can just add this as an addon:

local mp = require "mp"
local fb = require "file-browser"

mp.register_script_message("refresh-directory", function(directory)
    local browser_directory = fb.get_directory()
    directory = fb.fix_path(directory, true)

    -- if the directory is already open then rescan, if it is a higher level directory then clear the cache
    if directory == browser_directory then
        fb.rescan()
    elseif browser_directory:find(directory, 1, true) == 1 then
        fb.clear_cache()
    end
end)

return {}

Send a script message with the absolute path of the directory you want to refresh and it will handle it.

Edit: fixed up a few small bugs

@stax76
Copy link
Author

stax76 commented Jun 7, 2022

Thank you for the support. What also seem to work is an input command:

Ctrl+F script-message osc-idlescreen no no_osd; script-binding file_browser/open-browser; show-text ' '; script-binding file_browser/dynamic/reload

@CogentRedTester
Copy link
Owner

If that works too then great.

@CogentRedTester CogentRedTester added enhancement New feature or request use-addons request should be completed with an addon use custom-keybinds request should be completed using custom keybinds labels Jun 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request use custom-keybinds request should be completed using custom keybinds use-addons request should be completed with an addon
Projects
None yet
Development

No branches or pull requests

2 participants