mobile, idek

This commit is contained in:
sky
2025-08-17 19:14:11 -04:00
parent db94e9fe49
commit 4e315c993a
6 changed files with 293 additions and 119 deletions

View File

@ -8,6 +8,7 @@ import { download } from "./music.js";
import dayjs from "dayjs";
import relativeTime from "dayjs/plugin/relativeTime.js";
import { error } from "node:console";
dayjs.extend(relativeTime);
const sanitizeConfig = {
@ -201,7 +202,7 @@ async function editProfile(body, token, admin) {
fs.mkdirSync(dir, { recursive: true });
fs.writeFileSync(path, "");
await sharp(pfp, { animated: fileType == "gif" })
.resize({ width: 300, withoutEnlargement: true })
.resize({ width: 400, withoutEnlargement: true })
.webp({ quality: 70, effort: 4 })
.toFile(path);
await fs.unlink(`${__dirname}/${userData.pfp_url}`, () => {});
@ -217,13 +218,25 @@ async function editProfile(body, token, admin) {
if(checkStatusRequest.status != 200) {
return { success: false, err: "processing server is down, try again later"};
}
let path = await download(body.url);
console.log("exit download");
let file = Bun.file(path);
let data = await download(body.url);
if(data.error) {
if(data.error == "content.too_long") {
return { success: false, err: "the song was too long, pick something shorter!"};
} else if(data.error == "content.region") {
return { success: false, err: "the song could not be downloaded due to the region of the server."};
} else if(data.error == "content.paid") {
return { success: false, err: "the song is go+ only, and we're too poor to pay for that :( pick another song"};
} else if(data.error == "fetch.empty") {
return { success: false, err: "we could not fetch this song successfully"};
} else {
return { success: false, err: "an unknown error happened! error code: " + error};
}
}
let streamingURL = data.urls;
let request = new Request({
url: process.env.PROCESSING_SERVER + "/process",
method: "POST",
body: await file.arrayBuffer(),
body: JSON.stringify({url: streamingURL}),
headers: {
"X-Authentication": process.env.PROCESSING_SERVER_SECRET
}