Spaces:
Paused
Paused
Update index.js
Browse files
index.js
CHANGED
|
@@ -279,6 +279,77 @@ async function downloadFromUrl(url, filePath) {
|
|
| 279 |
});
|
| 280 |
}
|
| 281 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 282 |
async function Rules34info(url_r34) {
|
| 283 |
try {
|
| 284 |
// Mengambil halaman HTML dengan Axios
|
|
@@ -424,6 +495,7 @@ async function Rules34(url_r34) {
|
|
| 424 |
}
|
| 425 |
}
|
| 426 |
|
|
|
|
| 427 |
app.get('/r34', async (req, res) => {
|
| 428 |
const { url } = req.query;
|
| 429 |
if (!url) {
|
|
@@ -526,7 +598,7 @@ app.get('/r34/info', async (req, res) => {
|
|
| 526 |
return res.status(400).send('URL is required');
|
| 527 |
}
|
| 528 |
try {
|
| 529 |
-
const result = await
|
| 530 |
res.json(result);
|
| 531 |
} catch (error) {
|
| 532 |
res.status(500).send('Error processing request');
|
|
|
|
| 279 |
});
|
| 280 |
}
|
| 281 |
|
| 282 |
+
|
| 283 |
+
|
| 284 |
+
async function Rules34Infonues(url_r34) {
|
| 285 |
+
try {
|
| 286 |
+
const browser = await puppeteer.launch();
|
| 287 |
+
const page = await browser.newPage();
|
| 288 |
+
|
| 289 |
+
await page.setExtraHTTPHeaders({
|
| 290 |
+
'User-Agent': getRandomUserAgent() || 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36',
|
| 291 |
+
'Referer': url_r34
|
| 292 |
+
});
|
| 293 |
+
|
| 294 |
+
await page.goto(url_r34, { referer: url_r34 });
|
| 295 |
+
|
| 296 |
+
const htmlContent = await page.content();
|
| 297 |
+
const $ = cheerio.load(htmlContent);
|
| 298 |
+
|
| 299 |
+
const title = $("body > div > div.wrapper > div.main > div.container > div > div > div:nth-child(1) > div.heading > h1").text().trim() ||
|
| 300 |
+
url_r34.match(/\/video\/\d+\/(.*)\//)?.[1];
|
| 301 |
+
|
| 302 |
+
const infoElements = $("#tab_video_info > div");
|
| 303 |
+
const result = {
|
| 304 |
+
title,
|
| 305 |
+
artist: [],
|
| 306 |
+
uploader: [],
|
| 307 |
+
tags: [],
|
| 308 |
+
download: [],
|
| 309 |
+
category: []
|
| 310 |
+
};
|
| 311 |
+
|
| 312 |
+
if (infoElements.length > 0) {
|
| 313 |
+
const [videoInfo, tags, download] = [
|
| 314 |
+
infoElements.eq(infoElements.length - 3),
|
| 315 |
+
infoElements.eq(infoElements.length - 2),
|
| 316 |
+
infoElements.eq(infoElements.length - 1)
|
| 317 |
+
];
|
| 318 |
+
|
| 319 |
+
tags.find("div.wrap > a").each((_, element) => {
|
| 320 |
+
result.tags.push({ title: $(element).text().trim(), url: $(element).attr('href') });
|
| 321 |
+
});
|
| 322 |
+
result.tags.pop(); // Menghapus elemen terakhir dari tags
|
| 323 |
+
|
| 324 |
+
download.find("div.wrap > a").each((_, element) => {
|
| 325 |
+
result.download.push({ quality: $(element).text().trim(), url: $(element).attr('href') });
|
| 326 |
+
});
|
| 327 |
+
|
| 328 |
+
videoInfo.find("div.cols > div").each((_, col) => {
|
| 329 |
+
$(col).find("div.col:nth-child(1) > a").each((_, link) => {
|
| 330 |
+
result.category.push({ title: $(link).text().trim(), url: $(link).attr('href') });
|
| 331 |
+
});
|
| 332 |
+
|
| 333 |
+
$(col).find("div.col:nth-child(2) > a").each((_, link) => {
|
| 334 |
+
result.artist.push({ title: $(link).text().trim(), url: $(link).attr('href') });
|
| 335 |
+
});
|
| 336 |
+
|
| 337 |
+
$(col).find("div.col:nth-child(3) > a").each((_, link) => {
|
| 338 |
+
result.uploader.push({ title: $(link).text().trim(), url: $(link).attr('href') });
|
| 339 |
+
});
|
| 340 |
+
});
|
| 341 |
+
}
|
| 342 |
+
|
| 343 |
+
await browser.close();
|
| 344 |
+
return result;
|
| 345 |
+
} catch (error) {
|
| 346 |
+
console.error('Error fetching data:', error);
|
| 347 |
+
throw error; // Lempar ulang error untuk ditangani di level atas
|
| 348 |
+
}
|
| 349 |
+
}
|
| 350 |
+
|
| 351 |
+
|
| 352 |
+
|
| 353 |
async function Rules34info(url_r34) {
|
| 354 |
try {
|
| 355 |
// Mengambil halaman HTML dengan Axios
|
|
|
|
| 495 |
}
|
| 496 |
}
|
| 497 |
|
| 498 |
+
|
| 499 |
app.get('/r34', async (req, res) => {
|
| 500 |
const { url } = req.query;
|
| 501 |
if (!url) {
|
|
|
|
| 598 |
return res.status(400).send('URL is required');
|
| 599 |
}
|
| 600 |
try {
|
| 601 |
+
const result = await Rules34Infonues(url);
|
| 602 |
res.json(result);
|
| 603 |
} catch (error) {
|
| 604 |
res.status(500).send('Error processing request');
|