diff options
| -rw-r--r-- | res/client.js | 20 | ||||
| -rw-r--r-- | src/client/players/Youtube.hx | 18 |
2 files changed, 18 insertions, 20 deletions
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)) { diff --git a/src/client/players/Youtube.hx b/src/client/players/Youtube.hx index 10064b6..e63a095 100644 --- a/src/client/players/Youtube.hx +++ b/src/client/players/Youtube.hx @@ -14,9 +14,9 @@ using StringTools; class Youtube implements IPlayer { - final matchId = ~/v=([A-z0-9_-]+)/; - final matchShort = ~/youtu.be\/([A-z0-9_-]+)/; - final matchEmbed = ~/embed\/([A-z0-9_-]+)/; + final matchId = ~/youtube\.com.*v=([A-z0-9_-]+)/; + final matchShort = ~/youtu\.be\/([A-z0-9_-]+)/; + final matchEmbed = ~/youtube\.com\/embed\/([A-z0-9_-]+)/; final matchPlaylist = ~/youtube\.com.*list=([A-z0-9_-]+)/; final videosUrl = "https://www.googleapis.com/youtube/v3/videos"; final playlistUrl = "https://www.googleapis.com/youtube/v3/playlistItems"; @@ -41,16 +41,16 @@ class Youtube implements IPlayer { } function extractVideoId(url:String):String { - if (url.contains("youtu.be/")) { - matchShort.match(url); + if (matchId.match(url)) { + return matchId.matched(1); + } + if (matchShort.match(url)) { return matchShort.matched(1); } - if (url.contains("youtube.com/embed/")) { - matchEmbed.match(url); + if (matchEmbed.match(url)) { return matchEmbed.matched(1); } - if (!matchId.match(url)) return ""; - return matchId.matched(1); + return ""; } function extractPlaylistId(url:String):String { |
