2013-07-24 13:13:50 -05:00
|
|
|
require ('iuplua')
|
|
|
|
|
2013-07-31 21:35:58 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-07-26 22:46:59 -05:00
|
|
|
local cancelflag
|
2013-07-31 21:35:58 -05:00
|
|
|
local ffmpeg_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
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-07-31 21:35:58 -05:00
|
|
|
local ffmpeg_downloadProgress = iup.progressbar{expand="HORIZONTAL", MARQUEE="YES"}
|
2013-07-27 11:51:07 -05:00
|
|
|
local dlgProgress = iup.dialog{
|
|
|
|
title = "converting",
|
|
|
|
dialogframe = "YES", border = "YES",
|
|
|
|
iup.vbox {
|
2013-07-31 21:35:58 -05:00
|
|
|
ffmpeg_downloadProgress,
|
2013-07-27 11:51:07 -05:00
|
|
|
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-31 21:35:58 -05:00
|
|
|
local function DL_progress(YtLink, tmpPath)
|
2013-07-27 11:51:07 -05:00
|
|
|
downloadStart()
|
|
|
|
local pipe = io.popen(YtLink)
|
|
|
|
|
2013-07-31 21:35:58 -05:00
|
|
|
|
|
|
|
|
2013-07-27 11:51:07 -05:00
|
|
|
repeat
|
2013-07-31 21:35:58 -05:00
|
|
|
c = pipe:read(1)
|
|
|
|
|
|
|
|
iup.LoopStep()
|
|
|
|
-- iup.Message("Terminated","You have failed")
|
|
|
|
|
2013-07-27 11:51:07 -05:00
|
|
|
if cancelflag then
|
|
|
|
iup.Message("Terminated", "You have canceled the conversion")
|
|
|
|
iup.Flush()
|
2013-07-29 22:49:23 -05:00
|
|
|
pipe:close()
|
|
|
|
iup.Flush()
|
2013-07-31 21:35:58 -05:00
|
|
|
dlgProgress:destroy()
|
2013-07-29 22:49:23 -05:00
|
|
|
return false
|
2013-07-27 11:51:07 -05:00
|
|
|
end
|
2013-07-31 21:35:58 -05:00
|
|
|
|
|
|
|
until not c
|
|
|
|
dlgProgress:destroy()
|
|
|
|
pipe:close()
|
|
|
|
os.remove(tmpPath)
|
2013-07-29 22:49:23 -05:00
|
|
|
return true
|
2013-07-24 13:13:50 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
convert_mp3 = {}
|
2013-07-31 21:35:58 -05:00
|
|
|
convert_mp3.go = function(tubeLink, tmpPath)
|
|
|
|
local flag = DL_progress(tubeLink, tmpPath)
|
2013-07-29 22:49:23 -05:00
|
|
|
if not flag then return false else return true end
|
|
|
|
end
|
2013-07-24 13:13:50 -05:00
|
|
|
|
|
|
|
|