2013-07-23 21:23:31 -05:00
|
|
|
#!/usr/bin/lua5.2
|
|
|
|
|
|
|
|
--ffmpeg
|
|
|
|
--libavcodec-extra-53 <-Ubuntu...suck it
|
|
|
|
|
|
|
|
require("iuplua")
|
|
|
|
require("iupluacontrols")
|
|
|
|
require('progress')
|
2013-07-27 01:52:23 -05:00
|
|
|
require('ffmpeg_progress')
|
2013-07-26 20:36:15 -05:00
|
|
|
|
2013-07-23 21:23:31 -05:00
|
|
|
|
|
|
|
|
2013-07-26 22:49:41 -05:00
|
|
|
|
2013-07-23 21:23:31 -05:00
|
|
|
--Main url entry box
|
|
|
|
function url_entry()
|
|
|
|
|
2013-07-27 03:55:23 -05:00
|
|
|
res, url = iup.GetParam("Mandy 0.4 - Enter URL", nil,
|
2013-07-23 21:23:31 -05:00
|
|
|
"Enter Youtube URL: %s\n", "")
|
2013-07-26 22:49:41 -05:00
|
|
|
|
|
|
|
if res == true then
|
|
|
|
if string.match(url, "youtube.com/watch") then
|
|
|
|
return url
|
2013-07-24 13:13:50 -05:00
|
|
|
|
2013-07-26 22:49:41 -05:00
|
|
|
else
|
|
|
|
iup.Message("Error", "The URL is not a youtube link")
|
|
|
|
iup.Flush()
|
|
|
|
iup.Close()
|
|
|
|
end
|
2013-07-24 13:13:50 -05:00
|
|
|
|
2013-07-26 22:49:41 -05:00
|
|
|
|
|
|
|
else
|
|
|
|
return false
|
2013-07-23 21:23:31 -05:00
|
|
|
|
2013-07-24 13:13:50 -05:00
|
|
|
end
|
2013-07-26 22:49:41 -05:00
|
|
|
|
|
|
|
|
2013-07-23 21:23:31 -05:00
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--Ask user to select a codec
|
|
|
|
function sel_Codec()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--Ask user to set directory
|
|
|
|
function set_dir()
|
|
|
|
getPath = iup.filedlg{dialogtype = "SAVE", title="Save file...",
|
|
|
|
filter="*.mp3", filterinfo="mp3",
|
2013-07-27 03:55:23 -05:00
|
|
|
directory=".",
|
2013-07-24 07:20:05 -05:00
|
|
|
file="*.mp3"}
|
2013-07-23 21:23:31 -05:00
|
|
|
|
|
|
|
getPath:popup(iup.ANYWHERE, iup.ANYWHERE)
|
|
|
|
|
|
|
|
local status = getPath.status
|
|
|
|
|
|
|
|
if status == "1" then
|
2013-07-24 13:13:50 -05:00
|
|
|
if string.match(getPath.value, ".mp3") then
|
|
|
|
local savedPath = getPath.value
|
|
|
|
return savedPath
|
|
|
|
|
|
|
|
else
|
|
|
|
local savedPath = getPath.value..".mp3"
|
|
|
|
return savedPath
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2013-07-23 21:23:31 -05:00
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
end
|
2013-07-26 23:14:23 -05:00
|
|
|
|
2013-07-23 21:23:31 -05:00
|
|
|
|
|
|
|
end
|
|
|
|
|
2013-07-26 21:07:19 -05:00
|
|
|
function ytDl(x)
|
|
|
|
local tmpName = math.random(0,999999999999)
|
|
|
|
local tmpNameTwo = math.random(0,999999999999)
|
2013-07-26 21:32:28 -05:00
|
|
|
local tmpPath = x.." --output=/tmp/youtube-dl-"..tmpName.."-"..tmpNameTwo..".flv"
|
2013-07-26 21:07:19 -05:00
|
|
|
local tmpPath2 = "/tmp/youtube-dl-"..tmpName.."-"..tmpNameTwo..".flv"
|
2013-07-23 21:23:31 -05:00
|
|
|
|
2013-07-23 22:56:10 -05:00
|
|
|
popin.ytdl(tmpPath)
|
2013-07-26 20:36:15 -05:00
|
|
|
|
2013-07-26 21:07:19 -05:00
|
|
|
return tmpPath2
|
2013-07-23 21:23:31 -05:00
|
|
|
|
|
|
|
end
|
|
|
|
|
2013-07-26 21:07:19 -05:00
|
|
|
function ffmpeg(tmpPath, dirD)
|
2013-07-27 03:55:23 -05:00
|
|
|
local subSpaces = string.gsub(dirD, "", "\\")
|
|
|
|
local mp3 = "ffmpeg -i "..tmpPath.." -acodec libmp3lame -ac 2 -ab 192k -vn -y "..subSpaces
|
2013-07-27 01:38:39 -05:00
|
|
|
--os.execute(mp3)
|
2013-07-26 22:49:41 -05:00
|
|
|
convert_mp3.go(mp3)
|
2013-07-27 03:55:23 -05:00
|
|
|
io.popen("notify-send 'The file was saved to' "..subSpaces)
|
|
|
|
io.popen("xdg-open "..subSpaces)
|
2013-07-23 21:23:31 -05:00
|
|
|
end
|
|
|
|
--put everything into a table to use local functions globally
|
|
|
|
global = {}
|
|
|
|
global.url = function ()
|
|
|
|
local url = url_entry()
|
|
|
|
return url
|
|
|
|
end
|
|
|
|
|
|
|
|
global.dir = function()
|
|
|
|
local dir = set_dir()
|
|
|
|
return dir
|
|
|
|
end
|
|
|
|
|
2013-07-26 21:07:19 -05:00
|
|
|
global.path = function(url)
|
|
|
|
local yt = ytDl(url)
|
|
|
|
return yt
|
2013-07-23 21:23:31 -05:00
|
|
|
end
|
|
|
|
|
2013-07-26 21:07:19 -05:00
|
|
|
global.ffmpeg = function(tmpPath, saveDir)
|
|
|
|
local convert = ffmpeg(tmpPath, saveDir)
|
|
|
|
return convert
|
|
|
|
end
|
2013-07-23 21:23:31 -05:00
|
|
|
|
|
|
|
|