This repository has been archived by the owner on Aug 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
/
index.js
97 lines (93 loc) · 1.92 KB
/
index.js
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import express from "express";
import axios from "axios";
import bodyParser from "body-parser";
import path from "path";
const __dirname = path.resolve();
const app = express();
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
const port = process.env.PORT || 3000;
const ssyoutube = async (url) => {
const res = await axios.post("https://ssyoutube.com/api/convert", {
url: url,
});
return res.data;
};
app.get("/", function (req, res) {
res.sendFile(path.join(__dirname + "/index.html"));
});
app.get("/api", function (req, res) {
res.sendFile(path.join(__dirname + "/index.html"));
});
app.get("/api/youtube", async (req, res) => {
const url = req.query.url;
try {
const data = await ssyoutube(url);
res.json({
"status": true,
"result": data
})
} catch{
res.json({
"status": false,
})
}
});
app.get("/api/tiktok", async (req, res) => {
const url = req.query.url;
try {
const data = await ssyoutube(url);
res.json({
"status": true,
"result": data
})
} catch{
res.json({
"status": false,
})
}
});
app.get("/api/twitter", async (req, res) => {
const url = req.query.url;
try {
const data = await ssyoutube(url);
res.json({
"status": true,
"result": data
})
} catch{
res.json({
"status": false,
})
}
});
app.get("/api/facebook", async (req, res) => {
const url = req.query.url;
try {
const data = await ssyoutube(url);
res.json({
"status": true,
"result": data
})
} catch{
res.json({
"status": false,
})
}
});
app.get("/api/instagram", async (req, res) => {
const url = req.query.url;
try {
const data = await ssyoutube(url);
res.json({
"status": true,
"result": data
})
} catch{
res.json({
"status": false,
})
}
});
app.listen(port);
console.log(`Server running on port ${port}`);