Code Monkey home page Code Monkey logo

vlc-delete's Introduction

Install

Windows

Copy vlc-delete.lua to %appdata%\vlc\lua\extensions\ and restart the VLC Media Player.

Installation script (requires Windows 10 / curl)

mkdir %appdata%\vlc\lua\extensions\
curl -# -o %appdata%\vlc\lua\extensions\vlc-delete.lua https://raw.githubusercontent.com/surrim/vlc-delete/master/vlc-delete.lua

Linux

Copy the vlc-delete.lua file to ~/.local/share/vlc/lua/extensions/ and restart the VLC Media Player.

Installation script

mkdir -p ~/.local/share/vlc/lua/extensions/
curl -# -o ~/.local/share/vlc/lua/extensions/vlc-delete.lua https://raw.githubusercontent.com/surrim/vlc-delete/master/vlc-delete.lua

Installation script for Flatpak

mkdir -p ~/.var/app/org.videolan.VLC/data/vlc/lua/extensions/
curl -# -o ~/.var/app/org.videolan.VLC/data/vlc/lua/extensions/vlc-delete.lua https://raw.githubusercontent.com/surrim/vlc-delete/master/vlc-delete.lua

Note: If trash-cli is installed videos will be moved to the recycle bin instead of removing them directly.

Usage

When playing a video you can click on ViewRemove current file from playlist and disk. Then the video will be removed and the next one is played.

Known bugs and issues

  • There is no fixed shortcut key; it depends on the menu language.
    For instance in English: Press and hold Alt to activate the hotkey navigation, then press i (Vi̲ew), then r (R̲emove current file from playlist and disk). I haven't found a solution to implement a fixed key; probably it's not supported by the VLC Media Player.
    Hotkeys animation
    • For AutoHotKey v2 and English menus, you can use the following script.
#Requires AutoHotkey v2.0

#HotIf WinActive("ahk_exe vlc.exe")
^Delete:: {
    Send("{Blind}{Ctrl up}{Delete up}")
    Send("{Blind}{Alt down}{i down}{i up}{r down}{r up}{Alt up}")
}
#HotIf

Thanks for contributing DanKaplanSES and abramter

  • Windows: UNC paths like \SERVER\Share\File.mp4 are not working.
    As a workaround, you could use net use P: "\uncpath" in the Windows terminal and open the file with a regular path. Thanks for contributing Taomyn and freeload101
  • Windows: Video can't be deleted if the file name contains emojis.
    Thanks for contributing Jonas1312

If you create a new issue please include your VLC Version number and operating system. Otherwise it's hard to reproduce.
The biggest help would be to contribute some Lua Code.

vlc-delete's People

Contributors

adrianparisi avatar benjamin-loison avatar johbii avatar surrim avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vlc-delete's Issues

Stopped working suddenly after update

I'm using VLC 3.0.19
Vetinari builduser@ Oct 11 2023

and my OS is arch linux
Linux mohammad-81yh 6.1.58-1-lts #1 SMP PREEMPT_DYNAMIC Sun, 15 Oct 2023 18:38:43 +0000 x86_64 GNU/Linux

image

add a hotkey

great extension 😄 ! thanks for your work!

Would it be possible to add a hotkey?

Cheers,
ben

Here You Go - Alternate Script (Autohotkey v2+) -- Press DEL (or SHIFT+DEL) to Delete Videos + Move

Here is a a relatively better script than vlc-delete that I wrote using AutoHotkey (v2+) that not only works when VLC is in true full-screen mode, unlike vlc-delete, but this script also allows using multiple customizable hotkeys to do the following:

  1. Delete the video to recycle bin (default shortcut key: DEL)
  2. Delete the video permanently from disk (default shortcut key: SHIFT+DEL)
  3. Move the video file to an arbitrary location e.g. C:\ (default shortcut key: CTRL+Z)

I added a lot of code comments for your convenience. And, the default shortcut keys can be changed easily to whatever you want, as seen in the code below.

; Delete/Move a playing VLC video (via hotkeys) then jumps to the next video in the playlist.
; ------------------------------------------
; DEL       = Delete video to the recycle bin
; SHIFT+DEL = Permanently delete video of disk
; CTRL+Z    = Move video to arbitrary location
; ------------------------------------------

MOVE_ACTION_DIR := "C:\"
MEDIA_INFO_DIALOG_TITLE := "Current Media Information"
WAIT_FOR_MEDIA_INFO_DIALOG_SECS := 0.25
WAIT_FOR_MEDIA_INFO_DIALOG_RETRIES := 10
CLIPBOARD_WAIT_SECS := 1
WAIT_FOR_NEXT_VID_SECS := 0.10
WAIT_FOR_NEXT_VID_RETRIES := 10
GIVE_BACK_MOUSE_CONTROL_AFTER_SECS := 5

#Requires AutoHotkey >=2.0
#SingleInstance Force
#HotIf WinActive("ahk_class Qt5QWindowIcon")  ; only trigger the use of hotkeys if a VLC window is active

~Shift & Delete:: {  ; SHIFT+DEL = Permanently delete video off disk
    KeyWait "Delete", "Up"
    KeyWait "Shift", "Up"
    DoPermDelete()
    Return
}

~Delete:: {  ; DEL = Delete video to the recycle bin
    KeyWait "Delete", "Up"
    DoRecycleDelete()
    Return
}

~Ctrl & z:: {  ; CTRL+Z = Move video to arbitrary location
    KeyWait "Ctrl", "Up"
    KeyWait "z", "Up"
    DoMove(MOVE_ACTION_DIR)
    Return
}

DoAction(action) {
    BlockInput "MouseMove"  ; block user from using the mouse
    SetTimer AllowMouse, GIVE_BACK_MOUSE_CONTROL_AFTER_SECS * 1000  ; restore the mouse for the user at some point if something goes wrong
    vlcTitle := WinGetTitle("A") ; vlc should be the active window because it's the only way this line got called
    isFullScreen := false

    ; open the media information dialog

    Send "^i" ; CTRL+I is harcoded in vlc to open the media info dialog
    if !WinWait(MEDIA_INFO_DIALOG_TITLE, , WAIT_FOR_MEDIA_INFO_DIALOG_SECS) {
        ; cant find information window - vlc in fullscreen?
        ; attempt to leave fullscreen and retry opening information dialog
        Send "{ESC}" ; leave fullscreen
        Sleep 10
        Send "^i"
        isFullScreen := true ; user was indeed in fullscreen - remember so we can restore it later
        retry := 1
        while !WinWait(MEDIA_INFO_DIALOG_TITLE, , WAIT_FOR_MEDIA_INFO_DIALOG_SECS) {            
            retry++
            if retry == WAIT_FOR_MEDIA_INFO_DIALOG_RETRIES { ; something went wrong.
                Msgbox "Can't find Media Information dialog. Aborting!"
                Return
            }
            Send "^i"
        }
    }

    ; save the full path (as seen in the information dialog) of the video that is playing to the clipboard

    MouseGetPos &orgMouseX, &orgMouseY
    orgClipboardContent := ClipboardAll()
    WinActivate MEDIA_INFO_DIALOG_TITLE
    WinWaitActive MEDIA_INFO_DIALOG_TITLE
    WinGetPos , , &width, &height, MEDIA_INFO_DIALOG_TITLE
    fileLocationX := width/2
    fileLocationY := height-52    
    CoordMode "Mouse", "Window"
    MouseMove fileLocationX, fileLocationY, 1
    Click 3 ; selects the entire path
    Send "^c" ; copies the path to the clipboard
    CoordMode "Mouse", "Screen"
    MouseMove orgMouseX, orgMouseY, 1
    if !ClipWait(CLIPBOARD_WAIT_SECS) {
        WinClose MEDIA_INFO_DIALOG_TITLE
        WinWaitClose MEDIA_INFO_DIALOG_TITLE
        MsgBox "Can't delete/move file!  Problem finding file location nside Media Information dialog."
        Return
    }
    WinClose MEDIA_INFO_DIALOG_TITLE
    WinWaitClose MEDIA_INFO_DIALOG_TITLE

    ; if the user was originally in fullscreen this restore it now

    if isFullScreen {
        ; restore fullscreen if it was orginally set
        WinGetPos , , &width, &height, vlcTitle
        videoX := width/2
        videoY := height/2
        CoordMode "Mouse", "Window"
        MouseMove videoX, videoY, 1
        Click 2
        CoordMode "Mouse", "Screen"
        MouseMove orgMouseX, orgMouseY, 1
    }

    ; move to the next video -- so it can delete/move this video (because vlc locks the running video)

    Send "{PgDn Down}"
    retry := 1
    while WinGetTitle("A") == vlcTitle { ; wait for the next video to start playing
        Sleep WAIT_FOR_NEXT_VID_SECS * 1000 ; give it some more time to move to next video
        retry++
        if retry == WAIT_FOR_NEXT_VID_RETRIES { ; something went wrong.  no more videos? (we cant delete/move if its only 1 video)
            MsgBox "Didn't detect next video change. Only 1 video left?`nCan't delete/move this video."
            Return
        }
    }
    vlcTitle := WinGetTitle("A")

    ; perform action (delete/move the video now)

    BlockInput "MouseMoveOff"  ; allow the user to have control over the mouse now (in case the delete/move takes too long)
    try
        if action == "del_perm"
            FileDelete A_Clipboard
        else if action == "del_recycle" {
            ;WinActivate "ahk_class Shell_TrayWnd"
            ;WinWaitActive "ahk_class Shell_TrayWnd"
            FileRecycle A_Clipboard
        } else
            FileMove A_Clipboard, action
    catch as err
        MsgBox "Problem deleting/moving file:`n`n" A_Clipboard "`n`n(" err.What " - " err.Message ")"
    A_Clipboard := orgClipboardContent
    try
        WinActivate vlcTitle
    catch
        WinActivate "ahk_class Qt5QWindowIcon" ; strange, we can't find the player! ok just activate any vlc window blindly
}

DoPermDelete() {
    DoAction("del_perm")
}

DoRecycleDelete() {
    DoAction("del_recycle")
}

DoMove(path) {
    DoAction(path)
}

AllowMouse() {
    BlockInput "MouseMoveOff"
}

Don't know if this plugin works in other OSes, but in Windows (10/11) it surely didn't work, so I had to do many fixes and turn this plugin into Windows only using only core Windows batch functions for operations

Don't know if this plugin works in other OSes, but in Windows (10/11) it surely didn't work, so I had to do many fixes and turn this plugin into Windows only using only core Windows batch functions for operations.

So in hopes that this inspires others here to rectify the errors in the Lua libraries so that they don't throw errors when dealing with File I/O operations in Windows, here's the code and the Stackoverflow page where also I mentioned this as an answer to my own question:

-- Copy this file to %ProgramFiles%\VideoLAN\VLC\lua\extensions\ and restart VLC Media player.
function descriptor()
    return {
        title = "VLC Delete Media File(Windows only)";
        version = "1.0";
        author = "Vicky Dev";
        shortdesc = "&Remove current file from playlist and disk";
        description = [[
<h1>VLC Delete Media File(Windows only)</h1>"
When you're playing a file, use this to easily
delete the current file from your <b>playlist</b> and <b>disk</b> with one click.<br>
Disclaimer: The author is not responsible for damage caused by this extension.
        ]];
    }
end

function sleep(seconds)
    local t0 = os.clock()
    local tOriginal = t0
    while os.clock() - t0 <= seconds and os.clock() >= tOriginal do end
end

function removeItem()
    local id = vlc.playlist.current()
    vlc.playlist.delete(id)
    vlc.playlist.gotoitem(id + 1)
    vlc.deactivate()
end

function activate()
    local item = vlc.input.item()
    local uri = item:uri()
    uri = string.gsub(uri, "^file:///", "")
    uri = vlc.strings.decode_uri(uri)
    path = string.gsub(uri, "/", "\\")
    vlc.msg.info("[VLC Delete Media File(Windows only)] removing: "..uri.." : "..path)
    removeItem()
    retval, err = os.execute("if exist ".."\""..path.."\"".." @(call )")
    if (type(retval) == 'number' and retval == 0) then
        os.execute("del /f /a /q ".."\""..path.."\"")
    end
end

function click_ok()
    d:delete()
    vlc.deactivate()
end

function deactivate()
    vlc.deactivate()
end

function close()
    deactivate()
end

function meta_changed()
end

keyboard shortcut

Hi,
Is it possible to add a shortcut on DELETE key on keyboard ?
Thanks

Video not deleted if file name contains an emoji (windows)

Hi,

The extension does not work if the file name contains an emoji (testtest ❤️.mp4 for example).

lua info: [vlc-delete] removing: C:/Users/Jonas/Desktop/testtest ❤️.mp4
lua info: [vlc-delete] windows detected
lua info: [vlc-delete] before string.gsub: C:/Users/Jonas/Desktop/testtest ❤️.mp4
lua info: [vlc-delete] after string.gsub: C:\Users\Jonas\Desktop\testtest ❤️.mp4
main info: playlist is empty
lua info: [vlc-delete] error: File does not exist

fileExists("\"" .. file .. "\"") fails to detect the file, but I don't know why...

Thanks

Does not work with Windows UNC paths

When directly viewing files on a Windows UNC path e.g. \SERVER\Share\File.mp4 it says the file does not exist.

I also could not see from the script if the video is stopped before it deletes because VLC has a nasty habit of locking the file until it opens the next one.

bind key

can you update to bind the shortcut key to [shift + delete] ?

Shortcut key

Thanks for your work on this! A shortcut key option would be a huge improvement for this extention. I would love to map it to a button on my Stream Deck to quickly delete files from a playlist as I review them.

mac os shows as installed but is not in view menu

Is this broken for new mac vlcs? Anything I can do?

I moved the lua in two places on my osx, it shows as installed addon with check mark, but when I click view in menu there's nothing there new about deleting.

Playlist not saved after delete

Can you add something like a "save playlist" command/function after using vlc-delete?

Currently the file is deleted permanently.

But it is only removed from the playlist until you close VLC.

When you start VLC again with that playlist, the files are listed, but cannot be played, because, obviously, the physical file does not exist.

And due to a VLC generic bug, when it cannot play an a file in the playlist that does not exist, the CPU usage goes to 100% until you kill VLC.

Strangely enough, there is no vlc.playlist.save command that we can add?

https://code.videolan.org/videolan/vlc/-/blob/master/share/lua/README.txt
https://code.videolan.org/videolan/vlc/-/blob/master/share/lua/playlist/README.txt

Not working on OSX w/ VLC 3.0.8

Hi,
this looks exactly like what I was looking for, unfortunately it doesn't seem to work on OSX with VLC 3.0.8. The extension is being displayed in the menu VLC/Extensions as "VLC Delete", but when activating it only seems to remove the item from the playlist, but not from the disk. I am not able to see any error messages or similar.

Regards

My way Implement fixed key

I'm using autokey app on linux, basically it select VLC window then simulate keyboard press alt + ir

import subprocess

def focus_or_open_vlc():
    process = subprocess.Popen(['pgrep', '-f', 'vlc'], stdout=subprocess.PIPE)
    output, _ = process.communicate()
    if process.returncode == 0:
     # Vlc is already running, focus on the active Vlc window
     dolphin_windows = subprocess.check_output(['wmctrl', '-l', '-p']).decode().splitlines()
     for window in dolphin_windows:
         if any(pid in window for pid in output.decode().split()):
             window_id = window.split()[0]
             subprocess.Popen(['wmctrl', '-ia', window_id])
                         
             # Launch vlc-delete extension
             time.sleep(0.5)
             keyboard.send_keys("<alt>+ir")
             
             break
    else:
        # Dolphin is not running, so open a new instance
        subprocess.Popen(['/usr/bin/vlc', '--started-from-file', '/mnt/storage/Music/with-lyric/'])

focus_or_open_vlc()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.