mirror of
https://git.luna-app.eu/50n50/sources
synced 2025-12-21 21:26:19 +01:00
Add x/x.js
This commit is contained in:
parent
2beba5ff6b
commit
6a2aaff828
1 changed files with 84 additions and 0 deletions
84
x/x.js
Normal file
84
x/x.js
Normal file
|
|
@ -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 = /<a class="username" href="\/([^"]+)"[\s\S]*?<div class="tweet-content[^"]*"[^>]*>([\s\S]*?)<\/div>[\s\S]*?<video\s+poster="([^"]+)"[\s\S]*?data-url="([^"]+)"/g;
|
||||
|
||||
let match;
|
||||
while ((match = regex.exec(html)) !== null) {
|
||||
const username = match[1].trim();
|
||||
const tweetBody = match[2].replace(/<[^>]*>/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/";
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue