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

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 #11

Closed
vivek1986 opened this issue Jul 27, 2022 · 5 comments
Assignees
Labels
Milestone

Comments

@vivek1986
Copy link

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
@surrim
Copy link
Owner

surrim commented Jul 27, 2022

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.

[...]

Thanks for your investigations(!) 🤗

Could you please create a pull request to the new branch https://github.com/surrim/vlc-delete/tree/master-windows-only if possible? At the moment I don't have a PC with me. Maybe somebody else could modify the branch that I can later merge it back into the master branch. I'm really no Lua expert :)

@vivek1986
Copy link
Author

@surrim I tried but I am getting this error when I try to push from my local repo copy to origin(master-windows-only):

remote: Permission to surrim/vlc-delete.git denied to vivek1986.
fatal: unable to access 'https://github.com/surrim/vlc-delete.git/': The requested URL returned error: 403

@surrim
Copy link
Owner

surrim commented Jul 28, 2022

@surrim I tried but I am getting this error when I try to push from my local repo copy to origin(master-windows-only):

remote: Permission to surrim/vlc-delete.git denied to vivek1986.
fatal: unable to access 'https://github.com/surrim/vlc-delete.git/': The requested URL returned error: 403

You can fork this project, then push to your own, and finally create a pull request on GitHub 😉
See creating-a-pull-request if you are not sure how it works.

@surrim
Copy link
Owner

surrim commented Jun 17, 2023

Applied changes with commit 539dc60, and some more 🚀

@surrim surrim self-assigned this Jun 17, 2023
@surrim surrim added this to the v0.2 milestone Jun 17, 2023
@surrim surrim added the bug label Jun 17, 2023
@surrim
Copy link
Owner

surrim commented Jun 18, 2023

Should be finally working with commit 6f5f276, see also #15 🚀

@surrim surrim closed this as completed Jun 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants