Skip to content

Instantly share code, notes, and snippets.

@Shudouken
Created January 28, 2015 06:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shudouken/7286734aa651121400cb to your computer and use it in GitHub Desktop.
Save Shudouken/7286734aa651121400cb to your computer and use it in GitHub Desktop.
terminal-dl.lua
-- README:
-- calls terminal and starts youtube-dl to download the video currently playing
local opt = require 'mp.options'
-- default options, .conf is read
local options = {
terminal = 'guake -t && guake -n guake -e',
--terminal = 'gnome-terminal -e',
--terminal = 'konsole -e'
}
read_options(options, "terminal-dl")
-----------------
-- Main script --
-----------------
function download()
mp.resume_all()
local url = mp.get_property("path", "")
url = string.gsub(url, "'", "'\\''")
if string.sub(url,1,4) == "http" then
local command = options.terminal .. ' "youtube-dl \'' .. url .. '\'"'
mp.osd_message("Download started")
os.execute(command)
else
mp.osd_message("Error: local file, no url provided!", 2)
end
end
mp.add_key_binding("alt+d", "terminal-dl", download)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment