aboutsummaryrefslogtreecommitdiffstats
path: root/src/client
diff options
context:
space:
mode:
authorRblSb <msrblsb@gmail.com>2021-01-31 19:42:11 +0300
committerRblSb <msrblsb@gmail.com>2021-01-31 19:43:34 +0300
commit8128d9d29ebdd4d64b44194b9bdb75cb888c3176 (patch)
treed20a6c5e4f96c7e17843b93b5a579512a8be6a60 /src/client
parent8e603b7161b19a1035616b71c5b572577ac24317 (diff)
Improve youtube link detection
Diffstat (limited to 'src/client')
-rw-r--r--src/client/players/Youtube.hx18
1 files changed, 9 insertions, 9 deletions
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 {
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage