Merge pull request 'Search for Youtube-IDs in local files' (#1) from JanBecker/mpv_sponsorblock_minimal:master into master

Reviewed-on: https://codeberg.org/jouni/mpv_sponsorblock_minimal/pulls/1
This commit is contained in:
jouni 2021-04-11 22:50:48 +02:00
commit 95ab1f572c
1 changed files with 2 additions and 1 deletions

View File

@ -55,7 +55,8 @@ function file_loaded()
local youtube_id2 = string.match(video_path, "https?://w?w?w?%.?youtube%.com/v/([%w-_]+).*") 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 youtube_id3 = string.match(video_path, "/watch.*[?&]v=([%w-_]+).*")
local youtube_id4 = string.match(video_path, "/embed/([%w-_]+).*") local youtube_id4 = string.match(video_path, "/embed/([%w-_]+).*")
youtube_id = youtube_id1 or youtube_id2 or youtube_id3 or youtube_id4 local youtube_id5 = string.match(video_path, ".*-([%w-_]+).*")
youtube_id = youtube_id1 or youtube_id2 or youtube_id3 or youtube_id4 or youtube_id5
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)