basic url validation/file name validation

This commit is contained in:
2013-07-24 13:13:50 -05:00
parent f9eff77186
commit afdcd87499
5 changed files with 124 additions and 15 deletions

View File

@@ -6,6 +6,7 @@
require("iuplua")
require("iupluacontrols")
require('progress')
require('ffmpeg_progress')
--Main url entry box
@@ -13,9 +14,17 @@ function url_entry()
res, url = iup.GetParam("Mandy - 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
return url
end
@@ -41,8 +50,16 @@ function set_dir()
local status = getPath.status
if status == "1" then
local savedPath = getPath.value
return savedPath
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
@@ -78,18 +95,12 @@ function ytDl(x)
end
function ffmpeg(tmpPath, dirD)
if dirD == dirD..".mp3" then
dirD = dirD
mp3 = "ffmpeg -i "..tmpPath.." -acodec libmp3lame -ac 2 -ab 192k -vn -y "..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)
elseif dirD ~= dirD..".mp3" then
dirD = dirD..".mp3"
mp3 = "ffmpeg -i "..tmpPath.." -acodec libmp3lame -ac 2 -ab 192k -vn -y"..dirD..""
os.execute(mp3)
io.popen("vlc "..dirD)
end
end
--put everything into a table to use local functions globally