2013-07-24 13:13:50 -05:00
|
|
|
require ('iuplua')
|
|
|
|
|
2013-07-26 22:46:59 -05:00
|
|
|
local cancelflag
|
|
|
|
local downloadProgress
|
2013-07-24 13:13:50 -05:00
|
|
|
|
2013-07-26 22:46:59 -05:00
|
|
|
local function downloadStart(YtLink)
|
2013-07-27 11:51:07 -05:00
|
|
|
cancelButton = iup.button{
|
|
|
|
title = "Cancel",
|
|
|
|
action = function()
|
|
|
|
cancelflag = true
|
|
|
|
end
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
local downloadProgress = iup.progressbar{expand="HORIZONTAL", MARQUEE="YES"}
|
|
|
|
local dlgProgress = iup.dialog{
|
|
|
|
title = "converting",
|
|
|
|
dialogframe = "YES", border = "YES",
|
|
|
|
iup.vbox {
|
|
|
|
downloadProgress,
|
|
|
|
cancelButton,
|
2013-07-24 13:13:50 -05:00
|
|
|
}
|
2013-07-27 11:51:07 -05:00
|
|
|
}
|
|
|
|
dlgProgress.size = "QUARTERxEIGHT"
|
|
|
|
dlgProgress.menubox = "NO"
|
|
|
|
dlgProgress.close_cb = cancelButton.action
|
|
|
|
dlgProgress:showxy(iup.CENTER, iup.CENTER)
|
|
|
|
return dlgProgress
|
2013-07-24 13:13:50 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2013-07-26 22:46:59 -05:00
|
|
|
local function DL_progress(YtLink)
|
2013-07-27 11:51:07 -05:00
|
|
|
downloadStart()
|
|
|
|
local pipe = io.popen(YtLink)
|
|
|
|
|
|
|
|
repeat
|
|
|
|
local c = pipe:read()
|
|
|
|
if c then
|
|
|
|
iup.Flush()
|
|
|
|
iup.LoopStep()
|
|
|
|
iup.Flush()
|
|
|
|
if cancelflag then
|
|
|
|
iup.Message("Terminated", "You have canceled the conversion")
|
|
|
|
iup.Flush()
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
until not c
|
|
|
|
pipe:close()
|
|
|
|
iup.Close()
|
|
|
|
return
|
2013-07-24 13:13:50 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
convert_mp3 = {}
|
|
|
|
convert_mp3.go = function(tubeLink)
|
|
|
|
DL_progress(tubeLink)
|
2013-07-26 22:46:59 -05:00
|
|
|
return
|
2013-07-27 11:51:07 -05:00
|
|
|
end
|
2013-07-24 13:13:50 -05:00
|
|
|
|
|
|
|
|