diff options
author | 2021-09-19 12:47:21 +0200 | |
---|---|---|
committer | 2021-09-19 12:47:21 +0200 | |
commit | 865c9cc345aa105714dfe3ccf1d1c0a9a6a75f7f (patch) | |
tree | 2dd4935ae03b084570c003eb0c004022e9a99de3 /pages/api/youtube/playlist.js | |
parent | bb22276b9bdfdb23da313a5495dc4f3fcdb3bb09 (diff) | |
download | my_apps-865c9cc345aa105714dfe3ccf1d1c0a9a6a75f7f.tar.gz my_apps-865c9cc345aa105714dfe3ccf1d1c0a9a6a75f7f.tar.bz2 my_apps-865c9cc345aa105714dfe3ccf1d1c0a9a6a75f7f.zip |
youtube & player apps fixes
Diffstat (limited to 'pages/api/youtube/playlist.js')
-rw-r--r-- | pages/api/youtube/playlist.js | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/pages/api/youtube/playlist.js b/pages/api/youtube/playlist.js new file mode 100644 index 0000000..e75e00d --- /dev/null +++ b/pages/api/youtube/playlist.js @@ -0,0 +1,26 @@ +import withSession from 'hocs/withSession' +import ytpl from 'ytpl' + +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 ytpl(id, { gl: user.language || 'en' }) + + res.status(200).json(info) + } catch (error) { + res.status(400).json([]) + } + break + default: + res.status(400).send() + break + } +}) |