From 0b4ae7693444be4e522458f477ca05c4c8d76b06 Mon Sep 17 00:00:00 2001 From: Logen Kain Date: Fri, 26 Jul 2013 22:46:59 -0500 Subject: [PATCH] possibly working marquee --- ffmpeg_progress.lua | 74 +++++++++++++++++---------------------------- 1 file changed, 27 insertions(+), 47 deletions(-) diff --git a/ffmpeg_progress.lua b/ffmpeg_progress.lua index ef26a8b..811ac88 100644 --- a/ffmpeg_progress.lua +++ b/ffmpeg_progress.lua @@ -1,62 +1,47 @@ --- take note of YtLink, I keep passing it around in order to show it as the title bar --- of the download window, YOU WILL HAVE TO PAY ATTENTION TO IT --- IT GOES THROUGH FUCKING EVERYTHING --- Also it will be replaced by what the user saves the file as --- keep that in mind as well require ('iuplua') -local cancelflag --set variable -local downloadProgress --set variable +local cancelflag +local downloadProgress -local function downloadStart(YtLink) --create button and cancle flag +local function downloadStart(YtLink) cancelButton = iup.button{ title = "Cancel", action = function() cancelflag = true - - --return iup.CLOSE --not sure if needed - - end + end } local downloadProgress = iup.progressbar{expand="HORIZONTAL", MARQUEE="YES"} - local dlgProgress = iup.dialog{ --create main window - title = YtLink, + local dlgProgress = iup.dialog{ + title = "converting", dialogframe = "YES", border = "YES", - iup.vbox { -- create vbox that contains said objects + iup.vbox { downloadProgress, cancelButton, } } - dlgProgress.size = "QUARTERxEIGHT" --should be size of dialog box - -- dlgProgress.menubox = "NO" -- no windows menus - dlgProgress.close_cb = cancelButton.action -- calls the action of the button - dlgProgress:showxy(iup.CENTER, iup.CENTER) -- show and position box + 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) -- monitor download progress - downloadStart(YtLink) -- start the progress bar - -- downloadProgress.value = 0 - -- local pipe = io.popen(YtLink) - os.execute(YtLink) - --[[repeat - local c = pipe:read() -- read the first 20 characters of each line - if c then -- if c is true then... +local function DL_progress(YtLink) + downloadStart() + local pipe = io.popen(YtLink) + --os.execute(YtLink) + + repeat + local c = pipe:read() + if c then - --downloadProgress.value = c/100 -- x out of 100 - -- in this case x is the progress - -- data we grabbed - iup.Flush() -- speeds everything up considerably - -- when changing an attribute of an element, the change may not - -- take place immediately - -- in that case throw in a flush after the change + iup.Flush() - iup.LoopStep() -- required to work, also allows user to click button - iup.Flush() -- added this second flush... helps a shit ton - if cancelflag then -- if cancelflag is true, then break - -- which happens if you click the button + iup.LoopStep() + iup.Flush() + if cancelflag then iup.Message("Terminated", "You have canceled the conversion") iup.Flush() @@ -69,21 +54,16 @@ local function DL_progress(YtLink) -- monitor download progress -until not c-- creating a loop until c is not true -pipe:close() -- closing the ipopen--]] +until not c +pipe:close() iup.Close() +return end convert_mp3 = {} convert_mp3.go = function(tubeLink) DL_progress(tubeLink) + return end ---if you can have your script call this one and insert the link to YtLink... win - ---local YtLink = ('http://www.youtube.com/watch?v=jrmlums5bV8') - - ---DL_progress( YtLink) -