Nexchan commited on
Commit
5d6a460
·
verified ·
1 Parent(s): 1c7b818

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +21 -1
index.js CHANGED
@@ -246,6 +246,15 @@ app.get('/nhentai', async (req, res) => {
246
  try {
247
  const result = await nhentai(url);
248
  res.json(result);
 
 
 
 
 
 
 
 
 
249
  } catch (error) {
250
  res.status(500).send('Error processing request');
251
  }
@@ -315,7 +324,7 @@ async function Rules34(url_r34) {
315
  // Mendownload dari URL terakhir di array download
316
  const lastDownloadUrl = result.download[result.download.length - 1].url;
317
  const downloadPath = path.resolve(os.tmpdir())
318
- let filenem = `/${Date.now()}_file.mp4`
319
  const filePath = path.join(downloadPath, filenem)
320
 
321
  await downloadFromUrl(lastDownloadUrl, filePath);
@@ -360,6 +369,17 @@ app.get('/r34', async (req, res) => {
360
  try {
361
  const result = await Rules34(url);
362
  res.json(result);
 
 
 
 
 
 
 
 
 
 
 
363
  } catch (error) {
364
  res.status(500).send('Error processing request');
365
  }
 
246
  try {
247
  const result = await nhentai(url);
248
  res.json(result);
249
+ setTimeout(() => {
250
+ fs.unlink(result.path, (err) => {
251
+ if (err) {
252
+ console.error(`Error deleting file: ${err.message}`);
253
+ } else {
254
+ console.log(`File deleted: ${filePath}`);
255
+ }
256
+ });
257
+ }, 480000);
258
  } catch (error) {
259
  res.status(500).send('Error processing request');
260
  }
 
324
  // Mendownload dari URL terakhir di array download
325
  const lastDownloadUrl = result.download[result.download.length - 1].url;
326
  const downloadPath = path.resolve(os.tmpdir())
327
+ let filenem = `${Date.now()}_file.mp4`
328
  const filePath = path.join(downloadPath, filenem)
329
 
330
  await downloadFromUrl(lastDownloadUrl, filePath);
 
369
  try {
370
  const result = await Rules34(url);
371
  res.json(result);
372
+ const filePath = result.downloadPath;
373
+ // Hapus file setelah 8 menit (480000 milidetik)
374
+ setTimeout(() => {
375
+ fs.unlink(filePath, (err) => {
376
+ if (err) {
377
+ console.error(`Error deleting file: ${err.message}`);
378
+ } else {
379
+ console.log(`File deleted: ${filePath}`);
380
+ }
381
+ });
382
+ }, 480000);
383
  } catch (error) {
384
  res.status(500).send('Error processing request');
385
  }