aboutsummaryrefslogtreecommitdiffstats
path: root/server/shared.ts
diff options
context:
space:
mode:
authorPinapelz <yukais@pinapelz.com>2026-06-26 18:55:09 -0700
committerPinapelz <yukais@pinapelz.com>2026-06-26 18:55:09 -0700
commit84fbd4ee1e159b0426d664cc98a3dc7165d6381f (patch)
tree4e16adcb955339d44ae181633db65f6c956c98f9 /server/shared.ts
parente2446af8e273e412e0c1a1c7f46e43bbfcf732ae (diff)
game: music video frame routes
Diffstat (limited to 'server/shared.ts')
-rw-r--r--server/shared.ts14
1 files changed, 14 insertions, 0 deletions
diff --git a/server/shared.ts b/server/shared.ts
index 3b5344c..9744de9 100644
--- a/server/shared.ts
+++ b/server/shared.ts
@@ -1,5 +1,7 @@
import { createHmac, timingSafeEqual } from "crypto";
import { songs } from "./data/songs";
+import { musicVideos } from "./data/mvs";
+
function getSalt(): string {
return process.env.VITE_HEARDLE_SALT ?? "changeme";
@@ -58,6 +60,7 @@ export function pickSong(date: string): Song {
return songs[index];
}
+
function getLastNDates(n: number): string[] {
const dates: string[] = [];
for (let i = 1; i <= n; i++) {
@@ -83,6 +86,17 @@ export function getDailySong(today: string): Song {
return candidate;
}
+export function pickMusicVideo(date: string): Song {
+ const seed = hashString(date);
+ const index = seed % musicVideos.length;
+ return musicVideos[index];
+}
+
+export function getDailyMusicVideo(today: string): Song {
+ // potentially use deterministic no-repeat here too, for now this is fine
+ return pickMusicVideo(today);
+}
+
function signValue(prefix: string, value: string): string {
return createHmac("sha256", getSigningSecret())
.update(`${prefix}:${value}`)
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage