Skip to content

Instantly share code, notes, and snippets.

@FoxeiZ
Created January 9, 2022 00:51
Show Gist options
  • Select an option

  • Save FoxeiZ/c3540683a7dfbafba863b295f2bcd3fa to your computer and use it in GitHub Desktop.

Select an option

Save FoxeiZ/c3540683a7dfbafba863b295f2bcd3fa to your computer and use it in GitHub Desktop.
make it work on termux with termux-api
-- https://github.com/jonniek/mpv-scripts/blob/master/appendURL.lua
-- Author: donmaiq
-- Modifier: FoxeiZ
-- Appends url from clipboard to the playlist
-- Termux edition
local utils = require 'mp.utils'
local msg = require 'mp.msg'
--main function function append()
local clipboard = get_clipboard()
if clipboard then
mp.commandv("loadfile", clipboard, "append-play") msg.info("URL appended: "..clipboard)
end
end
--handles the subprocess response table and return clipboard if it was a success
function handleres(res, args) if not res.error and res.status == 0 then return res.stdout
else
msg.error("There was an error getting clipboard!")
msg.error(" Status: "..(res.status or ""))
msg.error(" Error: "..(res.error or ""))
msg.error(" stdout: "..(res.stdout or ""))
msg.error("args: "..utils.to_string(args))
msg.error("Make sure you already installed termux-api")
return nil
end
end
function get_clipboard()
return handleres(utils.subprocess({ args = 'termux-clipboard-get', cancellable = false }), args)
end
mp.add_key_binding("a", "appendURL", append)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment