Epikcoder commited on
Commit
0e6ea55
·
1 Parent(s): fc22737
Files changed (1) hide show
  1. api/index.js +67 -20
api/index.js CHANGED
@@ -9,13 +9,15 @@ const app = express()
9
  const port = process.env.SERVER_PORT || process.env.SERVER_PORT || 7860
10
  // import {exec} from 'child_process'
11
  const link_twt = "https://raw.githubusercontent.com/Epikcoder/aru/main/twt.json"
12
- let dat2a = await axios.get(link_twt).then(r => r.data)
 
 
13
  app.use(cors())
14
  app.get("/video", async(req,res) => {
15
  let c = "" //get random data
16
  let url = "";
17
  function check() {
18
- c = dat2a[Math.floor(Math.random() * dat2a.length)].split("|")
19
  url = c[2]
20
  if (!url.includes("?tag=")) {
21
  check()
@@ -23,13 +25,7 @@ app.get("/video", async(req,res) => {
23
 
24
  }
25
  check()
26
- // Set custom headers
27
- // res.set("X-fetchedurl", c[2]); // fetch url
28
- // res.set("X-fetchedurlid", c[1]); // give vid id
29
- // res.set("X-fetchedurlname", c[0]); // give vid author name
30
-
31
 
32
- // Image or non-range video request
33
  const response = await axios({
34
  method: 'GET',
35
  url: url,
@@ -46,7 +42,7 @@ app.get('/image',async(req,res)=>{
46
  let c = "" //get random data
47
  let url = "";
48
  function check() {
49
- c = dat2a[Math.floor(Math.random() * dat2a.length)].split("|")
50
  url = c[2]
51
  if (url.includes("?tag=")) {
52
  check()
@@ -72,30 +68,81 @@ app.get('/image',async(req,res)=>{
72
 
73
  response.data.pipe(res);
74
  })
 
75
  app.get("/api", (req,res) => {
76
- const a = dat2a[Math.floor(Math.random() * dat2a.length)].split("|")
77
  res.json({ "urllink": a[2], "id": a[1], "name": a[0] })
78
  })
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
 
 
 
 
 
80
  app.get("/", async (req, res) => {
81
  const murl = req.headers["x-vercel-deployment-url"] || req.headers.referrer || req.headers.host
82
  res.json({madeBy: "@EpikCoder", mainurl: murl, routes: [
83
  murl + "/image",
84
  murl + "/api",
85
- murl + "/video"
 
 
 
86
  ]})
87
  })
88
- // app.use("/updb", rateLimit({
89
- // windowMs: 15 * 60 * 1000, // 15 minutes
90
- // limit: 100, // Limit each IP to 100 requests per `window` (here, per 15 minutes).
91
- // standardHeaders: 'draft-7', // draft-6: `RateLimit-*` headers; draft-7: combined `RateLimit` header
92
- // legacyHeaders: false, // Disable the `X-RateLimit-*` headers.
93
- // // store: ... , // Redis, Memcached, etc. See below.
94
- // }))
95
  app.get("/updb", async(req,res)=> {
96
  const {data} = await axios.get(link_twt)
97
- if(data.length != dat2a.length) {
98
- dat2a = data;
99
  return res.send("updb")
100
  } else{
101
 
 
9
  const port = process.env.SERVER_PORT || process.env.SERVER_PORT || 7860
10
  // import {exec} from 'child_process'
11
  const link_twt = "https://raw.githubusercontent.com/Epikcoder/aru/main/twt.json"
12
+ let twt_data = await axios.get(link_twt).then(r => r.data)
13
+ const link_ig = "https://raw.githubusercontent.com/Epikcoder/aru/main/ig.json"
14
+ let ig_data = await axios.get(link_ig).then(r => r.data)
15
  app.use(cors())
16
  app.get("/video", async(req,res) => {
17
  let c = "" //get random data
18
  let url = "";
19
  function check() {
20
+ c = twt_data[Math.floor(Math.random() * twt_data.length)].split("|")
21
  url = c[2]
22
  if (!url.includes("?tag=")) {
23
  check()
 
25
 
26
  }
27
  check()
 
 
 
 
 
28
 
 
29
  const response = await axios({
30
  method: 'GET',
31
  url: url,
 
42
  let c = "" //get random data
43
  let url = "";
44
  function check() {
45
+ c = twt_data[Math.floor(Math.random() * twt_data.length)].split("|")
46
  url = c[2]
47
  if (url.includes("?tag=")) {
48
  check()
 
68
 
69
  response.data.pipe(res);
70
  })
71
+
72
  app.get("/api", (req,res) => {
73
+ const a = twt_data[Math.floor(Math.random() * twt_data.length)].split("|")
74
  res.json({ "urllink": a[2], "id": a[1], "name": a[0] })
75
  })
76
+ app.get("/video", async(req,res) => {
77
+ let c = "" //get random data
78
+ let url = "";
79
+ function check() {
80
+ c = ig_data[Math.floor(Math.random() * ig_data.length)]
81
+ url = c
82
+ if (!url.includes(".mp4")) {
83
+ check()
84
+ }
85
+
86
+ }
87
+ check()
88
+
89
+ const response = await axios({
90
+ method: 'GET',
91
+ url: url,
92
+ responseType: 'stream'
93
+ });
94
+
95
+ res.setHeader('Content-Disposition', 'inline');
96
+ res.setHeader('Content-Type', response.headers['content-type']);
97
+
98
+ response.data.pipe(res);
99
+ })
100
+
101
+ app.get('/igimage',async(req,res)=>{
102
+ let c = "" //get random data
103
+ let url = "";
104
+ function check() {
105
+ c = ig_data[Math.floor(Math.random() * ig_data.length)]
106
+ url = c
107
+ if (url.includes(".mp4")) {
108
+ check()
109
+ }
110
+
111
+ }
112
+ check()
113
+
114
+ const response = await axios({
115
+ method: 'GET',
116
+ url: url,
117
+ responseType: 'stream'
118
+ });
119
+
120
+ res.setHeader('Content-Disposition', 'inline');
121
+ res.setHeader('Content-Type', response.headers['content-type']);
122
+
123
+ response.data.pipe(res);
124
+ })
125
 
126
+ app.get("/igapi", (req,res) => {
127
+ const a = ig_data[Math.floor(Math.random() * ig_data.length)]
128
+ res.json({ "urllink": a })
129
+ })
130
  app.get("/", async (req, res) => {
131
  const murl = req.headers["x-vercel-deployment-url"] || req.headers.referrer || req.headers.host
132
  res.json({madeBy: "@EpikCoder", mainurl: murl, routes: [
133
  murl + "/image",
134
  murl + "/api",
135
+ murl + "/video",
136
+ murl + "/igimage",
137
+ murl + "/igapi",
138
+ murl + "/igvideo"
139
  ]})
140
  })
141
+
 
 
 
 
 
 
142
  app.get("/updb", async(req,res)=> {
143
  const {data} = await axios.get(link_twt)
144
+ if(data.length != twt_data.length) {
145
+ twt_data = data;
146
  return res.send("updb")
147
  } else{
148