diff --git a/public/embico/odysee.png b/public/embico/odysee.png new file mode 100644 index 00000000..148c2103 Binary files /dev/null and b/public/embico/odysee.png differ diff --git a/public/embico/twitter.png b/public/embico/twitter.png new file mode 100644 index 00000000..ad280c69 Binary files /dev/null and b/public/embico/twitter.png differ diff --git a/src/components/embeds/Odysee.jsx b/src/components/embeds/Odysee.jsx index c79314c3..de35a3a7 100644 --- a/src/components/embeds/Odysee.jsx +++ b/src/components/embeds/Odysee.jsx @@ -3,48 +3,39 @@ * therefor we can't use it right now. * Still keeping this here in case that the policy changes in the future */ -import React, { useState, useEffect } from 'react'; +import React from 'react'; -function getUserFromUrl(url) { - let aPos = url.indexOf('/@'); - if (aPos === -1) { - return url; +import { stripQuery } from '../../core/utils'; + +function stripCol(str) { + const posCol = str.lastIndexOf(':'); + if (posCol !== -1) { + return str.substring(0, posCol); } - aPos += 1; - let bPos = url.indexOf(':', aPos); - if (bPos === -1) { - bPos = url.length; - } - return url.substring(aPos, bPos); + return str; } +const urlStr = '/@'; + const Odysee = ({ url }) => { - const [embedUrl, setEmbedUrl] = useState(null); - - useEffect(async () => { - const prot = window.location.protocol.startsWith('http') - ? window.location.protocol : 'https'; - // eslint-disable-next-line max-len - const odurl = `${prot}//odysee.com/$/oembed?url=${encodeURIComponent(url)}&format=json`; - const resp = await fetch(odurl); - const embedData = await resp.json(); - if (embedData.html) { - const { html } = embedData; - let emUrl = html.substring(html.indexOf('src="') + 5); - emUrl = emUrl.substring(0, emUrl.indexOf('"')); - setEmbedUrl(emUrl); + let oid = null; + let posA = url.indexOf(urlStr); + if (posA !== -1) { + oid = url.substring(url.indexOf('/', posA + urlStr.length) + 1); + } else { + posA = url.indexOf('//'); + if (posA === -1) { + posA = 0; } - }, []); - - if (!embedUrl) { - return
LOADING
; + oid = url.substring(url.indexOf('/', posA + 2) + 1); } + oid = stripCol(stripQuery(oid)); return (