Change getting video id method

This commit is contained in:
blank X 2021-03-12 18:57:04 +07:00
parent b9ce682bf0
commit d608ee9429
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
1 changed files with 4 additions and 6 deletions

View File

@ -51,12 +51,10 @@ 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_title = mp.get_property("media-title")
local youtube_id2 = string.match(video_path, "https?://w?w?w?%.?youtube%.com/v/([%w-_]+).*") youtube_id = string.match(video_title, ".* %(([%w-_]+)%)")
local youtube_id3 = string.match(video_path, "/watch.*[?&]v=([%w-_]+).*") print(youtube_id)
local youtube_id4 = string.match(video_path, "/embed/([%w-_]+).*") if not string.match(video_path, "https?://.*%.?googlevideo%.com/.*") or not youtube_id or string.len(youtube_id) < 11 then return end
youtube_id = youtube_id1 or youtube_id2 or youtube_id3 or youtube_id4
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)
getranges() getranges()