diff --git a/x/x.js b/x/x.js new file mode 100644 index 0000000..ed40212 --- /dev/null +++ b/x/x.js @@ -0,0 +1,84 @@ +async function searchResults(keyword) { + const results = []; + const headers = { + "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3", + "Cookie": "hlsPlayback=on" + }; + try { + const response = await fetchv2(`https://nitter.net/search?q=${encodeURIComponent(keyword)}&f-videos=on&f=tweets`, headers); + const html = await response.text(); + + const regex = /]*>([\s\S]*?)<\/div>[\s\S]*?]*>/g, '').trim(); + const image = "https://nitter.net" + match[3].trim(); + const videoUrl = "https://nitter.net" + match[4].trim(); + + const href = videoUrl + "?tweetbody=" + encodeURIComponent(tweetBody); + + results.push({ + title: username, + image: image, + href: href + }); + } + + return JSON.stringify(results); + } catch (err) { + return JSON.stringify([{ + title: "Error", + image: "Error", + href: "Error" + }]); + } +} + +async function extractDetails(url) { + try { + const urlParts = url.split('?tweetbody='); + const description = urlParts.length > 1 ? decodeURIComponent(urlParts[1]) : "N/A"; + + return JSON.stringify([{ + description: description, + aliases: "N/A", + airdate: "N/A" + }]); + } catch (err) { + return JSON.stringify([{ + description: "Error", + aliases: "Error", + airdate: "Error" + }]); + } +} + +async function extractEpisodes(url) { + const results = []; + try { + const urlParts = url.split('?tweetbody='); + const videoUrl = urlParts[0]; + + results.push({ + href: videoUrl, + number: 1 + }); + + return JSON.stringify(results); + } catch (err) { + return JSON.stringify([{ + href: "Error", + number: "Error" + }]); + } +} + +async function extractStreamUrl(url) { + try { + return url; + } catch (err) { + return "https://error.org/"; + } +}