From e59b9cf3f412fef11d1ff27d718bc74fe4a43466 Mon Sep 17 00:00:00 2001 From: silvernode Date: Mon, 5 Aug 2013 01:00:20 -0500 Subject: [PATCH 1/8] updated branch --- Config.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 Config.txt diff --git a/Config.txt b/Config.txt new file mode 100644 index 0000000..4321bdc --- /dev/null +++ b/Config.txt @@ -0,0 +1 @@ +local format = 1 \ No newline at end of file From 007ff260f7e690b648bea2bbf60f85b25b44500e Mon Sep 17 00:00:00 2001 From: silvernode Date: Mon, 5 Aug 2013 04:10:10 -0500 Subject: [PATCH 2/8] Added bitrate options --- mandy.cfg | 4 +-- mandy.lua | 74 ++++++++++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 65 insertions(+), 13 deletions(-) diff --git a/mandy.cfg b/mandy.cfg index 5d6ac5c..42ee7f1 100644 --- a/mandy.cfg +++ b/mandy.cfg @@ -1,6 +1,6 @@ cfg_table = { -format = "ogg" -- 0 for mp3, 1 for ogg, 2 for flac - +format = "ogg", --0 for mp3, 1 for ogg, 2 for flac +bitrate = "320k" } diff --git a/mandy.lua b/mandy.lua index 3f5b719..6e8fe10 100644 --- a/mandy.lua +++ b/mandy.lua @@ -7,24 +7,32 @@ require('ffmpeg_progress') --Main url entry box function url_entry() - + local changeLog = io.popen("changelog.txt", "r") local format = sel_format() - + local bitRate = sel_bitrate() local url = "" + local multiLine = "changeLog" + - res, url, format = iup.GetParam("Mandy 0.5.0 - Enter URL", nil, + res, url, format, bitRate, multiLine = iup.GetParam("Mandy 0.5.0 - Enter URL", nil, "Enter Youtube URL: %s\n".. - "Select an audio format: %l|mp3|ogg|flac|\n", url, format) - + "Audio Options %t\n".. + "Select an audio format: %l|mp3|ogg|flac|\n".. + "Select the bitrate: %l|320 kb/s|192 kb/s|160 kb/s|128 kb/s|96 kb/s|32 kb/s|\n".. + "Changelog %m\n", url, format, bitRate, multiLine) gFormat = sel_Codec(format) + gBitrate = bit_logic(bitRate) if res == true then if string.match(url, "youtube.com/watch") then - local format_config = io.open("Config.txt", "w") - format_config:write("local format = "..format) - format_config:close() + --local format_config = io.open("Config.txt", "w") + --format_config:write("local format = "..format) + --format_config:close() + --local bitrate_config = io.open("Config.txt", "w") + --bitrate_config:write("local bitrate = "..bitRate) + --bitrate_config:close() return url else iup.Message("Error", "The URL is not a youtube link") @@ -48,6 +56,17 @@ function sel_format() end end +function sel_bitrate() + local bitrate = cfg_table["bitrate"] + if bitrate == "320k" then return 0 + elseif bitrate == "192k" then return 1 + elseif bitrate == "160k" then return 2 + elseif bitrate == "128k" then return 3 + elseif bitrate == "96k" then return 4 + elseif bitrate == "32k" then return 5 + else return 0 + end +end --make format dropdown menu items work @@ -68,6 +87,34 @@ function sel_Codec(x) end +function bit_logic(x) + if x == 0 then + local b320k = "320k" + print ("Selected "..b320k) + return b320k + elseif x == 1 then + local b192k = "b192k" + print ("Selected "..b192k) + return b192k + elseif x == 2 then + local b160k = "160k" + print ("Selected "..b160k) + return b160k + elseif x == 3 then + local b128k = "128k" + print ("Selected "..b128k) + return b128k + elseif x == 4 then + local b96k = "96k" + print ("Selected "..b96k) + return b96k + elseif x == 5 then + local b32k = "32k" + print ("Selected "..b32k) + return b32k + end +end + --Ask user to set directory function set_dir() @@ -102,7 +149,7 @@ function ytDl(x) local tmpNameTwo = math.random(0,999999999999) local tmpPath = x.." --output=/tmp/youtube-dl-"..tmpName.."-"..tmpNameTwo..".flv" local tmpPath2 = "/tmp/youtube-dl-"..tmpName.."-"..tmpNameTwo..".flv" - + print(x) local flag = popin.ytdl(tmpPath, tmpPath2) if not flag then return false end @@ -135,9 +182,14 @@ function ffmpeg(tmpPath, dirD) if gFormat == ".ogg" then gFormat = "libvorbis" end if gFormat == ".flac" then gFormat = "flac" end - + if gBitrate == "320k" then gBitrate = "320k" end + if gBitrate == "192k" then gBitrate = "192k" end + if gBitrate == "160k" then gBitrate = "160k" end + if gBitrate == "128k" then gBitrate = "128k" end + if gBitrate == "96k" then gBitrate = "96k" end + if gBitrate == "32k" then gBitrate = "32k" end local subSpaces = string.gsub(dirD, " ", "\\ ") - local codec = "ffmpeg -i "..tmpPath.." -acodec "..gFormat.." -ac 2 -ab 192k -vn -y "..subSpaces + local codec = "ffmpeg -i "..tmpPath.." -acodec "..gFormat.." -ac 2 -ab "..gBitrate.." -vn -y "..subSpaces print(format) local flag = convert_mp3.go(codec, tmpPath) From bf81bd3369ac882c56a4cfebceb11c6466ce7811 Mon Sep 17 00:00:00 2001 From: silvernode Date: Mon, 5 Aug 2013 07:22:05 -0500 Subject: [PATCH 3/8] Main dialog: bitrate, play file dropdown, changelog viewer --- Config.txt | 1 - README.md | 5 ++-- TODO.txt | 21 ++++++++-------- changelog.txt | 9 +++++++ mandy.cfg | 9 +++++-- mandy.lua | 69 ++++++++++++++++++++++++++------------------------- 6 files changed, 64 insertions(+), 50 deletions(-) delete mode 100644 Config.txt diff --git a/Config.txt b/Config.txt deleted file mode 100644 index 4321bdc..0000000 --- a/Config.txt +++ /dev/null @@ -1 +0,0 @@ -local format = 1 \ No newline at end of file diff --git a/README.md b/README.md index 1e90935..ddf0c9f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ -#Mandy - current version: 0.5.0 +#Mandy +###current version: 0.6.0 ##About @@ -215,7 +216,7 @@ Thanks! [1]: http://lua.org [2]: http://www.tecgraf.puc-rio.br/iup/ -[3]: http://i.imgur.com/P2rMTiM.png +[3]: http://i.imgur.com/btD0dJc.png [4]: http://i.imgur.com/1AcLZk6.png [5]: http://sourceforge.net/projects/iup/files/ [6]: http://sourceforge.net/projects/canvasdraw/files/ diff --git a/TODO.txt b/TODO.txt index 35b403a..79d76a1 100644 --- a/TODO.txt +++ b/TODO.txt @@ -2,16 +2,15 @@ TODO: key: + = to add, - = to remove, x = completed, # = comment -xAdd option for multiple audio formats -+Dynamic libraries -+Create custom url entry dialog -+Create dialog asking to play finished file or not -+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 +x Add option for multiple audio formats ++ Dynamic libraries/package IUP +x Option play file once finished ++ Fix FFMPEG MARQUEE bar +x Make cancel button exit in url dialog +x Fix progress bar cancel button +x Display current action in progressbar instead of youtube link itself +x Url validation +x place spaces in file name with dashes/underscores +x Append extensions to file name in save dialog unless exists +Percentage in progress bar --- not possible with iUP #possibly more later diff --git a/changelog.txt b/changelog.txt index 63406af..7c07b4f 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,7 +1,16 @@ ***CHANGELOG*** +Version 0.6.0 (8-5-13) + +* Set the default settings in 'mandy.cfg' +* Can now select audio bitrate +* Autoremove old video files from /tmp +* Added option to play completed file +- Still unknown bug with 'converting' bar + Version 0.5.0 (7-31-13) + *added audio format selection for mp3. ogg, and flac -autoplay has been removed, users now play files manually diff --git a/mandy.cfg b/mandy.cfg index 42ee7f1..99ade61 100644 --- a/mandy.cfg +++ b/mandy.cfg @@ -1,6 +1,11 @@ cfg_table = { -format = "ogg", --0 for mp3, 1 for ogg, 2 for flac -bitrate = "320k" +--Change default audio format and bitrate within the quotes +--Values for format: mp3, ogg, flac +--Values for bitrate: 320k, 192k, 160k, 128k, 96k + +format = "ogg", +bitrate = "320k", +playFile = "no", } diff --git a/mandy.lua b/mandy.lua index 6e8fe10..c07c0d6 100644 --- a/mandy.lua +++ b/mandy.lua @@ -7,32 +7,31 @@ require('ffmpeg_progress') --Main url entry box function url_entry() - local changeLog = io.popen("changelog.txt", "r") local format = sel_format() local bitRate = sel_bitrate() local url = "" - local multiLine = "changeLog" + local playNow = sel_play() + local changeLog = "* Set the default settings in 'mandy.cfg'\n".. + "* Can now select audio bitrate\n".. + "* Autoremove old video files from /tmp\n".. + "* Added option to play completed file\n".. + "- Still unknown bug with 'converting' bar\n" - res, url, format, bitRate, multiLine = iup.GetParam("Mandy 0.5.0 - Enter URL", nil, + res, url, format, bitRate, playNow, changeLog = iup.GetParam("Mandy 0.6.0 (alpha)", nil, "Enter Youtube URL: %s\n".. "Audio Options %t\n".. "Select an audio format: %l|mp3|ogg|flac|\n".. - "Select the bitrate: %l|320 kb/s|192 kb/s|160 kb/s|128 kb/s|96 kb/s|32 kb/s|\n".. - "Changelog %m\n", url, format, bitRate, multiLine) - + "Select the bitrate: %l|320 kb/s|192 kb/s|160 kb/s|128 kb/s|96 kb/s|\n".. + "Play file when finished?: %l|no|yes|\n".. + "Changelog: %m\n", + url, format, bitRate, playNow, changeLog) + gPlay = ask_play(playNow) gFormat = sel_Codec(format) gBitrate = bit_logic(bitRate) if res == true then if string.match(url, "youtube.com/watch") then - - --local format_config = io.open("Config.txt", "w") - --format_config:write("local format = "..format) - --format_config:close() - --local bitrate_config = io.open("Config.txt", "w") - --bitrate_config:write("local bitrate = "..bitRate) - --bitrate_config:close() return url else iup.Message("Error", "The URL is not a youtube link") @@ -68,6 +67,15 @@ function sel_bitrate() end end +function sel_play() + local playFile = cfg_table["playFile"] + if playFile == "no" then return 0 + elseif playFile == "yes" then return 1 + else return 0 + end +end + + --make format dropdown menu items work function sel_Codec(x) @@ -93,7 +101,7 @@ function bit_logic(x) print ("Selected "..b320k) return b320k elseif x == 1 then - local b192k = "b192k" + local b192k = "192k" print ("Selected "..b192k) return b192k elseif x == 2 then @@ -108,10 +116,6 @@ function bit_logic(x) local b96k = "96k" print ("Selected "..b96k) return b96k - elseif x == 5 then - local b32k = "32k" - print ("Selected "..b32k) - return b32k end end @@ -158,19 +162,11 @@ end --optional function to implement autoplay -function ask_play(x) - local play = "" - res, play = iup.GetParam("Play now?", nil, - "Do you want to play the file now? %t\n") - - if res == true then - io.popen("notify-send 'The file was saved to' "..x) - io.close() - io.popen("xdg-open "..x) - io.close() - return true - else +function ask_play(x, y) + if x == 0 then return false + elseif x == 1 then + return true end end @@ -187,7 +183,6 @@ function ffmpeg(tmpPath, dirD) if gBitrate == "160k" then gBitrate = "160k" end if gBitrate == "128k" then gBitrate = "128k" end if gBitrate == "96k" then gBitrate = "96k" end - if gBitrate == "32k" then gBitrate = "32k" end local subSpaces = string.gsub(dirD, " ", "\\ ") local codec = "ffmpeg -i "..tmpPath.." -acodec "..gFormat.." -ac 2 -ab "..gBitrate.." -vn -y "..subSpaces @@ -195,9 +190,15 @@ function ffmpeg(tmpPath, dirD) local flag = convert_mp3.go(codec, tmpPath) if not flag then return false end - --end - --io.popen("notify-send 'The file was saved to' "..subSpaces) - ask_play(subSpaces) + io.popen("notify-send 'The file was saved to' "..subSpaces) + io.close() + if gPlay == true then + io.popen("xdg-open "..subSpaces) + io.close() + + elseif gPlay == false then + print ("You chose not to open the file") + end end --put everything into a table to use local functions globally From 7a42ec87ad32578299c87942cacdcfcb1b2c46d4 Mon Sep 17 00:00:00 2001 From: silvernode Date: Mon, 5 Aug 2013 18:07:14 -0500 Subject: [PATCH 4/8] cleaned up pointless gBitrate crap and the extra y param --- mandy.lua | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/mandy.lua b/mandy.lua index c07c0d6..f606b8d 100644 --- a/mandy.lua +++ b/mandy.lua @@ -162,7 +162,7 @@ end --optional function to implement autoplay -function ask_play(x, y) +function ask_play(x) if x == 0 then return false elseif x == 1 then @@ -178,11 +178,6 @@ function ffmpeg(tmpPath, dirD) if gFormat == ".ogg" then gFormat = "libvorbis" end if gFormat == ".flac" then gFormat = "flac" end - if gBitrate == "320k" then gBitrate = "320k" end - if gBitrate == "192k" then gBitrate = "192k" end - if gBitrate == "160k" then gBitrate = "160k" end - if gBitrate == "128k" then gBitrate = "128k" end - if gBitrate == "96k" then gBitrate = "96k" end local subSpaces = string.gsub(dirD, " ", "\\ ") local codec = "ffmpeg -i "..tmpPath.." -acodec "..gFormat.." -ac 2 -ab "..gBitrate.." -vn -y "..subSpaces From c409825057e4bb457c8f4380cba8d5ea9f9c9d10 Mon Sep 17 00:00:00 2001 From: silvernode Date: Mon, 5 Aug 2013 18:41:16 -0500 Subject: [PATCH 5/8] changed #!/usr/bin/env lua and kb/s to kbps for bitrate --- main.lua | 2 +- mandy.lua | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/main.lua b/main.lua index 4a6bcbd..83ab655 100755 --- a/main.lua +++ b/main.lua @@ -1,4 +1,4 @@ -#!/usr/bin/lua5.2 +#!/usr/bin/env lua require("mandy") dofile("mandy.cfg") function main() diff --git a/mandy.lua b/mandy.lua index f606b8d..abf87c7 100644 --- a/mandy.lua +++ b/mandy.lua @@ -1,4 +1,4 @@ -#!/usr/bin/lua5.2 +#!/usr/bin/env lua require("iuplua") require("iupluacontrols") @@ -22,7 +22,7 @@ function url_entry() "Enter Youtube URL: %s\n".. "Audio Options %t\n".. "Select an audio format: %l|mp3|ogg|flac|\n".. - "Select the bitrate: %l|320 kb/s|192 kb/s|160 kb/s|128 kb/s|96 kb/s|\n".. + "Select the bitrate: %l|320 kbps|192 kbps|160 kbps|128 kbps|96 kbps|\n".. "Play file when finished?: %l|no|yes|\n".. "Changelog: %m\n", url, format, bitRate, playNow, changeLog) From 09706f706da1065ca4e097c5f4abda95e0008cd2 Mon Sep 17 00:00:00 2001 From: silvernode Date: Tue, 6 Aug 2013 15:19:44 -0500 Subject: [PATCH 6/8] added a comment --- mandy.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mandy.lua b/mandy.lua index abf87c7..39ae264 100644 --- a/mandy.lua +++ b/mandy.lua @@ -181,8 +181,9 @@ function ffmpeg(tmpPath, dirD) local subSpaces = string.gsub(dirD, " ", "\\ ") local codec = "ffmpeg -i "..tmpPath.." -acodec "..gFormat.." -ac 2 -ab "..gBitrate.." -vn -y "..subSpaces - print(format) + print(format) --debug purposes local flag = convert_mp3.go(codec, tmpPath) + use_xterm(codec) if not flag then return false end io.popen("notify-send 'The file was saved to' "..subSpaces) From f56dad78d6ba649f9ef975c77defad6632d1bf4c Mon Sep 17 00:00:00 2001 From: silvernode Date: Tue, 6 Aug 2013 15:23:21 -0500 Subject: [PATCH 7/8] forgot to remove something that didn't work --- mandy.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/mandy.lua b/mandy.lua index 39ae264..5e4b2d3 100644 --- a/mandy.lua +++ b/mandy.lua @@ -183,7 +183,6 @@ function ffmpeg(tmpPath, dirD) print(format) --debug purposes local flag = convert_mp3.go(codec, tmpPath) - use_xterm(codec) if not flag then return false end io.popen("notify-send 'The file was saved to' "..subSpaces) From 913d126d1301fceaa1a8f2737daea92818fc3eb1 Mon Sep 17 00:00:00 2001 From: silvernode Date: Tue, 6 Aug 2013 22:34:32 -0500 Subject: [PATCH 8/8] Took out misleading info in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ddf0c9f..2e09bc2 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Mandy is a script written in [Lua][1] using the [IUP][2] GUI toolkit. The purpose of Mandy is to provide a simple interface for downloading youtube videos and converting them to different audio formats. -Currently only mp3 format is supported. + Mandy currently relies on youtube-dl and ffmpeg for video downloading and converting however, if native libraries surface in the future the