Merged testing into master
This commit is contained in:
commit
8435ea7155
@ -1,4 +1,5 @@
|
|||||||
#Mandy - current version: 0.5.0
|
#Mandy
|
||||||
|
###current version: 0.6.0
|
||||||
|
|
||||||
|
|
||||||
##About
|
##About
|
||||||
@ -215,7 +216,7 @@ Thanks!
|
|||||||
|
|
||||||
[1]: http://lua.org
|
[1]: http://lua.org
|
||||||
[2]: http://www.tecgraf.puc-rio.br/iup/
|
[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
|
[4]: http://i.imgur.com/1AcLZk6.png
|
||||||
[5]: http://sourceforge.net/projects/iup/files/
|
[5]: http://sourceforge.net/projects/iup/files/
|
||||||
[6]: http://sourceforge.net/projects/canvasdraw/files/
|
[6]: http://sourceforge.net/projects/canvasdraw/files/
|
||||||
|
21
TODO.txt
21
TODO.txt
@ -2,16 +2,15 @@ TODO:
|
|||||||
|
|
||||||
key: + = to add, - = to remove, x = completed, # = comment
|
key: + = to add, - = to remove, x = completed, # = comment
|
||||||
|
|
||||||
xAdd option for multiple audio formats
|
x Add option for multiple audio formats
|
||||||
+Dynamic libraries
|
+ Dynamic libraries/package IUP
|
||||||
+Create custom url entry dialog
|
x Option play file once finished
|
||||||
+Create dialog asking to play finished file or not
|
+ Fix FFMPEG MARQUEE bar
|
||||||
+Fix FFMPEG MARQUEE bar
|
x Make cancel button exit in url dialog
|
||||||
xMake cancel button exit in url dialog
|
x Fix progress bar cancel button
|
||||||
xFix progress bar cancel button
|
x Display current action in progressbar instead of youtube link itself
|
||||||
xDisplay current action in progressbar instead of youtube link itself
|
x Url validation
|
||||||
xUrl validation
|
x place spaces in file name with dashes/underscores
|
||||||
xplace spaces in file name with dashes/underscores
|
x Append extensions to file name in save dialog unless exists
|
||||||
xAppend extensions to file name in save dialog unless exists
|
|
||||||
+Percentage in progress bar --- not possible with iUP
|
+Percentage in progress bar --- not possible with iUP
|
||||||
#possibly more later
|
#possibly more later
|
||||||
|
@ -1,7 +1,16 @@
|
|||||||
***CHANGELOG***
|
***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)
|
Version 0.5.0 (7-31-13)
|
||||||
|
|
||||||
*added audio format selection for mp3. ogg, and flac
|
*added audio format selection for mp3. ogg, and flac
|
||||||
-autoplay has been removed, users now play files manually
|
-autoplay has been removed, users now play files manually
|
||||||
|
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
require ('iuplua')
|
require ('iuplua')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
local cancelflag
|
local cancelflag
|
||||||
local downloadProgress
|
local ffmpeg_downloadProgress
|
||||||
|
|
||||||
local function downloadStart(YtLink)
|
local function downloadStart(YtLink)
|
||||||
cancelButton = iup.button{
|
cancelButton = iup.button{
|
||||||
@ -12,12 +16,12 @@ local function downloadStart(YtLink)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
local downloadProgress = iup.progressbar{expand="HORIZONTAL", MARQUEE="YES"}
|
local ffmpeg_downloadProgress = iup.progressbar{expand="HORIZONTAL", MARQUEE="YES"}
|
||||||
local dlgProgress = iup.dialog{
|
local dlgProgress = iup.dialog{
|
||||||
title = "converting",
|
title = "converting",
|
||||||
dialogframe = "YES", border = "YES",
|
dialogframe = "YES", border = "YES",
|
||||||
iup.vbox {
|
iup.vbox {
|
||||||
downloadProgress,
|
ffmpeg_downloadProgress,
|
||||||
cancelButton,
|
cancelButton,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -29,33 +33,37 @@ local function downloadStart(YtLink)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local function DL_progress(YtLink)
|
local function DL_progress(YtLink, tmpPath)
|
||||||
downloadStart()
|
downloadStart()
|
||||||
local pipe = io.popen(YtLink)
|
local pipe = io.popen(YtLink)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
repeat
|
repeat
|
||||||
local c = pipe:read()
|
c = pipe:read(1)
|
||||||
if c then
|
|
||||||
iup.Flush()
|
iup.LoopStep()
|
||||||
iup.LoopStep()
|
-- iup.Message("Terminated","You have failed")
|
||||||
iup.Flush()
|
|
||||||
if cancelflag then
|
if cancelflag then
|
||||||
iup.Message("Terminated", "You have canceled the conversion")
|
iup.Message("Terminated", "You have canceled the conversion")
|
||||||
iup.Flush()
|
iup.Flush()
|
||||||
pipe:close()
|
pipe:close()
|
||||||
iup.Flush()
|
iup.Flush()
|
||||||
|
dlgProgress:destroy()
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
|
||||||
until not c
|
until not c
|
||||||
|
dlgProgress:destroy()
|
||||||
pipe:close()
|
pipe:close()
|
||||||
iup.Close()
|
os.remove(tmpPath)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
convert_mp3 = {}
|
convert_mp3 = {}
|
||||||
convert_mp3.go = function(tubeLink)
|
convert_mp3.go = function(tubeLink, tmpPath)
|
||||||
local flag = DL_progress(tubeLink)
|
local flag = DL_progress(tubeLink, tmpPath)
|
||||||
if not flag then return false else return true end
|
if not flag then return false else return true end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
4
main.lua
Normal file → Executable file
4
main.lua
Normal file → Executable file
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/lua5.2
|
#!/usr/bin/env lua
|
||||||
require("mandy")
|
require("mandy")
|
||||||
|
dofile("mandy.cfg")
|
||||||
function main()
|
function main()
|
||||||
local url=global.url()
|
local url=global.url()
|
||||||
if not url then return false end
|
if not url then return false end
|
||||||
|
11
mandy.cfg
Normal file
11
mandy.cfg
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
cfg_table = {
|
||||||
|
|
||||||
|
--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",
|
||||||
|
}
|
||||||
|
|
128
mandy.lua
128
mandy.lua
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/lua5.2
|
#!/usr/bin/env lua
|
||||||
|
|
||||||
require("iuplua")
|
require("iuplua")
|
||||||
require("iupluacontrols")
|
require("iupluacontrols")
|
||||||
@ -7,13 +7,29 @@ require('ffmpeg_progress')
|
|||||||
|
|
||||||
--Main url entry box
|
--Main url entry box
|
||||||
function url_entry()
|
function url_entry()
|
||||||
|
local format = sel_format()
|
||||||
|
local bitRate = sel_bitrate()
|
||||||
local url = ""
|
local url = ""
|
||||||
local format = 0
|
local playNow = sel_play()
|
||||||
res, url, format = iup.GetParam("Mandy 0.5.0 - Enter URL", nil,
|
local changeLog = "* Set the default settings in 'mandy.cfg'\n"..
|
||||||
"Enter Youtube URL: %s\n"..
|
"* Can now select audio bitrate\n"..
|
||||||
"Select an audio format: %l|mp3|ogg|flac|\n", url, format)
|
"* 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, 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 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)
|
||||||
|
|
||||||
|
gPlay = ask_play(playNow)
|
||||||
gFormat = sel_Codec(format)
|
gFormat = sel_Codec(format)
|
||||||
|
gBitrate = bit_logic(bitRate)
|
||||||
if res == true then
|
if res == true then
|
||||||
if string.match(url, "youtube.com/watch") then
|
if string.match(url, "youtube.com/watch") then
|
||||||
return url
|
return url
|
||||||
@ -28,6 +44,39 @@ function url_entry()
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- checks mandy.cfg for format
|
||||||
|
function sel_format()
|
||||||
|
local format = cfg_table["format"]
|
||||||
|
if format == "mp3" then return 0
|
||||||
|
elseif format == "ogg" then return 1
|
||||||
|
elseif format == "flac" then return 2
|
||||||
|
else return 0
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
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
|
--make format dropdown menu items work
|
||||||
function sel_Codec(x)
|
function sel_Codec(x)
|
||||||
if x == 0 then
|
if x == 0 then
|
||||||
@ -46,6 +95,30 @@ function sel_Codec(x)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function bit_logic(x)
|
||||||
|
if x == 0 then
|
||||||
|
local b320k = "320k"
|
||||||
|
print ("Selected "..b320k)
|
||||||
|
return b320k
|
||||||
|
elseif x == 1 then
|
||||||
|
local b192k = "192k"
|
||||||
|
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
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--Ask user to set directory
|
--Ask user to set directory
|
||||||
function set_dir()
|
function set_dir()
|
||||||
|
|
||||||
@ -58,6 +131,7 @@ function set_dir()
|
|||||||
|
|
||||||
local status = getPath.status
|
local status = getPath.status
|
||||||
|
|
||||||
|
-- The "%" is used to escape the "." comming from gFormat
|
||||||
if status == "1" or status == "0" then
|
if status == "1" or status == "0" then
|
||||||
if string.match(getPath.value, "%"..gFormat) then
|
if string.match(getPath.value, "%"..gFormat) then
|
||||||
local savedPath = getPath.value
|
local savedPath = getPath.value
|
||||||
@ -79,24 +153,20 @@ function ytDl(x)
|
|||||||
local tmpNameTwo = math.random(0,999999999999)
|
local tmpNameTwo = math.random(0,999999999999)
|
||||||
local tmpPath = x.." --output=/tmp/youtube-dl-"..tmpName.."-"..tmpNameTwo..".flv"
|
local tmpPath = x.." --output=/tmp/youtube-dl-"..tmpName.."-"..tmpNameTwo..".flv"
|
||||||
local tmpPath2 = "/tmp/youtube-dl-"..tmpName.."-"..tmpNameTwo..".flv"
|
local tmpPath2 = "/tmp/youtube-dl-"..tmpName.."-"..tmpNameTwo..".flv"
|
||||||
|
print(x)
|
||||||
local flag = popin.ytdl(tmpPath)
|
local flag = popin.ytdl(tmpPath, tmpPath2)
|
||||||
if not flag then return false end
|
if not flag then return false end
|
||||||
|
|
||||||
return tmpPath2
|
return tmpPath2
|
||||||
end
|
end
|
||||||
|
|
||||||
--optional function to implement autoplay
|
--optional function to implement autoplay
|
||||||
function ask_play(x)
|
|
||||||
play = ""
|
|
||||||
res, play = iup.GetParam("Play now?", nil,
|
|
||||||
"Do you want to play the file now? %t\n", play)
|
|
||||||
|
|
||||||
if res == true then
|
function ask_play(x)
|
||||||
io.popen("notify-send 'The file was saved to' "..x)
|
if x == 0 then
|
||||||
io.popen("xdg-open "..x)
|
|
||||||
else
|
|
||||||
return false
|
return false
|
||||||
|
elseif x == 1 then
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -104,22 +174,26 @@ end
|
|||||||
|
|
||||||
function ffmpeg(tmpPath, dirD)
|
function ffmpeg(tmpPath, dirD)
|
||||||
|
|
||||||
local subSpaces = string.gsub(dirD, " ", "\\ ")
|
if gFormat == ".mp3" then gFormat = "libmp3lame" end
|
||||||
local mp3 = "ffmpeg -i "..tmpPath.." -acodec libmp3lame -ac 2 -ab 192k -vn -y "..subSpaces
|
if gFormat == ".ogg" then gFormat = "libvorbis" end
|
||||||
local ogg = "ffmpeg -i "..tmpPath.." -acodec libvorbis -ac 2 -ab 192k -vn -y "..subSpaces
|
if gFormat == ".flac" then gFormat = "flac" end
|
||||||
local flac = "ffmpeg -i "..tmpPath.." -acodec flac -ac 2 -ab 192k -vn -y "..subSpaces
|
|
||||||
|
|
||||||
if gFormat == ".mp3" then
|
local subSpaces = string.gsub(dirD, " ", "\\ ")
|
||||||
local flag = convert_mp3.go(mp3)
|
local codec = "ffmpeg -i "..tmpPath.." -acodec "..gFormat.." -ac 2 -ab "..gBitrate.." -vn -y "..subSpaces
|
||||||
elseif gFormat == ".ogg" then
|
|
||||||
local flag = convert_mp3.go(ogg)
|
print(format) --debug purposes
|
||||||
elseif gFormat == ".flac" then
|
local flag = convert_mp3.go(codec, tmpPath)
|
||||||
local flag = convert_mp3.go(flac)
|
|
||||||
else
|
|
||||||
if not flag then return false end
|
if not flag then return false end
|
||||||
|
|
||||||
end
|
|
||||||
io.popen("notify-send 'The file was saved to' "..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
|
end
|
||||||
|
|
||||||
--put everything into a table to use local functions globally
|
--put everything into a table to use local functions globally
|
||||||
|
@ -31,7 +31,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
-- start download, create progress bar, monitor progress
|
-- start download, create progress bar, monitor progress
|
||||||
local function DL_progress(YtLink)
|
local function DL_progress(YtLink, tmpPath)
|
||||||
downloadStart(YtLink)
|
downloadStart(YtLink)
|
||||||
downloadProgress.value = 0
|
downloadProgress.value = 0
|
||||||
local pipe = io.popen("youtube-dl " ..YtLink )
|
local pipe = io.popen("youtube-dl " ..YtLink )
|
||||||
@ -50,7 +50,9 @@ local function DL_progress(YtLink)
|
|||||||
iup.Message("Terminated", "You have canceled the download")
|
iup.Message("Terminated", "You have canceled the download")
|
||||||
iup.Flush()
|
iup.Flush()
|
||||||
pipe:close()
|
pipe:close()
|
||||||
|
os.remove(tmpPath..".part")
|
||||||
iup.Flush()
|
iup.Flush()
|
||||||
|
dlgProgress:destroy()
|
||||||
return false
|
return false
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -62,13 +64,14 @@ local function DL_progress(YtLink)
|
|||||||
end
|
end
|
||||||
|
|
||||||
until not c
|
until not c
|
||||||
|
dlgProgress:destroy()
|
||||||
pipe:close()
|
pipe:close()
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
popin = {}
|
popin = {}
|
||||||
popin.ytdl = function(tubeLink)
|
popin.ytdl = function(tubeLink, tmpPath)
|
||||||
local flag = DL_progress(tubeLink)
|
local flag = DL_progress(tubeLink, tmpPath)
|
||||||
if not flag then return false else return true end
|
if not flag then return false else return true end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user