From 4f46a7eaa803cb000a9f26bb1b313cf6838f55de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Mon, 15 Mar 2021 20:15:24 +0100 Subject: [PATCH] YT: handle embedded videos URIs --- src/youtube.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/youtube.js b/src/youtube.js index 64881750..ce28217e 100644 --- a/src/youtube.js +++ b/src/youtube.js @@ -493,14 +493,18 @@ function checkYouTubeUri(uri) gstUri.normalize(); const host = gstUri.get_host(); - - let success = true; let videoId = null; switch(host) { case 'www.youtube.com': case 'youtube.com': videoId = gstUri.get_query_value('v'); + if(!videoId) { + /* Handle embedded videos */ + const segments = gstUri.get_path_segments(); + if(segments && segments.length) + videoId = segments[segments.length - 1]; + } break; case 'youtu.be': videoId = gstUri.get_path_segments()[1]; @@ -512,9 +516,10 @@ function checkYouTubeUri(uri) videoId = originalHost; break; } - success = false; break; } + const success = (videoId != null); + return [success, videoId]; }