scnario commited on
Commit
48866f9
·
verified ·
1 Parent(s): 4aa7c6c

Update server.js

Browse files
Files changed (1) hide show
  1. server.js +10 -7
server.js CHANGED
@@ -2,14 +2,17 @@ const axios = require('axios');
2
  const express = require('express');
3
  const { snapsave } = require('snapsave-media-downloader');
4
 
5
- const app = express()
6
 
7
- app.get('/', async(req, res) => {
8
- const { url } = req.body || req.query
9
- if(/(?:(?:http|https):\/\/)?(?:www.)?(?:instagram.com|instagr.am|instagr.com)\/(\w+)/.test(url) || /(?:(?:www\.facebook\.com\/(?:(?:(?:video\.php)|(?:watch\/))\?v=\d+|(?:[0-9a-zA-Z-_.]+\/(?:(?:video|(post|photo))(?:s))\/)(?:[0-9a-zA-Z-_.]+(?:\/\d+)*)))|(?:fb\.watch\/(?:\w|-)+)\/?)/gi.test(url) || /https?:\/\/(?:www|m|vt|vm)\.tiktok\.com\/(?:v|embed|trending)\/?(?:\?shareId=)?(?P<id>[\da-z]+)/gi.test(url)) { // ig, tt, fb
10
- const resu = await snapsave(url)
11
- res.json(resu)
 
 
 
12
  }
13
  });
14
 
15
- app.listen(7860)
 
2
  const express = require('express');
3
  const { snapsave } = require('snapsave-media-downloader');
4
 
5
+ const app = express();
6
 
7
+ app.get('/', async (req, res) => {
8
+ const { url } = req.body || req.query;
9
+ if (/https?:\/\/(?:www\.)?(instagram\.com|instagr\.am|instagr\.com)\/\w+/.test(url) ||
10
+ /https?:\/\/(?:www\.facebook\.com\/(?:video\.php\?v=\d+|watch\/\d+|[0-9a-zA-Z-_.]+\/(?:video|post|photo)s?\/\d+))|fb\.watch\/\w+/i.test(url) ||
11
+ /https?:\/\/(?:www|m|vt|vm)\.tiktok\.com\/(?:v|embed|trending)\/?(\?shareId=\w+)?/i.test(url)) {
12
+ res.json(await snapsave(url));
13
+ } else {
14
+ res.status(400).json({ error: 'Invalid URL' });
15
  }
16
  });
17
 
18
+ app.listen(7860);