Last active
October 10, 2024 16:55
-
-
Save crmaxx/45fc0b22318e4593fb34ed921449d5ba to your computer and use it in GitHub Desktop.
VLC Extensions: DELETE current playing FILE FROM DISK and Shuffle Playlist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--[[ | |
INSTALLATION (create directories if they don't exist): | |
- put the file in the VLC subdir /lua/extensions, by default: | |
* Windows (all users): %ProgramFiles%\VideoLAN\VLC\lua\extensions\ | |
* Windows (current user): %APPDATA%\VLC\lua\extensions\ | |
* Linux (all users): /usr/share/vlc/lua/extensions/ | |
* Linux (current user): ~/.local/share/vlc/lua/extensions/ | |
* Mac OS X (all users): /Applications/VLC.app/Contents/MacOS/share/lua/extensions/ | |
- Restart VLC. | |
]]-- | |
--[[ Extension description ]] | |
function descriptor() | |
return { | |
title = "Diskdelete" ; | |
version = "0.2" ; | |
author = "Mark Morschhäuser" ; | |
shortdesc = "DELETE current playing FILE FROM DISK"; | |
description = "<h1>Diskdelete</h1>" | |
.. "When you're playing a file, use Diskdelete to " | |
.. "easily delete this file <b>from your disk</b> with one click." | |
.. "<br>This will NOT change your playlist, it will <b>ERASE the file</b> itself!" | |
.. "<br>It will not use the Recycle Bin, the file will be gone immediately!" | |
.. "<br>This extension has been tested on GNU Linux with VLC 2.0.3." | |
.. "<br>The author is not responsible for damage caused by this extension."; | |
url = "https://github.com/VanNostrand/Diskdelete" | |
} | |
end | |
--[[ Hooks ]] | |
-- Activation hook | |
function activate() | |
vlc.msg.dbg("[Diskdelete] Activated") | |
d = vlc.dialog("Diskdelete") | |
d:add_label("<b>Clicking</b> this button will <b>delete</b> the currently playing file <b>from disk</b>.<br>You have to <b>be sure</b> as <b>you won't be asked</b> again!<br>You are responsible for your own actions, consider yourself warned.") | |
d:add_button("DELETE CURRENT FILE PERMANENTLY FROM DISK WITHOUT ASKING", delete) | |
d:show() | |
end | |
-- Deactivation hook | |
function deactivate() | |
vlc.msg.dbg("[Diskdelete] Deactivated") | |
vlc.deactivate() | |
end | |
function close() | |
deactivate() | |
end | |
--[[ The file deletion routine ]] | |
function delete() | |
item = vlc.input.item() -- get the current playing file | |
uri = item:uri() -- extract it's URI | |
filename = vlc.strings.decode_uri(uri) -- decode %foo stuff from the URI | |
vlc.playlist.skip(1) | |
--[[ | |
--vlc.misc.mwait(vlc.misc.mdate() + 3000000) | |
--vlc.var.add_callback(vlc.object.input(), "time", vlc.playlist.skip(1), 3000000) | |
]]-- | |
--retval, err = os.chmod(filename, 0777) | |
filename = string.sub(filename,9) -- remove 'file://' prefix which is 7 chars long | |
vlc.msg.dbg("[Diskdelete] selected for deletion: " .. filename) | |
retval, err = os.remove(filename) -- delete the file with this filename from disk | |
if(retval == nil) -- error handling; if deletion failed, print why | |
then | |
vlc.msg.dbg("[Diskdelete] error: " .. err) | |
end | |
end | |
-- This empty function is there, because vlc pested me otherwise | |
function meta_changed() | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function descriptor() | |
return { | |
title = "Shuffle Playlist", | |
version = "1.1.2", | |
shortdesc = "Shuffle Playlist", | |
description = "Shuffles all items on the playlist similar to MPC-HC's randomize playlist function.", | |
author = "Daniel Grünwald", | |
icon = [[<?xml version="1.0" encoding="UTF-8" standalone="no"?> | |
<svg width="30" height="30" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1"><path stroke="none" fill="#33333f" d="M 18.3125,23 22,23.03125 22,27 28,21 22,15 22,19.03125 19.6875,19 7.6875,10 2,10 2,14 6.34375,14 z M 15.361844,14.403932 16.53125,10 24,10 24,14 30,8 24,2 24,6 13.46875,6 11.908809,11.764408 z M 10.212023,18.207792 8.9375,23 0,23 l 0,4 12.03125,0 1.651047,-6.199744 z"/></svg>]], | |
capabilities = {"trigger"} | |
} | |
end | |
function trigger() | |
vlc.playlist.stop() | |
math.randomseed(os.time()) | |
local pl = vlc.playlist.get("normal", false) | |
local randomList = {} | |
for i, v in ipairs(pl.children) do | |
if v.duration == -1 then v.duration = 0 end | |
randomList[#randomList + 1] = v | |
end | |
local swap | |
for i = 1, #randomList do | |
swap = math.random(i, #randomList) | |
randomList[i], randomList[swap] = randomList[swap], randomList[i] | |
end | |
vlc.playlist.clear() | |
vlc.playlist.enqueue(randomList) | |
vlc.msg.info("Playlist shuffled!") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment