File size: 3,773 Bytes
44cdc52
 
 
 
 
fc22737
 
44cdc52
 
9ef279c
fc22737
0e6ea55
 
 
44cdc52
 
 
 
 
0e6ea55
44cdc52
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0e6ea55
44cdc52
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0e6ea55
44cdc52
0e6ea55
44cdc52
 
0e6ea55
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44cdc52
0e6ea55
 
 
 
44cdc52
678d8dd
bb616dd
 
 
0e6ea55
 
 
 
bb616dd
44cdc52
0e6ea55
fc22737
 
0e6ea55
 
fc22737
 
 
 
 
 
44cdc52
 
 
 
 
 
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
import { config } from 'dotenv'
config()
import express from 'express'
import cors from 'cors'
import axios from 'axios'
import { rateLimit } from 'express-rate-limit'

const app = express()
const port = process.env.SERVER_PORT || process.env.SERVER_PORT || 7860
// import {exec} from 'child_process'
const link_twt = "https://raw.githubusercontent.com/Epikcoder/aru/main/twt.json"
let twt_data = await axios.get(link_twt).then(r => r.data)
const link_ig = "https://raw.githubusercontent.com/Epikcoder/aru/main/ig.json"
let ig_data = await axios.get(link_ig).then(r => r.data)
app.use(cors())
app.get("/video", async(req,res) => {
  let c = "" //get random data
  let url = "";
  function check() {
    c = twt_data[Math.floor(Math.random() * twt_data.length)].split("|")
    url = c[2]
    if (!url.includes("?tag=")) {
      check()
    }

  }
  check()

  const response = await axios({
    method: 'GET',
    url: url,
    responseType: 'stream'
  });

  res.setHeader('Content-Disposition', 'inline');
  res.setHeader('Content-Type', response.headers['content-type']);

  response.data.pipe(res);
})

app.get('/image',async(req,res)=>{
  let c = "" //get random data
  let url = "";
  function check() {
    c = twt_data[Math.floor(Math.random() * twt_data.length)].split("|")
    url = c[2]
    if (url.includes("?tag=")) {
      check()
    }

  }
  check()
  // Set custom headers
  res.set("X-fetchedurl", c[2]); // fetch url
  res.set("X-fetchedurlid", c[1]); // give vid id
  res.set("X-fetchedurlname", c[0]); // give vid author name


  // Image or non-range video request
  const response = await axios({
    method: 'GET',
    url: url,
    responseType: 'stream'
  });

  res.setHeader('Content-Disposition', 'inline');
  res.setHeader('Content-Type', response.headers['content-type']);

  response.data.pipe(res);
})

app.get("/api", (req,res) => {
  const a = twt_data[Math.floor(Math.random() * twt_data.length)].split("|")
  res.json({ "urllink": a[2], "id": a[1], "name": a[0]  })
})
app.get("/video", async(req,res) => {
  let c = "" //get random data
  let url = "";
  function check() {
    c = ig_data[Math.floor(Math.random() * ig_data.length)]
    url = c
    if (!url.includes(".mp4")) {
      check()
    }

  }
  check()

  const response = await axios({
    method: 'GET',
    url: url,
    responseType: 'stream'
  });

  res.setHeader('Content-Disposition', 'inline');
  res.setHeader('Content-Type', response.headers['content-type']);

  response.data.pipe(res);
})

app.get('/igimage',async(req,res)=>{
  let c = "" //get random data
  let url = "";
  function check() {
    c = ig_data[Math.floor(Math.random() * ig_data.length)]
    url = c
    if (url.includes(".mp4")) {
      check()
    }

  }
  check()

  const response = await axios({
    method: 'GET',
    url: url,
    responseType: 'stream'
  });

  res.setHeader('Content-Disposition', 'inline');
  res.setHeader('Content-Type', response.headers['content-type']);

  response.data.pipe(res);
})

app.get("/igapi", (req,res) => {
  const a = ig_data[Math.floor(Math.random() * ig_data.length)]
  res.json({ "urllink": a  })
})
app.get("/", async (req, res) => {
  const murl = req.headers["x-vercel-deployment-url"] || req.headers.referrer || req.headers.host
  res.json({madeBy: "@EpikCoder", mainurl: murl, routes: [
    murl + "/image",
    murl + "/api",
    murl + "/video",
    murl + "/igimage",
    murl + "/igapi",
    murl + "/igvideo"
  ]})
})

app.get("/updb", async(req,res)=> {
  const {data} = await axios.get(link_twt)
  if(data.length != twt_data.length) {
    twt_data = data;
    return res.send("updb")
  } else{
    
    res.send("up to date")
  }
})

app.listen(port, () => {
  console.log(`Example app listening on port ${port}`)
})

export default app