Update index.js
Browse files
index.js
CHANGED
|
@@ -195,20 +195,26 @@ async function fby2mate(url) {
|
|
| 195 |
//YTDL-CORE
|
| 196 |
async function uploadBuffer(media) {
|
| 197 |
return new Promise(async (resolve, reject) => {
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 212 |
async function streamToBuffer(stream) {
|
| 213 |
const chunks = [];
|
| 214 |
const captureChunks = new Writable({
|
|
|
|
| 195 |
//YTDL-CORE
|
| 196 |
async function uploadBuffer(media) {
|
| 197 |
return new Promise(async (resolve, reject) => {
|
| 198 |
+
try {
|
| 199 |
+
let {fileTypeFromBuffer} = await (await import('file-type'))
|
| 200 |
+
let mime = await fileTypeFromBuffer(media);
|
| 201 |
+
let form = new FormData();
|
| 202 |
+
form.append("files[]", media, `file-${new Date().getTime()}.${mime.ext}`);
|
| 203 |
+
|
| 204 |
+
let response = await 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 |
+
});
|
| 210 |
+
|
| 211 |
+
resolve(response.data?.files[0]?.url || null);
|
| 212 |
+
} catch (error) {
|
| 213 |
+
console.error(error);
|
| 214 |
+
resolve(null); // Ensure null is returned if there's an error
|
| 215 |
+
}
|
| 216 |
+
});
|
| 217 |
+
}
|
| 218 |
async function streamToBuffer(stream) {
|
| 219 |
const chunks = [];
|
| 220 |
const captureChunks = new Writable({
|