scnario commited on
Commit
47cf320
·
verified ·
1 Parent(s): b40dc1c

Update server.js

Browse files
Files changed (1) hide show
  1. server.js +49 -1
server.js CHANGED
@@ -2,6 +2,8 @@ const express = require("express");
2
  const axios = require("axios");
3
  const path = require("path");
4
  const cheerio = require('cheerio');
 
 
5
  const app = express();
6
  app.set('json spaces', 4);
7
  const PORT = 7860;
@@ -77,9 +79,55 @@ const ttdl = async(url) => {
77
  return { play: data.data.play, hd: data.data.hdplay }
78
  }
79
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  app.all("/", async (req, res) => {
81
  const { url } = req.query || req.body;
82
- if(/^(https?:\/\/)?(www\.)?instagram\.com\/(p|reel)\/.+/i.test(url)) res.json(await yt5sIo(url)) // instagram
83
  if(/^(https?:\/\/)?(www\.)?(facebook\.com|fb\.watch)\/.+/i.test(url)) res.json(await yt5sIo(url)) // fesnuk
84
  if(/(?:https?:)?(?:\/\/)?(?:[0-9A-Z-]+\.)?(?:youtu\.be\/|youtube(?:-nocookie)?\.com\S*?[^\w\s-])([\w-]{11})(?=[^\w-]|$)(?![?=&+%\w.-]*(?:['"][^<>]*>|<\/a>))[?=&+%\w.-]*/gim.test(url)) res.json(await ytdl(url)) // yt
85
  if(/https?:\/\/(?:www|m|vt)\.tiktok\.com\//gi.test(url)) res.json(await ttdl(url)) // tiktok
 
2
  const axios = require("axios");
3
  const path = require("path");
4
  const cheerio = require('cheerio');
5
+ const FormData = require('form-data');
6
+
7
  const app = express();
8
  app.set('json spaces', 4);
9
  const PORT = 7860;
 
79
  return { play: data.data.play, hd: data.data.hdplay }
80
  }
81
 
82
+ const snapinst = {
83
+ async app(url) {
84
+ const { data } = await axios.get('https://snapinst.app/');
85
+ const $ = cheerio.load(data);
86
+ const form = new FormData();
87
+
88
+ form.append('url', url);
89
+ form.append('action', 'post');
90
+ form.append('lang', '');
91
+ form.append('cf-turnstile-response', '');
92
+ form.append('token', $('input[name=token]').attr('value'));
93
+
94
+ const headers = {
95
+ ...form.getHeaders(),
96
+ 'accept': '*/*',
97
+ 'accept-language': 'id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7',
98
+ 'sec-ch-ua': '"Not A(Brand";v="8", "Chromium";v="132"',
99
+ 'sec-ch-ua-mobile': '?1',
100
+ 'sec-ch-ua-platform': '"Android"',
101
+ 'sec-fetch-dest': 'empty',
102
+ 'sec-fetch-mode': 'cors',
103
+ 'sec-fetch-site': 'same-origin',
104
+ 'Referer': 'https://snapinst.app/',
105
+ 'Referrer-Policy': 'strict-origin-when-cross-origin'
106
+ };
107
+
108
+ const jsbejad = await axios.post('https://snapinst.app/action2.php', form, { headers });
109
+ const ayok = new Function('callbuk', jsbejad.data.replace('eval', 'callbuk'));
110
+
111
+ const html = await new Promise((resolve, reject) => {
112
+ ayok(t=>{
113
+ const code = t.split(".innerHTML = ")[1].split("; document.")[0];
114
+ resolve(eval(code));
115
+ });
116
+ });
117
+
118
+ const _ = cheerio.load(html);
119
+ const res = [];
120
+ _('.row .download-item').each((i, e)=>{
121
+ res.push(_(e).find('.download-bottom a').attr('href'));
122
+ });
123
+
124
+ return res
125
+ },
126
+ };
127
+
128
  app.all("/", async (req, res) => {
129
  const { url } = req.query || req.body;
130
+ if(/^(https?:\/\/)?(www\.)?instagram\.com\/(p|reel)\/.+/i.test(url)) res.json(await snapinst.app(url)) // instagram
131
  if(/^(https?:\/\/)?(www\.)?(facebook\.com|fb\.watch)\/.+/i.test(url)) res.json(await yt5sIo(url)) // fesnuk
132
  if(/(?:https?:)?(?:\/\/)?(?:[0-9A-Z-]+\.)?(?:youtu\.be\/|youtube(?:-nocookie)?\.com\S*?[^\w\s-])([\w-]{11})(?=[^\w-]|$)(?![?=&+%\w.-]*(?:['"][^<>]*>|<\/a>))[?=&+%\w.-]*/gim.test(url)) res.json(await ytdl(url)) // yt
133
  if(/https?:\/\/(?:www|m|vt)\.tiktok\.com\//gi.test(url)) res.json(await ttdl(url)) // tiktok