Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"title": "Featured Profiles",
"description": "Top 20 players from UltRank 2025",
"profile_alt": "View {name} 2025 recap"
}
},
"out_of_service": "Since {date}, downloading recap images and videos is no longer possible."
},
"common": {
"or": "OR"
Expand Down
3 changes: 2 additions & 1 deletion messages/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"title": "Profils en vedette",
"description": "Top 20 joueurs de l'UltRank 2025",
"profile_alt": "Voir le récapitulatif 2025 de {name}"
}
},
"out_of_service": "A partir du {date}, il ne sera plus possible de télécharger les récaps images et vidéos."
},
"common": {
"or": "OU"
Expand Down
33 changes: 33 additions & 0 deletions src/routes/(app)/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,18 @@
onMount(() => {
videoSrc = '/videos/Glutonny.webm';
});

const endOfService = new Date('2026-06-29T00:00:00Z');
</script>

<SearchPlayer bind:open={searchOpen} />

<div class="banner-info">
<p class="banner-text">
{m['home.out_of_service']({ date: endOfService.toLocaleDateString() })}
</p>
</div>

<section id="hero">
<div class="info">
<div class="branding-heading">
Expand Down Expand Up @@ -90,6 +98,31 @@
</section>

<style lang="scss">
@keyframes scroll {
from {
transform: translateX(0);
}
to {
transform: translateX(-100%);
}
}

.banner-info {
color: var(--nearly-black);
background-color: var(--really-white);
padding: 0.5rem 1rem;
text-align: center;

overflow: hidden;
white-space: nowrap;

.banner-text {
display: inline-block;
padding-left: 100%;
animation: scroll 10s linear infinite;
}
}

section {
display: flex;
flex-direction: column;
Expand Down
149 changes: 1 addition & 148 deletions src/routes/(app)/user/[slug]/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<script lang="ts">
import { resolve } from '$app/paths';
import { page } from '$app/state';
import { Button, type ButtonProps } from '$lib/components/Button';
import Download from '$lib/components/icons/Download.svelte';
import { Button } from '$lib/components/Button';
import { IsMobile } from '$lib/hooks/is-mobile.svelte';
import { getPlayerStats } from '$lib/remotes/players.remote';
import { createBlueSkyIntent, createXIntent } from '$lib/socialIntents';
Expand All @@ -18,121 +17,10 @@
const mobile = new IsMobile();

let player = $state<PlayerRef | undefined>();
let downloadButton = $state<HTMLAnchorElement | undefined>();
let isDownloading = $state(false);
let isDownloadingStill = $state(false);
let renderingProgress = $state<number | undefined>(undefined);
let downloadButtonProps = $state<ButtonProps>();

let userSlug = $derived(data.userSlug);
let shareUrl = $derived(page.url.href);
let isDebug = $derived(page.url.searchParams.get('debug') === 'true');

const downloadFromUrl = (url: string, name: string): void => {
const a = document.createElement('a');
a.href = url;
a.download = name;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
};

const renderRecap = async (stats: MainProps) => {
isDownloading = true;

const year = stats.thisIsMyRecapProps.year;
const filename =
`${stats.thisIsMyRecapProps.user.prefix ?? ''} ${stats.thisIsMyRecapProps.user.gamerTag}'s SmashRecap ${stats.thisIsMyRecapProps.year}.mp4`.trim();

// Trigger the render
const renderReq = await fetch(`/api/render`, {
method: 'POST',
body: JSON.stringify({ stats, userSlug, year })
});

if (!renderReq.ok) {
isDownloading = false;
renderingProgress = undefined;
return;
}

const renderResponse = await renderReq.json();
if ('url' in renderResponse) {
isDownloading = false;
renderingProgress = undefined;
return downloadFromUrl(renderResponse.url, filename);
}

const { renderId, bucketName } = renderResponse;

const checkProgress = async () => {
const progressReq = await fetch('/api/render/progress', {
method: 'POST',
body: JSON.stringify({ renderId, bucketName, userSlug, year })
});

if (!progressReq.ok) {
const message = await progressReq.text();
throw new Error(message);
}

return progressReq.json();
};

while (true) {
await new Promise((resolve) => setTimeout(resolve, 1000));
try {
const progress = await checkProgress();
if (progress.type === 'error') {
alert(m['recap.render_failed']({ error: progress.message }));
isDownloading = false;
renderingProgress = undefined;
return;
}

if (progress.type === 'done') {
isDownloading = false;
renderingProgress = undefined;

const downloadUrl = `/api/download?url=${encodeURIComponent(progress.url)}`;
downloadFromUrl(downloadUrl, filename);
break;
}
renderingProgress = progress.progress;
} catch {
isDownloading = false;
renderingProgress = undefined;
return;
}
}
};

const renderStill = async (stats: MainProps) => {
isDownloadingStill = true;

const filename =
`${stats.thisIsMyRecapProps.user.prefix ?? ''} ${stats.thisIsMyRecapProps.user.gamerTag}'s SmashRecap Summary ${stats.thisIsMyRecapProps.year}.png`.trim();

try {
const renderReq = await fetch(`/api/render/still`, {
method: 'POST',
body: JSON.stringify({ stats, userSlug })
});

if (!renderReq.ok) {
throw new Error('Failed to trigger still render');
}

const { url } = await renderReq.json();
const downloadUrl = `/api/download?url=${encodeURIComponent(url)}`;
downloadFromUrl(downloadUrl, filename);
} catch (e) {
console.error(e);
alert('Failed to download summary image');
} finally {
isDownloadingStill = false;
}
};
</script>

<div class="content">
Expand Down Expand Up @@ -194,41 +82,6 @@
Debug me
</Button>
{/if}
<Button
bind:ref={downloadButton}
id="download-button"
extended
size={mobile.current ? 'small' : 'medium'}
onclick={() => renderRecap(videoProps)}
disabled={isDownloading || isDownloadingStill}
icon={Download}
{...downloadButtonProps}
>
{#if isDownloading}
{#if renderingProgress !== undefined}
{m['recap.download_progress']({ progress: Math.round(renderingProgress * 100) })}
{:else}
{m['recap.downloading']()}
{/if}
{:else}
{m['recap.download_video']()}
{/if}
</Button>

<Button
extended
size={mobile.current ? 'small' : 'medium'}
onclick={() => renderStill(videoProps)}
disabled={isDownloading || isDownloadingStill}
icon={Download}
variant="secondary"
>
{#if isDownloadingStill}
{m['recap.downloading']()}
{:else}
{m['recap.download_summary_image']()}
{/if}
</Button>
<div class="posts">
<Button
extended
Expand Down
30 changes: 0 additions & 30 deletions src/routes/api/download/+server.ts

This file was deleted.

57 changes: 0 additions & 57 deletions src/routes/api/render/+server.ts

This file was deleted.

Loading
Loading