add changes from the original mpv sponsorblock
This commit is contained in:
parent
95ab1f572c
commit
65e13958f2
|
@ -50,13 +50,21 @@ function skip_ads(name,pos)
|
||||||
end
|
end
|
||||||
|
|
||||||
function file_loaded()
|
function file_loaded()
|
||||||
local video_path = mp.get_property("path")
|
local video_path = mp.get_property("path", "")
|
||||||
local youtube_id1 = string.match(video_path, "https?://youtu%.be/([%w-_]+).*")
|
local video_referer = string.match(mp.get_property("http-header-fields", ""), "Referer:([^,]+)") or ""
|
||||||
local youtube_id2 = string.match(video_path, "https?://w?w?w?%.?youtube%.com/v/([%w-_]+).*")
|
|
||||||
local youtube_id3 = string.match(video_path, "/watch.*[?&]v=([%w-_]+).*")
|
local urls = {
|
||||||
local youtube_id4 = string.match(video_path, "/embed/([%w-_]+).*")
|
"https?://youtu%.be/([%w-_]+).*",
|
||||||
local youtube_id5 = string.match(video_path, ".*-([%w-_]+).*")
|
"https?://w?w?w?%.?youtube%.com/v/([%w-_]+).*",
|
||||||
youtube_id = youtube_id1 or youtube_id2 or youtube_id3 or youtube_id4 or youtube_id5
|
"/watch.*[?&]v=([%w-_]+).*",
|
||||||
|
"/embed/([%w-_]+).*",
|
||||||
|
".*-([%w-_]+).*"
|
||||||
|
}
|
||||||
|
youtube_id = nil
|
||||||
|
for i,url in ipairs(urls) do
|
||||||
|
youtube_id = youtube_id or string.match(video_path, url) or string.match(video_referer, url)
|
||||||
|
end
|
||||||
|
|
||||||
if not youtube_id or string.len(youtube_id) < 11 then return end
|
if not youtube_id or string.len(youtube_id) < 11 then return end
|
||||||
youtube_id = string.sub(youtube_id, 1, 11)
|
youtube_id = string.sub(youtube_id, 1, 11)
|
||||||
|
|
||||||
|
|
Reference in New Issue