Skip to content

Instantly share code, notes, and snippets.

@e-desouza
Created August 23, 2020 04:12
Show Gist options
  • Select an option

  • Save e-desouza/9c340a5373492befb1203428e458bbf5 to your computer and use it in GitHub Desktop.

Select an option

Save e-desouza/9c340a5373492befb1203428e458bbf5 to your computer and use it in GitHub Desktop.
Delete current file on disk and playlist in VLC (OSX only)
--[[
Copyright 2020 wizard
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
]]--
function descriptor()
return {
title = "VLC Delete OSX";
version = "0.2";
author = "wizard";
shortdesc = "Remove current file from playlist and disk";
description = [[
<h1>vlc-delete</h1>"
VLC Delete OSX can delete the current file from your playlist and <b>disk</b> with one click.<br>
This extension has been tested on OSX 15.x+ with VLC 3.0.11.<br>
The author is not responsible for damage caused by this extension.
]];
}
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)
vlc.msg.info("[vlc-delete] removing: " .. uri)
os.execute("rm -f \"" .. uri .. "\"")
removeItem()
end
function deactivate()
vlc.deactivate()
end
function close()
deactivate()
end
function meta_changed()
end
@kevinp2
Copy link
Copy Markdown

kevinp2 commented Sep 18, 2020

Hi!

I was able to install this on MacOS and it works with 3.0.11.1 But I have to run the extension by using Menu > Extensions > VLC Delete OSX

Is there a way to attach this to a hotkey? I could not figure this out easily. Perhaps it can be part of the documentation block, e.g.

Copy this file to /Applications/VLC.app/Contents/MacOS/share/lua/extensions/
Set up a hotkey to run the extension using xxx...

@e-desouza
Copy link
Copy Markdown
Author

You gota set up keyboard shortcuts like this :
image

@kevinp2
Copy link
Copy Markdown

kevinp2 commented Sep 18, 2020

Great, thank you, I set up Command-X since VLC seems to use Command-D for something else.

@themighty1
Copy link
Copy Markdown

themighty1 commented Jul 31, 2021

Thanks, works on Linux too if you replace the line
uri = string.gsub(uri, '^file:///', '')
with
uri = string.gsub(uri, '^file://', '')
i.e. 2 slashes // instead of 3 ///

@yyaremenko
Copy link
Copy Markdown

Thank you. Also, for MacOS if you want to move the files to the Trash bin, just in case you'll change your mind later, replace

os.execute("rm -f \"" .. uri .. "\"")
with
os.execute("mv -fv \"" .. uri .. "\" ~/.Trash/")

@PeterFuhren
Copy link
Copy Markdown

Thank you. Also, for MacOS if you want to move the files to the Trash bin, just in case you'll change your mind later, replace

os.execute("rm -f \"" .. uri .. "\"") with os.execute("mv -fv \"" .. uri .. "\" ~/.Trash/")

Great addition! Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment