make the message less useless
This commit is contained in:
		
							parent
							
								
									bdb0f48c4d
								
							
						
					
					
						commit
						2775d83c94
					
				|  | @ -20,26 +20,29 @@ function getranges() | ||||||
| 		"categories=["..options.categories.."]", | 		"categories=["..options.categories.."]", | ||||||
| 		"-G", | 		"-G", | ||||||
|         	options.API} |         	options.API} | ||||||
| 	local sponsors |     	local sponsors = mp.command_native({name = "subprocess", capture_stdout = true, playback_only = false, args = args}) | ||||||
|     	sponsors = mp.command_native({name = "subprocess", capture_stdout = true, playback_only = false, args = args}) | 
 | ||||||
|     	if not string.match(sponsors.stdout,"%[(.-)%]") then return end |     	if string.match(sponsors.stdout,"%[(.-)%]") then | ||||||
| 	ranges = {} | 		ranges = {} | ||||||
| 	for i in string.gmatch(string.sub(sponsors.stdout,2,-2),"%[(.-)%]") do | 		for i in string.gmatch(string.sub(sponsors.stdout,2,-2),"%[(.-)%]") do | ||||||
| 		k,v = string.match(i,"(%d+.?%d*),(%d+.?%d*)") | 			k,v = string.match(i,"(%d+.?%d*),(%d+.?%d*)") | ||||||
| 		ranges[k] = v | 			ranges[k] = v | ||||||
|  | 		end | ||||||
| 	end | 	end | ||||||
| 	return | 	return | ||||||
| end | end | ||||||
| 
 | 
 | ||||||
| function skip_ads(name,pos) | function skip_ads(name,pos) | ||||||
| 	if pos == nil then return end | 	if pos ~= nil then | ||||||
| 	for k,v in pairs(ranges) do | 		for k,v in pairs(ranges) do | ||||||
| 		if tonumber(k) <= pos and tonumber(v) > pos then | 			if tonumber(k) <= pos and tonumber(v) > pos then | ||||||
|         		mp.osd_message("[sponsorblock] skipping to "..tostring(v)) |         			mp.osd_message("[sponsorblock] skipping forward "..math.floor(tonumber(v)-mp.get_property("time-pos")).."s") | ||||||
| 			mp.set_property("time-pos",tonumber(v)) | 				mp.set_property("time-pos",tonumber(v)+0.01) | ||||||
|             		return |             			return | ||||||
|     		end |     			end | ||||||
|  | 		end | ||||||
| 	end | 	end | ||||||
|  | 	return | ||||||
| end | end | ||||||
| 
 | 
 | ||||||
| function file_loaded() | function file_loaded() | ||||||
|  | @ -53,11 +56,12 @@ function file_loaded() | ||||||
| 	youtube_id = string.sub(youtube_id, 1, 11) | 	youtube_id = string.sub(youtube_id, 1, 11) | ||||||
| 
 | 
 | ||||||
| 	getranges() | 	getranges() | ||||||
| 	if not ranges then return end | 	if ranges then | ||||||
| 
 | 		ON = true | ||||||
| 	ON = true | 		mp.add_key_binding("b","sponsorblock",toggle) | ||||||
| 	mp.add_key_binding("b","sponsorblock",toggle) | 		mp.observe_property("time-pos", "native", skip_ads) | ||||||
| 	mp.observe_property("time-pos", "native", skip_ads) | 	end | ||||||
|  | 	return | ||||||
| end | end | ||||||
| 
 | 
 | ||||||
| function toggle() | function toggle() | ||||||
|  |  | ||||||
		Reference in New Issue