From 232d869fc82d7abea8221c9f382faac4a5feefdb Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Sat, 9 Sep 2023 17:09:09 +0200 Subject: [PATCH] fix embedded media, add new sites --- src/components/Embed.jsx | 259 +++++++++++++++++++ src/components/styled/GlobalStyle.styled.jsx | 45 +++- src/components/views/Board.jsx | 180 +++++++------ src/utils/getCommentMediaInfo.js | 45 +--- yarn.lock | 186 +------------ 5 files changed, 412 insertions(+), 303 deletions(-) create mode 100644 src/components/Embed.jsx diff --git a/src/components/Embed.jsx b/src/components/Embed.jsx new file mode 100644 index 00000000..5629c2e7 --- /dev/null +++ b/src/components/Embed.jsx @@ -0,0 +1,259 @@ +const Embed = ({url}) => { + const parsedUrl = new URL(url); + + if (youtubeHosts.has(parsedUrl.host)) { + return ; + } + if (twitterHosts.has(parsedUrl.host)) { + return ; + } + if (redditHosts.has(parsedUrl.host)) { + return ; + } + if (twitchHosts.has(parsedUrl.host)) { + return ; + } + if (tiktokHosts.has(parsedUrl.host)) { + return ; + } + if (instagramHosts.has(parsedUrl.host)) { + return ; + } + if (odyseeHosts.has(parsedUrl.host)) { + return ; + } + if (bitchuteHosts.has(parsedUrl.host)) { + return ; + } + if (streamableHosts.has(parsedUrl.host)) { + return ; + } + if (spotifyHosts.has(parsedUrl.host)) { + return ; + } +}; + +const youtubeHosts = new Set(['youtube.com', 'www.youtube.com', 'youtu.be', 'www.youtu.be']); + +const YoutubeEmbed = ({parsedUrl}) => { + let youtubeId; + if (parsedUrl.host.endsWith('youtu.be')) { + youtubeId = parsedUrl.pathname.replaceAll('/', ''); + } + else { + youtubeId = parsedUrl.searchParams.get('v'); + } + return