fast72 commited on
Commit
99174cb
·
verified ·
1 Parent(s): d01810a

Upload 3 files

Browse files
Files changed (3) hide show
  1. Dockerfile +7 -0
  2. index.js +32 -0
  3. package.json +10 -0
Dockerfile ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ FROM node:latest
2
+ WORKDIR /app
3
+ COPY package*.json ./
4
+ RUN npm install
5
+ COPY . .
6
+ EXPOSE 8080
7
+ CMD ["node", "index.js"]
index.js ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const express = require("express");
2
+ const { notube, tiktok, instagram, threads } = require('./lib/yt.js');
3
+
4
+ const app = express();
5
+ app.use(express.json());
6
+ app.set('json spaces', 4);
7
+
8
+ app.all('/dl/start', async (req, res) => {
9
+ const { url, typeYT = 'mp3' } = req.query || req.body;
10
+ if(/^https?:\/\/(?:www\.)?(?:youtube\.com\/(?:embed\/|v\/|watch\?v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/.test(url)) {
11
+ if(!['mp3', 'mp4'].includes(typeYT)) return res.json({ status: false, r: 'invalid type, use mp3 or mp4.' });
12
+ const ytr = await notube(url, typeYT, 'id', 'false');
13
+ res.json({ status: true, ...ytr });
14
+ } else if(/^https?:\/\/(?:www\.)?(?:twitter|x)\.com\/(?:i\/web\/status|[^\/]+\/status)\/(\d+)/.test(url)) {
15
+ const xr = await notube(url, 'mp4', 'id', 'false');
16
+ res.json({ status: true, ...xr });
17
+ } else if(/^https?:\/\/(?:www\.)?(?:tiktok\.com\/(?:@[^\/]+\/video|t)\/|vt\.tiktok\.com\/)([a-zA-Z0-9]+)/.test(url)) {
18
+ const ttr = await tiktok(url);
19
+ res.json(ttr);
20
+ } else if(/^https?:\/\/(?:www\.)?instagram\.com\/(?:reel|p|tv)\/([a-zA-Z0-9_-]+)/.test(url)) {
21
+ const igr = await instagram(url);
22
+ res.json({ status: true, ...igr });
23
+ } else if(/^https?:\/\/(?:www\.)?facebook\.com\/(?:watch\/\?v=|reels\/|[^\/]+\/videos\/)(\d+)/.test(url)) {
24
+
25
+ } else if(/^https?:\/\/(?:www\.)?threads\.net\/@[^\/]+\/post\/([a-zA-Z0-9_-]+)/.test(url)) {
26
+ const thr = await threads(url);
27
+ res.json(thr);
28
+ }
29
+ });
30
+
31
+ const PORT = 8080;
32
+ app.listen(PORT, () => console.log(`Server running on port ${PORT}`));
package.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "main": "index.js",
3
+ "scripts": {
4
+ "start": "node index.js"
5
+ },
6
+ "dependencies": {
7
+ "express": "*",
8
+ "axios": "*"
9
+ }
10
+ }