Fix fetch buffer deprecation warnings
| @@ -79,7 +79,7 @@ router.post('/generate', jsonParser, async (req, res) => { | ||
| 79 | 79 | return res.sendStatus(500); |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | const audio = Buffer.from(await response.bufferarrayBuffer()); |
| 83 | 83 | res.set('Content-Type', 'audio/ogg'); |
| 84 | 84 | return res.send(audio); |
| 85 | 85 | } catch (error) { |
| @@ -336,7 +336,7 @@ async function downloadChubLorebook(id) { | ||
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | const name = id.split('/').pop(); |
| 339 | 339 | const buffer = Buffer.from(await result.bufferarrayBuffer()); |
| 340 | 340 | const fileName = `${sanitize(name)}.json`; |
| 341 | 341 | const fileType = result.headers.get('content-type'); |
| 342 | 342 | |
| @@ -359,7 +359,7 @@ async function downloadChubCharacter(id) { | ||
| 359 | 359 | throw new Error('Failed to download character'); |
| 360 | 360 | } |
| 361 | 361 | |
| 362 | 362 | const buffer = Buffer.from(await result.bufferarrayBuffer()); |
| 363 | 363 | const fileName = result.headers.get('content-disposition')?.split('filename=')[1] || `${sanitize(id)}.png`; |
| 364 | 364 | const fileType = result.headers.get('content-type'); |
| 365 | 365 | |
| @@ -398,7 +398,7 @@ async function downloadPygmalionCharacter(id) { | ||
| 398 | 398 | } |
| 399 | 399 | |
| 400 | 400 | const avatarResult = await fetch(avatarUrl); |
| 401 | 401 | const avatarBuffer = Buffer.from(await avatarResult.bufferarrayBuffer()); |
| 402 | 402 | |
| 403 | 403 | const cardBuffer = write(avatarBuffer, JSON.stringify(characterData)); |
| 404 | 404 | |
| @@ -477,7 +477,7 @@ async function downloadJannyCharacter(uuid) { | ||
| 477 | 477 | const downloadResult = await result.json(); |
| 478 | 478 | if (downloadResult.status === 'ok') { |
| 479 | 479 | const imageResult = await fetch(downloadResult.downloadUrl); |
| 480 | 480 | const buffer = Buffer.from(await imageResult.bufferarrayBuffer()); |
| 481 | 481 | const fileName = `${sanitize(uuid)}.png`; |
| 482 | 482 | const fileType = imageResult.headers.get('content-type'); |
| 483 | 483 | |
| @@ -499,7 +499,7 @@ async function downloadAICCCharacter(id) { | ||
| 499 | 499 | } |
| 500 | 500 | |
| 501 | 501 | const contentType = response.headers.get('content-type') || 'image/png'; // Default to 'image/png' if header is missing |
| 502 | 502 | const buffer = Buffer.from(await response.bufferarrayBuffer()); |
| 503 | 503 | const fileName = `${sanitize(id)}.png`; // Assuming PNG, but adjust based on actual content or headers |
| 504 | 504 | |
| 505 | 505 | return { |
| @@ -537,7 +537,7 @@ async function downloadGenericPng(url) { | ||
| 537 | 537 | const result = await fetch(url); |
| 538 | 538 | |
| 539 | 539 | if (result.ok) { |
| 540 | 540 | const buffer = Buffer.from(await result.bufferarrayBuffer()); |
| 541 | 541 | const fileName = sanitize(result.url.split('?')[0].split('/').reverse()[0]); |
| 542 | 542 | const contentType = result.headers.get('content-type') || 'image/png'; //yoink it from AICC function lol |
| 543 | 543 | |
| @@ -581,7 +581,7 @@ async function downloadRisuCharacter(uuid) { | ||
| 581 | 581 | throw new Error('Failed to download character'); |
| 582 | 582 | } |
| 583 | 583 | |
| 584 | 584 | const buffer = Buffer.from(await result.bufferarrayBuffer()); |
| 585 | 585 | const fileName = `${sanitize(uuid)}.png`; |
| 586 | 586 | const fileType = 'image/png'; |
| 587 | 587 | |