Added bitrate options
This commit is contained in:
parent
e59b9cf3f4
commit
007ff260f7
@ -1,6 +1,6 @@
|
|||||||
cfg_table = {
|
cfg_table = {
|
||||||
|
|
||||||
format = "ogg" -- 0 for mp3, 1 for ogg, 2 for flac
|
format = "ogg", --0 for mp3, 1 for ogg, 2 for flac
|
||||||
|
bitrate = "320k"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
74
mandy.lua
74
mandy.lua
@ -7,24 +7,32 @@ require('ffmpeg_progress')
|
|||||||
|
|
||||||
--Main url entry box
|
--Main url entry box
|
||||||
function url_entry()
|
function url_entry()
|
||||||
|
local changeLog = io.popen("changelog.txt", "r")
|
||||||
local format = sel_format()
|
local format = sel_format()
|
||||||
|
local bitRate = sel_bitrate()
|
||||||
local url = ""
|
local url = ""
|
||||||
|
local multiLine = "changeLog"
|
||||||
|
|
||||||
res, url, format = iup.GetParam("Mandy 0.5.0 - Enter URL", nil,
|
|
||||||
|
res, url, format, bitRate, multiLine = iup.GetParam("Mandy 0.5.0 - Enter URL", nil,
|
||||||
"Enter Youtube URL: %s\n"..
|
"Enter Youtube URL: %s\n"..
|
||||||
"Select an audio format: %l|mp3|ogg|flac|\n", url, format)
|
"Audio Options %t\n"..
|
||||||
|
"Select an audio format: %l|mp3|ogg|flac|\n"..
|
||||||
|
"Select the bitrate: %l|320 kb/s|192 kb/s|160 kb/s|128 kb/s|96 kb/s|32 kb/s|\n"..
|
||||||
|
"Changelog %m\n", url, format, bitRate, multiLine)
|
||||||
|
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
local format_config = io.open("Config.txt", "w")
|
--local format_config = io.open("Config.txt", "w")
|
||||||
format_config:write("local format = "..format)
|
--format_config:write("local format = "..format)
|
||||||
format_config:close()
|
--format_config:close()
|
||||||
|
--local bitrate_config = io.open("Config.txt", "w")
|
||||||
|
--bitrate_config:write("local bitrate = "..bitRate)
|
||||||
|
--bitrate_config:close()
|
||||||
return url
|
return url
|
||||||
else
|
else
|
||||||
iup.Message("Error", "The URL is not a youtube link")
|
iup.Message("Error", "The URL is not a youtube link")
|
||||||
@ -48,6 +56,17 @@ function sel_format()
|
|||||||
end
|
end
|
||||||
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
|
||||||
|
|
||||||
|
|
||||||
--make format dropdown menu items work
|
--make format dropdown menu items work
|
||||||
@ -68,6 +87,34 @@ 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 = "b192k"
|
||||||
|
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
|
||||||
|
elseif x == 5 then
|
||||||
|
local b32k = "32k"
|
||||||
|
print ("Selected "..b32k)
|
||||||
|
return b32k
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--Ask user to set directory
|
--Ask user to set directory
|
||||||
function set_dir()
|
function set_dir()
|
||||||
|
|
||||||
@ -102,7 +149,7 @@ 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, tmpPath2)
|
local flag = popin.ytdl(tmpPath, tmpPath2)
|
||||||
if not flag then return false end
|
if not flag then return false end
|
||||||
|
|
||||||
@ -135,9 +182,14 @@ function ffmpeg(tmpPath, dirD)
|
|||||||
if gFormat == ".ogg" then gFormat = "libvorbis" end
|
if gFormat == ".ogg" then gFormat = "libvorbis" end
|
||||||
if gFormat == ".flac" then gFormat = "flac" end
|
if gFormat == ".flac" then gFormat = "flac" end
|
||||||
|
|
||||||
|
if gBitrate == "320k" then gBitrate = "320k" end
|
||||||
|
if gBitrate == "192k" then gBitrate = "192k" end
|
||||||
|
if gBitrate == "160k" then gBitrate = "160k" end
|
||||||
|
if gBitrate == "128k" then gBitrate = "128k" end
|
||||||
|
if gBitrate == "96k" then gBitrate = "96k" end
|
||||||
|
if gBitrate == "32k" then gBitrate = "32k" end
|
||||||
local subSpaces = string.gsub(dirD, " ", "\\ ")
|
local subSpaces = string.gsub(dirD, " ", "\\ ")
|
||||||
local codec = "ffmpeg -i "..tmpPath.." -acodec "..gFormat.." -ac 2 -ab 192k -vn -y "..subSpaces
|
local codec = "ffmpeg -i "..tmpPath.." -acodec "..gFormat.." -ac 2 -ab "..gBitrate.." -vn -y "..subSpaces
|
||||||
|
|
||||||
print(format)
|
print(format)
|
||||||
local flag = convert_mp3.go(codec, tmpPath)
|
local flag = convert_mp3.go(codec, tmpPath)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user