From 4afe15a715490fcb23e5e99b341a9b024372a58c Mon Sep 17 00:00:00 2001 From: localhost Date: Sat, 7 Mar 2026 10:55:36 +0100 Subject: [PATCH] lower ratelimit, avoid crashing on video error --- src/router/websocket.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/router/websocket.ts b/src/router/websocket.ts index 981fa78..4ae9a40 100644 --- a/src/router/websocket.ts +++ b/src/router/websocket.ts @@ -14,7 +14,7 @@ import { parseSlop } from '@/utils/slop'; const app = new Elysia() const videoIds: Record = {} -const MB_LIMIT = 500 +const MB_LIMIT = 350 const saveKey = (videoId: string) => `save:${videoId}` const checkMbLimit = async (hash: string, mb?: number): Promise => { @@ -218,7 +218,10 @@ app.ws('/savechannel', { videoIds[ws.id] = `downloading-${channelId}`; const videos = await getChannelVideos(channelId); - const hash = Bun.hash(getRateLimitKey(ws.data.headers['cf-connecting-ip'] || '0.0.0.0')) + if (!Array.isArray(videos)) { + await cleanup(ws, channelId); + return sendError(ws, 'Unable to retrieve channel videos from YouTube. Please try again later.'); + } for (const video of videos.slice(0, 5)) { if (!video || (await redis.get(saveKey(video.video_id))) || (await redis.get(`blacklist:${video.video_id}`))) continue; @@ -277,4 +280,4 @@ app.ws('/savechannel', { }) app.onError(error) -export default app \ No newline at end of file +export default app