Update index.js
Browse files
index.js
CHANGED
|
@@ -193,26 +193,22 @@ async function fby2mate(url) {
|
|
| 193 |
}
|
| 194 |
|
| 195 |
//YTDL-CORE
|
| 196 |
-
async function uploadBuffer(
|
| 197 |
-
|
| 198 |
-
let
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
}
|
| 212 |
-
} catch (error) {
|
| 213 |
-
return null
|
| 214 |
}
|
| 215 |
-
}
|
| 216 |
async function streamToBuffer(stream) {
|
| 217 |
const chunks = [];
|
| 218 |
const captureChunks = new Writable({
|
|
|
|
| 193 |
}
|
| 194 |
|
| 195 |
//YTDL-CORE
|
| 196 |
+
async function uploadBuffer(media) {
|
| 197 |
+
return new Promise(async (resolve, reject) => {
|
| 198 |
+
let {fileTypeFromBuffer} = await (await import('file-type'))
|
| 199 |
+
let mime = await fileTypeFromBuffer(media)
|
| 200 |
+
let form = new FormData()
|
| 201 |
+
|
| 202 |
+
form.append("files[]", media, `file-${new Date().getTime()}.${mime.ext}`)
|
| 203 |
+
|
| 204 |
+
axios.post("https://pomf.lain.la/upload.php", form, {
|
| 205 |
+
headers: {
|
| 206 |
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 Edg/119.0.0.0",
|
| 207 |
+
...form.getHeaders()
|
| 208 |
+
}
|
| 209 |
+
}).then(({ data }) => resolve(data?.files[0]?.url)).catch(reject(null))
|
| 210 |
+
})
|
|
|
|
|
|
|
|
|
|
| 211 |
}
|
|
|
|
| 212 |
async function streamToBuffer(stream) {
|
| 213 |
const chunks = [];
|
| 214 |
const captureChunks = new Writable({
|