Mandy/mandy.lua

129 lines
2.4 KiB
Lua
Raw Normal View History

2013-07-23 21:23:31 -05:00
#!/usr/bin/lua5.2
--ffmpeg
--libavcodec-extra-53 <-Ubuntu...suck it
require("iuplua")
require("iupluacontrols")
require('progress')
require('ffmpeg_progress')
2013-07-23 21:23:31 -05:00
--Main url entry box
function url_entry()
res, url = iup.GetParam("Mandy 0.2 - Enter URL", nil,
2013-07-23 21:23:31 -05:00
"Enter Youtube URL: %s\n", "")
if string.match(url, "youtube.com/watch") then
return url
else
iup.Message("Error", "The URL is not a youtube link")
iup.Flush()
iup.Close()
2013-07-23 21:23:31 -05:00
end
2013-07-23 21:23:31 -05:00
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",
2013-07-24 07:20:05 -05:00
directory="Music/",
file="*.mp3"}
2013-07-23 21:23:31 -05:00
getPath:popup(iup.ANYWHERE, iup.ANYWHERE)
local status = getPath.status
if status == "1" then
if string.match(getPath.value, ".mp3") then
local savedPath = getPath.value
return savedPath
else
local savedPath = getPath.value..".mp3"
return savedPath
end
2013-07-23 21:23:31 -05:00
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, y)
--local tmpName = math.random(0,999999999999)
--local tmpNameTwo = math.random(0,999999999999)
local thePath = set_dir()
local tmpPath = x.."--extract-audio --audio-format=mp3 -t --output="..thePath
--local tmpPath2 = "/tmp/youtube-dl-"..tmpName.."-"..tmpNameTwo..".flv"
2013-07-23 21:23:31 -05:00
2013-07-23 22:56:10 -05:00
popin.ytdl(tmpPath)
io.popen("vlc "..y)
return
2013-07-23 21:23:31 -05:00
end
--[[function ffmpeg(tmpPath, dirD)
local mp3 = "ffmpeg -i "..tmpPath.." -acodec libmp3lame -ac 2 -ab 192k -vn -y "..dirD
2013-07-24 07:20:05 -05:00
os.execute(mp3)
-- convert_mp3.go(mp3)
2013-07-24 07:20:05 -05:00
io.popen("vlc "..dirD)
2013-07-23 21:23:31 -05:00
end
--]]
2013-07-23 21:23:31 -05:00
--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, dir)
local yt = ytDl(url, dir)
2013-07-23 21:23:31 -05:00
return yt
end
--global.ffmpeg = function(tmpPath, saveDir)
-- local convert = ffmpeg(tmpPath, saveDir)
-- return convert
--end
2013-07-23 21:23:31 -05:00