blob: 0a3a4d7bddb9c2887266faee46ad2dfa485890ff (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
import withSession from 'hocs/withSession'
import ytdl from '@distube/ytdl-core'
export default withSession(async (req, res) => {
switch (req.method) {
case 'POST':
try {
const user = req.session.get('user')
const { id } = req.body
if (!user || !user?.isVerified || !id) {
throw new Error('Something went wrong')
}
const info = await ytdl.getInfo(id, { lang: user.language || 'en' })
res.status(200).json(info)
} catch (error) {
console.log(error)
res.status(400).send()
}
break
default:
res.status(400).send()
break
}
})
|