From 8128d9d29ebdd4d64b44194b9bdb75cb888c3176 Mon Sep 17 00:00:00 2001 From: RblSb Date: Sun, 31 Jan 2021 19:42:11 +0300 Subject: Improve youtube link detection --- res/client.js | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'res/client.js') diff --git a/res/client.js b/res/client.js index 4ea4fd7..0f339f6 100644 --- a/res/client.js +++ b/res/client.js @@ -2599,9 +2599,9 @@ var client_players_Youtube = function(main,player) { this.playlistUrl = "https://www.googleapis.com/youtube/v3/playlistItems"; this.videosUrl = "https://www.googleapis.com/youtube/v3/videos"; this.matchPlaylist = new EReg("youtube\\.com.*list=([A-z0-9_-]+)",""); - this.matchEmbed = new EReg("embed/([A-z0-9_-]+)",""); - this.matchShort = new EReg("youtu.be/([A-z0-9_-]+)",""); - this.matchId = new EReg("v=([A-z0-9_-]+)",""); + this.matchEmbed = new EReg("youtube\\.com/embed/([A-z0-9_-]+)",""); + this.matchShort = new EReg("youtu\\.be/([A-z0-9_-]+)",""); + this.matchId = new EReg("youtube\\.com.*v=([A-z0-9_-]+)",""); this.main = main; this.player = player; }; @@ -2615,18 +2615,16 @@ client_players_Youtube.prototype = { } } ,extractVideoId: function(url) { - if(url.indexOf("youtu.be/") != -1) { - this.matchShort.match(url); + if(this.matchId.match(url)) { + return this.matchId.matched(1); + } + if(this.matchShort.match(url)) { return this.matchShort.matched(1); } - if(url.indexOf("youtube.com/embed/") != -1) { - this.matchEmbed.match(url); + if(this.matchEmbed.match(url)) { return this.matchEmbed.matched(1); } - if(!this.matchId.match(url)) { - return ""; - } - return this.matchId.matched(1); + return ""; } ,extractPlaylistId: function(url) { if(!this.matchPlaylist.match(url)) { -- cgit v1.2.3