Created
January 9, 2022 00:51
-
-
Save FoxeiZ/c3540683a7dfbafba863b295f2bcd3fa to your computer and use it in GitHub Desktop.
make it work on termux with termux-api
This file contains hidden or 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
| -- 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