From 8c49c84ba8b34d21a1030a01463885ec21d7f1fc Mon Sep 17 00:00:00 2001 From: silvernode Date: Thu, 25 Jul 2013 12:13:36 -0500 Subject: [PATCH 01/11] added version number to url entry title --- mandy.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mandy.lua b/mandy.lua index e858642..7a0f825 100644 --- a/mandy.lua +++ b/mandy.lua @@ -12,7 +12,7 @@ require('ffmpeg_progress') --Main url entry box function url_entry() -res, url = iup.GetParam("Mandy - Enter URL", nil, +res, url = iup.GetParam("Mandy 0.2 - Enter URL", nil, "Enter Youtube URL: %s\n", "") if string.match(url, "youtube.com/watch") then return url From 829ae01b4bd7bdb2a59b699d0e00a4535352a2e0 Mon Sep 17 00:00:00 2001 From: silvernode Date: Fri, 26 Jul 2013 00:57:37 -0500 Subject: [PATCH 02/11] Completed documenting README.md --- README.md | 221 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 220 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index cbc5ced..8b7d840 100644 --- a/README.md +++ b/README.md @@ -1 +1,220 @@ -# This is my README +#Mandy + +##About + +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 +current back-end will be replaced. + +Current platforms: Linux(x86/x64) + +##Screenshots + + +![url entry][3] + +![progressbar][4] + + +##Installation + +In order to run Mandy you will need to download and install it's +dependancies. + + +- lua 5.2 +- youtube-dl +- ffmpeg +- vlc (temporary) +- git +- [IUP][5] +- [CD][6] +- [IM][7] + + +Since the IUP libraries are not specific to one distribution, we will +cover it's installation separately. + + +###Arch Linux + +For Arch Linux we start with getting the dependencies already in the +main repository: + + + + pacman -S lua youtube-dl ffmpeg + + + +###Ubuntu + +Ubuntu users will need to get an extra package in order to do the +conversion to mp3: + + + + sudo apt-get install lua5.2 youtube-dl ffmpeg vlc libavcodec-extra-53 + + +###IUP + +IUP is a little more involved than the previous steps. For IUP we need to download each related library separately and edit a script before we run it and install the libraries. Since the documentation is difficult to find for this step, we will cover it here. + +We will be getting three tar.gz files starting with the main one, IUP. We will also need the library packages "CD" and "IM" which IUP uses for extra GUI features. The steps for all three are the same so I will only cover them once. + +NOTE: These instructions are for Linux Only! + +Download the compressed tar.gz file: + +32-bit + + + # wget http://iweb.dl.sourceforge.net/project/iup/3.8/Linux%20Libraries/iup-3.8_Linux32_lib.tar.gz + +64-bit + + # wget http://hivelocity.dl.sourceforge.net/project/iup/3.8/Linux%20Libraries/iup-3.8_Linux32_64_lib.tar.gz + +Since this tar.gz package does not include a directory we will need to create one: + + # mkdir iup + +Next we will extract the tar.gz file into the directory we just created: + + # tar xvf iup-X.X_LinuXX_XX_lib.tar.gz -C iup + +Now change to that directory: + + # cd iup/ + +Before we can run the install scripts wil need to do a few things first. + +First we need to edit the lua module file: + + # nano config_lua_module + +and change the top two lines to correspond to your version of lua which in our case is 5.2 at the time of this writing: + +Change this: + + #Current Lua Version + LUA_VER=5.1 + LUA_PFX=51 + +Should look like this: + + #Current Lua Version + LUA_VER=5.2 + LUA_PFX=52 + +After you have saved the lua module file, the next thing to do is to make the remaining install scripts executables: + + # chmod +x install install_dev + +Now we are ready to run all three scripts. These scripts will install the library files needed for IUP to be used with Lua. Since these libraries will copied to the /lib directory, you will need to run all three install scrips as root: + + # ./install + # ./install_dev + # ./config_lua_module + +The IUP libraries should now be properly installed on your system. This will give Mandy basic graphical capabilities but will not provide us with all the features Mandy needs to run. + +We still need to get the other two dependencies: CD and IM. + +####CD + +Download the compressed tar.gz file: + +32-bit + + # wget http://iweb.dl.sourceforge.net/project/canvasdraw/5.6.1/Linux%20Libraries/cd-5.6.1_Linux32_lib.tar.gz + +64-bit + + # wget http://iweb.dl.sourceforge.net/project/canvasdraw/5.6.1/Linux%20Libraries/cd-5.6.1_Linux32_64_lib.tar.gz + +Create a directory to extract to: + + # mkdir cd + +Extract the file: + + # tar xvf cd-X.X.X_LinuxXX_lib.tar.gz -C cd + +Change directories: + + # cd cd + +Now all you have to do is re-follow the steps listed above in the "IUP" section and you're ready to move on to installing IM. + +####IM + +Download the tar.gz file: + +32-bit + + # wget http://superb-dca2.dl.sourceforge.net/project/imtoolkit/3.8.1/Linux%20Libraries/im-3.8.1_Linux32_lib.tar.gz + +64-bit + + # wget http://superb-dca2.dl.sourceforge.net/project/imtoolkit/3.8.1/Linux%20Libraries/im-3.8.1_Linux32_64_lib.tar.gz + +Create a new directory: + + # mkdir im + +Extract the file: + + # tar xvf im-3.8.1_Linux32_lib.tar.gz -C im + +Now just follow the steps in the IUP section above as before and run the scripts and you're finally done. + + +##Getting Mandy + + +Now we can get the actual source files of Mandy. I recommend setting up a dedicated directory before doing this. + + # mkdir projects && cd projects + +Now we can clone the repository into the projects folder: + + # git clone https://silvernode1@bitbucket.org/silvernode1/mandy.git + # cd mandy + +Now you are ready to run Mandy and see what it's all about. For Arch Linux users all you need to do is run lua: + + # lua main.lua + +Ubuntu users need to run lua5.2 although optionally you can set up an alias and append it to your ~/.bashrc file: + + # alias lua5.2="lua" + # lua main.lua + + +##Notes + +In the future we hope to figure out how to include IUP, CD and IM as dynamic libraries in order to include them in a package with Mandy for various distributions i.e. Ubuntu derivatives. On the plus side (at least for Arch Linux users) in the meantime we plan to put together a few PKGBUILD for the Arch User Repository (AUR) which is a lot easier and will automate the installation process all the same. + +We hope you find Mandy useful and convenient. If you would like to contribute please send us a message through bitbucket. This is our first project so we could use some pointers on Lua in general as well as ideas for the project. + +Thanks! + + + + +[1]: http://lua.org +[2]: http://www.tecgraf.puc-rio.br/iup/ +[3]: http://i.imgur.com/ol0ZRUp.png +[4]: http://i.imgur.com/wpoVeXZ.png +[5]: http://sourceforge.net/projects/iup/files/ +[6]: http://sourceforge.net/projects/canvasdraw/files/ +[7]: http://sourceforge.net/projects/imtoolkit/files/ + + From e08d7c5caa84e59daba91c2f8561247a6871de3c Mon Sep 17 00:00:00 2001 From: silvernode Date: Fri, 26 Jul 2013 01:06:22 -0500 Subject: [PATCH 03/11] included vlc and git in distro install lines --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8b7d840..5dc2ad5 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ main repository: - pacman -S lua youtube-dl ffmpeg + pacman -S lua youtube-dl ffmpeg vlc git @@ -59,7 +59,7 @@ conversion to mp3: - sudo apt-get install lua5.2 youtube-dl ffmpeg vlc libavcodec-extra-53 + sudo apt-get install lua5.2 youtube-dl ffmpeg vlc git libavcodec-extra-53 ###IUP From ab846a81efd81b85a113340ae66b90bda25206c9 Mon Sep 17 00:00:00 2001 From: silvernode Date: Fri, 26 Jul 2013 01:23:13 -0500 Subject: [PATCH 04/11] fixed line 18 to include config_lua_module --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5dc2ad5..693f80b 100644 --- a/README.md +++ b/README.md @@ -115,7 +115,7 @@ Should look like this: After you have saved the lua module file, the next thing to do is to make the remaining install scripts executables: - # chmod +x install install_dev + # chmod +x install install_dev config_lua_module Now we are ready to run all three scripts. These scripts will install the library files needed for IUP to be used with Lua. Since these libraries will copied to the /lib directory, you will need to run all three install scrips as root: From f12f3dc21d8e15d54d58f03b05275effce65fbb7 Mon Sep 17 00:00:00 2001 From: Logen Kain Date: Fri, 26 Jul 2013 13:46:26 -0500 Subject: [PATCH 05/11] making a change under the SSH protocole --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 693f80b..ce11cee 100644 --- a/README.md +++ b/README.md @@ -216,5 +216,8 @@ Thanks! [5]: http://sourceforge.net/projects/iup/files/ [6]: http://sourceforge.net/projects/canvasdraw/files/ [7]: http://sourceforge.net/projects/imtoolkit/files/ - + + + +#testing ssh From 80ed77cf11bdc4ecc24c656c7dc6f55afa1fe28f Mon Sep 17 00:00:00 2001 From: Logen Kain Date: Fri, 26 Jul 2013 14:37:47 -0500 Subject: [PATCH 06/11] updated dependancies --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ce11cee..4bc5fe8 100644 --- a/README.md +++ b/README.md @@ -219,5 +219,5 @@ Thanks! -#testing ssh + From 481199a1f3686764a1c8619a0c0a052627365374 Mon Sep 17 00:00:00 2001 From: Logen Kain Date: Fri, 26 Jul 2013 16:48:06 -0500 Subject: [PATCH 07/11] Depend added --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 4bc5fe8..deda5c1 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ dependancies. - lua 5.2 +- libfreetype6-dev (ubuntu) - youtube-dl - ffmpeg - vlc (temporary) From 0b4ae7693444be4e522458f477ca05c4c8d76b06 Mon Sep 17 00:00:00 2001 From: Logen Kain Date: Fri, 26 Jul 2013 22:46:59 -0500 Subject: [PATCH 08/11] 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) - From c4fd0a3f91365ddeab26f6d9fb8a22ea524bcbb6 Mon Sep 17 00:00:00 2001 From: Logen Kain Date: Fri, 26 Jul 2013 22:49:41 -0500 Subject: [PATCH 09/11] fixed initial cancel, ffmpeg marquee function --- mandy.lua | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/mandy.lua b/mandy.lua index 7a0f825..1049a9b 100644 --- a/mandy.lua +++ b/mandy.lua @@ -9,22 +9,30 @@ require('progress') require('ffmpeg_progress') + --Main url entry box function url_entry() -res, url = iup.GetParam("Mandy 0.2 - Enter URL", nil, +res, url = iup.GetParam("Mandy 0.2 - Enter URL", nil, "Enter Youtube URL: %s\n", "") - if string.match(url, "youtube.com/watch") then - return url + + if res == true then + if string.match(url, "youtube.com/watch") then + return url + else + iup.Message("Error", "The URL is not a youtube link") + iup.Flush() + iup.Close() + end + + else - iup.Message("Error", "The URL is not a youtube link") - iup.Flush() - iup.Close() - + return false end - + + end @@ -97,8 +105,9 @@ end function ffmpeg(tmpPath, dirD) local mp3 = "ffmpeg -i "..tmpPath.." -acodec libmp3lame -ac 2 -ab 192k -vn -y "..dirD - os.execute(mp3) - -- convert_mp3.go(mp3) + --os.execute(mp3) + convert_mp3.go(mp3) + io.popen("vlc "..dirD) end From d8cc7e06a065266df521974613c518274184b219 Mon Sep 17 00:00:00 2001 From: Logen Kain Date: Fri, 26 Jul 2013 22:52:14 -0500 Subject: [PATCH 10/11] added proper cancle functionality to url --- main.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/main.lua b/main.lua index 4b3e63d..8aa72d6 100755 --- a/main.lua +++ b/main.lua @@ -3,6 +3,10 @@ require("mandy") function main() local url=global.url() + if not url then + + return false + end -- codec=sel_Codec() local saveDir=global.dir() if saveDir == "23" then From 572cf5e2ebe56a589747c1ca31ee1e0025ca1346 Mon Sep 17 00:00:00 2001 From: Logen Kain Date: Fri, 26 Jul 2013 22:55:51 -0500 Subject: [PATCH 11/11] clean up --- progress.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/progress.lua b/progress.lua index 321f358..2a55bd5 100644 --- a/progress.lua +++ b/progress.lua @@ -91,7 +91,7 @@ round up and only update if number has changed until not c-- creating a loop until c is not true pipe:close() -- closing the ipopen -iup.Close() +--iup.Close() end popin = {}