feat(embeds): add support to youtube shorts

This commit is contained in:
Tom (plebeius.eth)
2025-02-27 12:26:38 +01:00
parent 0e0e7c22cb
commit 306e7b081f
2 changed files with 4 additions and 0 deletions
+2
View File
@@ -74,6 +74,8 @@ const YoutubeEmbed = ({ parsedUrl }: EmbedComponentProps) => {
if (!videoId) {
if (parsedUrl.host.includes('youtu.be')) {
videoId = parsedUrl.pathname.substring(1);
} else if (parsedUrl.pathname.includes('/shorts/')) {
videoId = parsedUrl.pathname.split('/shorts/')[1];
} else if (isInvidious) {
if (parsedUrl.pathname.startsWith('/watch')) {
videoId = parsedUrl.searchParams.get('v');
+2
View File
@@ -52,6 +52,8 @@ export const getHasThumbnail = (commentMediaInfo: CommentMediaInfo | undefined,
const getYouTubeVideoId = (url: URL): string | null => {
if (url.host.includes('youtu.be')) {
return url.pathname.slice(1);
} else if (url.pathname.includes('/shorts/')) {
return url.pathname.split('/shorts/')[1].split('/')[0];
} else if (url.searchParams.has('v')) {
return url.searchParams.get('v');
}