commit
26250e74fc
225
README.md
225
README.md
@ -1 +1,224 @@
|
||||
# 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
|
||||
- libfreetype6-dev (ubuntu)
|
||||
- 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 vlc git
|
||||
|
||||
|
||||
|
||||
###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 git 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 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:
|
||||
|
||||
# ./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/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
||||
|
4
main.lua
4
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
|
||||
|
29
mandy.lua
29
mandy.lua
@ -9,22 +9,30 @@ require('progress')
|
||||
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
|
||||
|
||||
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
|
||||
|
@ -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 = {}
|
||||
|
Loading…
x
Reference in New Issue
Block a user