wudysoft commited on
Commit
328fdd3
·
verified ·
1 Parent(s): 3e35521

Update app.js

Browse files
Files changed (1) hide show
  1. app.js +7 -1
app.js CHANGED
@@ -188,10 +188,16 @@ app.get('/ytdl/v2', async (req, res) => {
188
  .split('\n')
189
  .map(line => line.trim().substring(5).trim())
190
  .filter(Boolean);
 
 
 
 
 
 
191
 
192
  if (!lastLine) return res.status(404).json({ error: 'No valid data found.' });
193
 
194
- res.json({ data: lastLine });
195
  } catch (error) {
196
  console.error(error);
197
  res.status(500).json({ error: 'Something went wrong while processing the request.' });
 
188
  .split('\n')
189
  .map(line => line.trim().substring(5).trim())
190
  .filter(Boolean);
191
+ const extractDownloadLinks = (data) => {
192
+ return [...new Set(data.flatMap(item => {
193
+ const $ = cheerio.load(item);
194
+ return $("a[href^='/download/']").map((_, el) => "https://ytdlp.online" + $(el).attr("href")).get();
195
+ }))];
196
+ };
197
 
198
  if (!lastLine) return res.status(404).json({ error: 'No valid data found.' });
199
 
200
+ res.json({ data: extractDownloadLinks(lastLine) });
201
  } catch (error) {
202
  console.error(error);
203
  res.status(500).json({ error: 'Something went wrong while processing the request.' });