darkvibe314 commited on
Commit
0010c04
·
verified ·
1 Parent(s): f195634

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +12 -5
index.js CHANGED
@@ -1,5 +1,5 @@
1
  const express = require("express");
2
- const snapsave = require("snapsave-downloader2");
3
  const app = express();
4
 
5
  app.get("/", (req, res) => res.send("Silent Tech IG Downloader Online"));
@@ -7,13 +7,20 @@ app.get("/", (req, res) => res.send("Silent Tech IG Downloader Online"));
7
  app.get("/igdl", async (req, res) => {
8
  try {
9
  const url = req.query.url;
10
- if (!url) return res.status(400).json({ error: "URL is missing" });
 
 
 
 
 
 
 
 
11
 
12
- const result = await snapsave(url);
13
- res.json(result);
14
  } catch (err) {
15
- res.status(500).json({ error: err.message });
16
  }
17
  });
18
 
 
19
  app.listen(7860, () => console.log("Server running on port 7860"));
 
1
  const express = require("express");
2
+ const igdl = require("@sasmeee/igdl");
3
  const app = express();
4
 
5
  app.get("/", (req, res) => res.send("Silent Tech IG Downloader Online"));
 
7
  app.get("/igdl", async (req, res) => {
8
  try {
9
  const url = req.query.url;
10
+ if (!url) {
11
+ return res.status(400).json({ error: "URL is missing" });
12
+ }
13
+
14
+ // The library returns an array of media objects (supports carousels!)
15
+ const result = await igdl(url);
16
+
17
+ // Send the raw JSON result back to the browser/bot
18
+ res.json({ success: true, data: result });
19
 
 
 
20
  } catch (err) {
21
+ res.status(500).json({ success: false, error: err.message });
22
  }
23
  });
24
 
25
+ // Hugging Face strictly requires apps to run on port 7860
26
  app.listen(7860, () => console.log("Server running on port 7860"));