fix: stuff

This commit is contained in:
dusk 2023-05-09 18:41:58 +03:00
parent eba9e8b5d0
commit 77ed4a6de6
Signed by: dusk
GPG Key ID: 1D8F8FAF2294D6EA
6 changed files with 99 additions and 78 deletions

View File

@ -9,11 +9,23 @@ interface MusicInfo {
}
export async function load({ params }) {
const resp = await fetch(`${LOCAL_MUSIKQUAD_SERVER}/share/info/${params.token}`);
const token = params.token;
let color = '#222222';
const resp = await fetch(`${LOCAL_MUSIKQUAD_SERVER}/share/info/${token}`);
const info: MusicInfo = await resp.json();
/*const thumb_resp = await fetch(`${LOCAL_MUSIKQUAD_SERVER}/share/thumbnail/${token}`);
if (thumb_resp.ok) {
const thumb = await thumb_resp.blob();
const rawColor = await getColor(thumb);
color = rgbToHex(rawColor[0], rawColor[1], rawColor[2]);
}*/
return {
info,
thumbnail_url: `${scheme}://${PUBLIC_MUSIKQUAD_SERVER}/share/thumbnail/${params.token}`,
audio_url: `${scheme}://${PUBLIC_MUSIKQUAD_SERVER}/share/audio/${params.token}`
color,
thumbnail_url: `${scheme}://${PUBLIC_MUSIKQUAD_SERVER}/share/thumbnail/${token}`,
audio_url: `${scheme}://${PUBLIC_MUSIKQUAD_SERVER}/share/audio/${token}`
};
}

View File

@ -18,7 +18,7 @@
const hasAlbum = data.info.album;
if (hasArtist && hasAlbum) {
return `from ${data.info.album} by ${data.info.artist}`;
return `from ${data.info.album}\nby ${data.info.artist}`;
} else if (hasArtist) {
return `by ${data.info.artist}`;
} else if (hasAlbum) {
@ -44,6 +44,7 @@
<meta property="og:description" content={getAlbumArtistInfo()} />
<meta property="og:image" content={data.thumbnail_url} />
<meta property="og:audio" content={data.audio_url} />
<meta name="theme-color" content={data.color} />
</svelte:head>
<div
@ -59,7 +60,6 @@
bind:paused
bind:currentTime
bind:duration
on:loadstart={(event) => event.currentTarget.play()}
/>
<button
class="relative rounded placeholder w-16 h-16"

View File

@ -78,3 +78,12 @@ export function interceptKeys(
}
};
}
function componentToHex(c: number) {
var hex = c.toString(16);
return hex.length == 1 ? '0' + hex : hex;
}
export function rgbToHex(r: number, g: number, b: number) {
return '#' + componentToHex(r) + componentToHex(g) + componentToHex(b);
}

View File

@ -323,9 +323,9 @@
svelte "^3.58.0"
"@sveltejs/kit@^1.15.9":
version "1.16.2"
resolved "https://registry.yarnpkg.com/@sveltejs/kit/-/kit-1.16.2.tgz#639fd71abbb48ec819b909f051418bd4193f40e0"
integrity sha512-yxcpA4nvlVlJ+VyYnj0zD3QN05kfmoh4OyitlPrVG34nnZSHzFpE4eZ33X1A/tc9prslSFRhpM6rWngCs0nM8w==
version "1.16.3"
resolved "https://registry.yarnpkg.com/@sveltejs/kit/-/kit-1.16.3.tgz#2b7540dbe08ce5d2eb46a282043c5a345f25691e"
integrity sha512-8uv0udYRpVuE1BweFidcWHfL+u2gAANKmvIal1dN/FWPBl7DJYbt9zYEtr3bNTiXystT8Sn0Wp54RfwpbPqHjQ==
dependencies:
"@sveltejs/vite-plugin-svelte" "^2.1.1"
"@types/cookie" "^0.5.1"