#!/usr/bin/lua5.2 --ffmpeg --libavcodec-extra-53 <-Ubuntu...suck it require("iuplua") require("iupluacontrols") require('progress') require('ffmpeg_progress') --Main url entry box function url_entry() 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 else iup.Message("Error", "The URL is not a youtube link") iup.Flush() iup.Close() end 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", directory="Music/", file="*.mp3"} getPath:popup(iup.ANYWHERE, iup.ANYWHERE) local status = getPath.status if status == "1" then if string.match(getPath.value, ".mp3") then local savedPath = getPath.value return savedPath else local savedPath = getPath.value..".mp3" return savedPath end 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 end function ytDl(x, y) --local tmpName = math.random(0,999999999999) --local tmpNameTwo = math.random(0,999999999999) local thePath = set_dir() local tmpPath = x.."--extract-audio --audio-format=mp3 -t --output="..thePath --local tmpPath2 = "/tmp/youtube-dl-"..tmpName.."-"..tmpNameTwo..".flv" popin.ytdl(tmpPath) io.popen("vlc "..y) return 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) io.popen("vlc "..dirD) 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 global.path = function(url, dir) local yt = ytDl(url, dir) return yt end --global.ffmpeg = function(tmpPath, saveDir) -- local convert = ffmpeg(tmpPath, saveDir) -- return convert --end