Created
January 28, 2015 06:20
-
-
Save Shudouken/7286734aa651121400cb to your computer and use it in GitHub Desktop.
terminal-dl.lua
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
-- 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