Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
jajbshjahavahh
GitHub Repository: jajbshjahavahh/Gojo-Satoru
Path: blob/master/lib/uploader.js
2591 views
1
//═══════════════════════════════════════════════════════//
2
//If you want to recode, reupload
3
//or copy the codes/script,
4
//pls give credit
5
//no credit? i will take action immediately
6
//© 2022 Xeon Bot Inc. Cheems Bot MD
7
//Thank you to Lord Buddha, Family and Myself
8
//════════════════════════════//
9
let axios = require('axios')
10
let BodyForm = require('form-data')
11
let { fromBuffer } = require('file-type')
12
let fetch = require('node-fetch')
13
let fs = require('fs')
14
let cheerio = require('cheerio')
15
16
17
18
function TelegraPh (Path) {
19
return new Promise (async (resolve, reject) => {
20
if (!fs.existsSync(Path)) return reject(new Error("File not Found"))
21
try {
22
const form = new BodyForm();
23
form.append("file", fs.createReadStream(Path))
24
const data = await axios({
25
url: "https://telegra.ph/upload",
26
method: "POST",
27
headers: {
28
...form.getHeaders()
29
},
30
data: form
31
})
32
return resolve("https://telegra.ph" + data.data[0].src)
33
} catch (err) {
34
return reject(new Error(String(err)))
35
}
36
})
37
}
38
39
async function UploadFileUgu (input) {
40
return new Promise (async (resolve, reject) => {
41
const form = new BodyForm();
42
form.append("files[]", fs.createReadStream(input))
43
await axios({
44
url: "https://uguu.se/upload.php",
45
method: "POST",
46
headers: {
47
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36",
48
...form.getHeaders()
49
},
50
data: form
51
}).then((data) => {
52
resolve(data.data.files[0])
53
}).catch((err) => reject(err))
54
})
55
}
56
57
function webp2mp4File(path) {
58
return new Promise((resolve, reject) => {
59
const form = new BodyForm()
60
form.append('new-image-url', '')
61
form.append('new-image', fs.createReadStream(path))
62
axios({
63
method: 'post',
64
url: 'https://s6.ezgif.com/webp-to-mp4',
65
data: form,
66
headers: {
67
'Content-Type': `multipart/form-data; boundary=${form._boundary}`
68
}
69
}).then(({ data }) => {
70
const bodyFormThen = new BodyForm()
71
const $ = cheerio.load(data)
72
const file = $('input[name="file"]').attr('value')
73
bodyFormThen.append('file', file)
74
bodyFormThen.append('convert', "Convert WebP to MP4!")
75
axios({
76
method: 'post',
77
url: 'https://ezgif.com/webp-to-mp4/' + file,
78
data: bodyFormThen,
79
headers: {
80
'Content-Type': `multipart/form-data; boundary=${bodyFormThen._boundary}`
81
}
82
}).then(({ data }) => {
83
const $ = cheerio.load(data)
84
const result = 'https:' + $('div#output > p.outfile > video > source').attr('src')
85
resolve({
86
status: true,
87
message: "Created By MRHRTZ",
88
result: result
89
})
90
}).catch(reject)
91
}).catch(reject)
92
})
93
}
94
95
module.exports = { TelegraPh, UploadFileUgu, webp2mp4File }
96
97