Mandy/ffmpeg_progress.lua

71 lines
1.4 KiB
Lua
Raw Normal View History

require ('iuplua')
2013-07-26 22:46:59 -05:00
local cancelflag
local ffmpeg_downloadProgress
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 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 {
ffmpeg_downloadProgress,
2013-07-27 11:51:07 -05:00
cancelButton,
}
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
end
local function DL_progress(YtLink, tmpPath)
2013-07-27 11:51:07 -05:00
downloadStart()
local pipe = io.popen(YtLink)
2013-07-27 11:51:07 -05:00
repeat
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()
pipe:close()
iup.Flush()
dlgProgress:destroy()
return false
2013-07-27 11:51:07 -05:00
end
until not c
dlgProgress:destroy()
pipe:close()
os.remove(tmpPath)
return true
end
convert_mp3 = {}
convert_mp3.go = function(tubeLink, tmpPath)
local flag = DL_progress(tubeLink, tmpPath)
if not flag then return false else return true end
end