finish up profiles, begin custom songs

This commit is contained in:
sky
2025-07-08 22:01:16 -04:00
parent cbdf039eab
commit acd6d2e9e2
7 changed files with 502 additions and 175 deletions

39
accounts/music.js Normal file
View File

@ -0,0 +1,39 @@
import Soundcloud from 'lucida/streamers/soundcloud/main.js'
let clientId = process.env.SOUNDCLOUD_CLIENT_ID;
let sc = new Soundcloud({
// oauthToken: clientId
})
async function search(query) {
let data = sc.search(query);
return data;
}
async function download(url, res) {
if (!url) {
return res.status(400).send('Please provide a SoundCloud track URL as ?url=')
}
try {
const info = await sc.getByUrl(url)
if (info.type !== 'track') {
return res.status(400).send('URL is not a SoundCloud track')
}
const { stream, mimeType, sizeBytes } = await info.getStream()
res.setHeader('Content-Type', mimeType)
if (sizeBytes) {
res.setHeader('Content-Length', sizeBytes.toString())
}
res.setHeader('Cache-Control', 'no-cache')
stream.pipe(res)
} catch (err) {
console.error('Stream error:', err)
res.status(500).send(err.message || 'Failed to stream track')
}
}
export { search, download };

View File

@ -235,7 +235,7 @@ async function generateAccountPage(name, cookie, admin) {
modifiedHTML = modifiedHTML.replaceAll("{{ user_pfp }}", userData.pfp_url || "/img/user.svg");
modifiedHTML = modifiedHTML.replaceAll("{{ custom_css }}", userData.custom_css || "");
modifiedHTML = modifiedHTML.replaceAll("{{ online_time }}", dayjs(userData.last_login).fromNow());
modifiedHTML = modifiedHTML.replaceAll("{{ played_games }}", buildGameHTML(userData));
modifiedHTML = modifiedHTML.replaceAll("{{ username }}", sanitizeHtml(userData.username, allowNone));
let badges_html = "";
if (userData.badges !== null) {