Khrisna commited on
Commit
7dd38d4
·
verified ·
1 Parent(s): 0a0f0b5

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +3 -3
index.js CHANGED
@@ -423,9 +423,9 @@ app.post('/api/youtube/info', async (req, res) => {
423
  if (!status) return res.json({ success: false, message: 'Required an status text!' })
424
 
425
  if(status !== apikey) return res.json({ success: false, message: 'Invalid status!' })
426
- if (!url.split(/https:\/\/(?:youtube\.com\/(?:shorts\/|watch\?v=|watch\?v=|watch\?v=)|youtu\.be\/)([\w-]+)/)[1]) return res.json({ success: false, message: 'Id Video Not Found!!!' })
427
- const regex = url.split(/https:\/\/(?:youtube\.com\/(?:shorts\/|watch\?v=|watch\?v=|watch\?v=)|youtu\.be\/)([\w-]+)/)[1]
428
- const response = await ytdl.getInfo(regex)
429
  res.json({
430
  status: "ok",
431
  result: { ...response }
 
423
  if (!status) return res.json({ success: false, message: 'Required an status text!' })
424
 
425
  if(status !== apikey) return res.json({ success: false, message: 'Invalid status!' })
426
+ const videoID = ytdl.getVideoID(url)
427
+ if (!videoID) return res.json({ success: false, message: 'Id Video Not Found!!!' })
428
+ const response = await ytdl.getInfo(videoID)
429
  res.json({
430
  status: "ok",
431
  result: { ...response }