109 lines
1.9 KiB
Lua
109 lines
1.9 KiB
Lua
#!/usr/bin/lua5.2
|
|
|
|
--ffmpeg
|
|
--libavcodec-extra-53 <-Ubuntu...suck it
|
|
|
|
require("iuplua")
|
|
require("iupluacontrols")
|
|
require('progress')
|
|
|
|
|
|
--Main url entry box
|
|
function url_entry()
|
|
|
|
res, url = iup.GetParam("Mandy - Enter URL", nil,
|
|
"Enter Youtube URL: %s\n", "")
|
|
|
|
|
|
return url
|
|
|
|
end
|
|
|
|
|
|
--Ask user to select a codec
|
|
function sel_Codec()
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--Ask user to set directory
|
|
function set_dir()
|
|
getPath = iup.filedlg{dialogtype = "SAVE", title="Save file...",
|
|
filter="*.mp3", filterinfo="mp3",
|
|
directory="~/Music"}
|
|
|
|
getPath:popup(iup.ANYWHERE, iup.ANYWHERE)
|
|
|
|
local status = getPath.status
|
|
|
|
if status == "1" then
|
|
local savedPath = getPath.value
|
|
return savedPath
|
|
|
|
elseif status == "0" then
|
|
|
|
local savedPath = getPath.value
|
|
|
|
g_status = "23"
|
|
return savedPath, g_status
|
|
|
|
|
|
|
|
elseif status == "-1" then
|
|
|
|
g_status = "23"
|
|
return g_status
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
function ytDl(x)
|
|
local tmpName = math.random(0,999999999999)
|
|
local tmpNameTwo = math.random(0,999999999999)
|
|
local tmpPath = x.." --output=/tmp/youtube-dl-"..tmpName.."-"..tmpNameTwo..".flv"
|
|
local tmpPath2 = "/tmp/youtube-dl-"..tmpName.."-"..tmpNameTwo..".flv"
|
|
|
|
popin.ytdl(tmpPath)
|
|
|
|
|
|
return tmpPath2
|
|
|
|
end
|
|
|
|
function ffmpeg(tmpPath, dirD)
|
|
|
|
mp3 = "ffmpeg -i "..tmpPath.." -acodec libmp3lame -ac 2 -ab 192k -vn -y "..dirD..".mp3"
|
|
os.execute(mp3)
|
|
io.popen("vlc "..dirD..".mp3")
|
|
end
|
|
|
|
--put everything into a table to use local functions globally
|
|
global = {}
|
|
global.url = function ()
|
|
local url = url_entry()
|
|
return url
|
|
end
|
|
|
|
global.dir = function()
|
|
local dir = set_dir()
|
|
return dir
|
|
end
|
|
|
|
global.path = function(url)
|
|
local yt = ytDl(url)
|
|
return yt
|
|
end
|
|
|
|
global.ffmpeg = function(tmpPath, saveDir)
|
|
local convert = ffmpeg(tmpPath, saveDir)
|
|
return convert
|
|
end
|
|
|
|
|