do the formating in a better way
This commit is contained in:
		| @@ -13,19 +13,19 @@ local options = { | |||||||
| function getranges() | function getranges() | ||||||
| 	local luacurl_available, cURL = pcall(require,'cURL') | 	local luacurl_available, cURL = pcall(require,'cURL') | ||||||
|  |  | ||||||
| 	local args = ("categories=[%s]&videoID=%s"):format(options.categories, youtube_id) | 	local cstr = ("categories=[%s]"):format(options.categories) | ||||||
| 	local API = ("%s?%s"):format(options.server, args) | 	local vstr = ("videoID=%s"):format(youtube_id) | ||||||
|  |  | ||||||
| 	if not(luacurl_available) then -- if Lua-cURL is not available on this system | 	if not(luacurl_available) then -- if Lua-cURL is not available on this system | ||||||
| 		local API = API:gsub("%[", "\\["):gsub("]", "\\]") |  | ||||||
|  |  | ||||||
| 		local curl_cmd = { | 		local curl_cmd = { | ||||||
| 			"curl", | 			"curl", | ||||||
| 			"-L", | 			"-L", | ||||||
| 			"-s", | 			"-s", | ||||||
| 			API -- use inoptimal method of calling external cURL command | 			"-G", | ||||||
|  | 			"-d", cstr, | ||||||
|  | 			"-d", vstr, | ||||||
|  | 			options.server | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		local sponsors = mp.command_native{ | 		local sponsors = mp.command_native{ | ||||||
| 			name = "subprocess", | 			name = "subprocess", | ||||||
| 			capture_stdout = true, | 			capture_stdout = true, | ||||||
| @@ -34,6 +34,7 @@ function getranges() | |||||||
| 		} | 		} | ||||||
| 		res = sponsors.stdout | 		res = sponsors.stdout | ||||||
| 	else -- otherwise use Lua-cURL (binding to libcurl) | 	else -- otherwise use Lua-cURL (binding to libcurl) | ||||||
|  | 		local API = ("%s?%s&%s"):format(options.server, cstr, vstr) | ||||||
| 		local buf={} | 		local buf={} | ||||||
| 		local c = cURL.easy_init() | 		local c = cURL.easy_init() | ||||||
| 		c:setopt_followlocation(1) | 		c:setopt_followlocation(1) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user