From 5f470e54ee28a98f43ddfb8919c609bd9ff267c9 Mon Sep 17 00:00:00 2001 From: Logen Kain Date: Mon, 29 Jul 2013 22:48:36 -0500 Subject: [PATCH 1/4] updated TODO --- TODO.txt | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/TODO.txt b/TODO.txt index 26595f8..48b5fee 100644 --- a/TODO.txt +++ b/TODO.txt @@ -2,15 +2,16 @@ TODO: key: + = to add, - = to remove, x = completed, # = comment -xAppend extensions to file name in save dialog unless exists +Add option for multiple audio formats +Dynamic libraries +Create custom url entry dialog -xUrl validation -+Percentage in progress bar -+Replace spaces in file name with dashes/underscores -+Make cancel button exit in url dialog +Create dialog asking to play finished file or not -+Display current action in progressbar instead of youtube link itself -+Fix progress bar cancel button ++Fix FFMPEG MARQUEE bar +xMake cancel button exit in url dialog +xFix progress bar cancel button +xDisplay current action in progressbar instead of youtube link itself +xUrl validation +xplace spaces in file name with dashes/underscores +xAppend extensions to file name in save dialog unless exists ++Percentage in progress bar --- not possible with iUP #possibly more later From c145e73a309f17896b0f0f169fd94aefd3abdcf8 Mon Sep 17 00:00:00 2001 From: Logen Kain Date: Mon, 29 Jul 2013 22:49:23 -0500 Subject: [PATCH 2/4] Fixed various cancle flags to act properly. --- ffmpeg_progress.lua | 12 +++++++----- main.lua | 20 ++++++++------------ mandy.lua | 19 +++++++------------ progress.lua | 11 ++++++++--- 4 files changed, 30 insertions(+), 32 deletions(-) diff --git a/ffmpeg_progress.lua b/ffmpeg_progress.lua index f57ee55..86bd21e 100644 --- a/ffmpeg_progress.lua +++ b/ffmpeg_progress.lua @@ -42,19 +42,21 @@ local function DL_progress(YtLink) if cancelflag then iup.Message("Terminated", "You have canceled the conversion") iup.Flush() - break + pipe:close() + iup.Flush() + return false end end until not c pipe:close() iup.Close() - return + return true end convert_mp3 = {} convert_mp3.go = function(tubeLink) - DL_progress(tubeLink) - return - end +local flag = DL_progress(tubeLink) +if not flag then return false else return true end +end diff --git a/main.lua b/main.lua index 8aa72d6..12e3eab 100755 --- a/main.lua +++ b/main.lua @@ -3,19 +3,15 @@ require("mandy") function main() local url=global.url() - if not url then - - return false - end + if not url then return false end -- codec=sel_Codec() - local saveDir=global.dir() - if saveDir == "23" then - return 0 - end - local tmpPath = global.path(url) - local convert = global.ffmpeg(tmpPath, saveDir) - - + local saveDir=global.dir() + if not saveDir then return false end + + local tmpPath = global.path(url) + if not tmpPath then return false end + + local convert = global.ffmpeg(tmpPath, saveDir) end --initialize function "main" diff --git a/mandy.lua b/mandy.lua index c67cf6d..cb2e4da 100644 --- a/mandy.lua +++ b/mandy.lua @@ -38,7 +38,7 @@ function set_dir() local status = getPath.status - if status == "1" then + if status == "1" or status == "0" then if string.match(getPath.value, "%.mp3") then local savedPath = getPath.value return savedPath @@ -49,16 +49,8 @@ function set_dir() end - 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 + return false end end @@ -68,14 +60,17 @@ function ytDl(x) local tmpPath = x.." --output=/tmp/youtube-dl-"..tmpName.."-"..tmpNameTwo..".flv" local tmpPath2 = "/tmp/youtube-dl-"..tmpName.."-"..tmpNameTwo..".flv" - popin.ytdl(tmpPath) + local ytdl_action = popin.ytdl(tmpPath) + if not ytdl_action then return false end + return tmpPath2 end function ffmpeg(tmpPath, dirD) local subSpaces = string.gsub(dirD, " ", "\\") local mp3 = "ffmpeg -i "..tmpPath.." -acodec libmp3lame -ac 2 -ab 192k -vn -y "..subSpaces - convert_mp3.go(mp3) + local flag = convert_mp3.go(mp3) + if not flag then return false end io.popen("notify-send 'The file was saved to' "..subSpaces) io.popen("xdg-open "..subSpaces) end diff --git a/progress.lua b/progress.lua index b4c0b04..288c8bb 100644 --- a/progress.lua +++ b/progress.lua @@ -34,7 +34,7 @@ end local function DL_progress(YtLink) downloadStart(YtLink) downloadProgress.value = 0 - local pipe = io.popen("youtube-dl " ..YtLink) + local pipe = io.popen("youtube-dl " ..YtLink ) repeat local c = pipe:read(20) -- read the first 20 characters of each line if c then @@ -49,7 +49,10 @@ local function DL_progress(YtLink) if cancelflag then iup.Message("Terminated", "You have canceled the download") iup.Flush() - break + pipe:close() + iup.Flush() + return false + end end @@ -60,10 +63,12 @@ local function DL_progress(YtLink) until not c pipe:close() + return true end popin = {} popin.ytdl = function(tubeLink) - DL_progress(tubeLink) +local flag = DL_progress(tubeLink) + if not flag then return false else return true end end From a8d95449a18c67b86664c3b333975fc99f04b4c3 Mon Sep 17 00:00:00 2001 From: Logen Kain Date: Mon, 29 Jul 2013 22:55:12 -0500 Subject: [PATCH 3/4] fixed flag --- mandy.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mandy.lua b/mandy.lua index cb2e4da..6f4f82a 100644 --- a/mandy.lua +++ b/mandy.lua @@ -60,8 +60,8 @@ function ytDl(x) local tmpPath = x.." --output=/tmp/youtube-dl-"..tmpName.."-"..tmpNameTwo..".flv" local tmpPath2 = "/tmp/youtube-dl-"..tmpName.."-"..tmpNameTwo..".flv" - local ytdl_action = popin.ytdl(tmpPath) - if not ytdl_action then return false end + local flag = popin.ytdl(tmpPath) + if not flag then return false end return tmpPath2 end From de7fe89d10a92df24a086e6d3c58284efec4896a Mon Sep 17 00:00:00 2001 From: Logen Kain Date: Tue, 30 Jul 2013 11:07:49 -0500 Subject: [PATCH 4/4] fixed your problem --- mandy.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mandy.lua b/mandy.lua index 6f4f82a..a720cf5 100644 --- a/mandy.lua +++ b/mandy.lua @@ -67,7 +67,7 @@ function ytDl(x) end function ffmpeg(tmpPath, dirD) - local subSpaces = string.gsub(dirD, " ", "\\") + local subSpaces = string.gsub(dirD, " ", "\\ ") local mp3 = "ffmpeg -i "..tmpPath.." -acodec libmp3lame -ac 2 -ab 192k -vn -y "..subSpaces local flag = convert_mp3.go(mp3) if not flag then return false end