From 23fdba356e5aaff89e5ac24ed582a76130553645 Mon Sep 17 00:00:00 2001 From: localhost Date: Sat, 30 Mar 2024 16:51:13 +0100 Subject: [PATCH] people abusing it --- controller/websocket.js | 4 ++-- utils/metadata.js | 5 +---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/controller/websocket.js b/controller/websocket.js index b79a85f..7464c3c 100644 --- a/controller/websocket.js +++ b/controller/websocket.js @@ -127,7 +127,7 @@ exports.playlist = async (ws, req) => { async function startDownloading() { const playlist = await metadata.getPlaylistVideos(playlistId) - for (video of playlist.relatedStreams) { + for (video of playlist.relatedStreams.slice(0, 5)) { if (ws.readyState !== ws.OPEN) { return logger.info({ message: `Stopped downloading ${playlistId}, websocket is closed` }) } @@ -233,7 +233,7 @@ exports.channel = async (ws, req) => { async function startDownloading() { const videos = await metadata.getChannelVideos(channelId) - for (video of videos) { + for (video of videos.slice(0, 5)) { if (ws.readyState !== ws.OPEN) { return logger.info({ message: `Stopped downloading ${channelId}, websocket is closed` }) } diff --git a/utils/metadata.js b/utils/metadata.js index a8ba2fb..9d6ab97 100644 --- a/utils/metadata.js +++ b/utils/metadata.js @@ -122,10 +122,7 @@ async function getPlaylistVideos(id) { 'User-Agent': 'Mozilla/5.0 (compatible; PreserveTube/0.0; +https://preservetube.com)' } })).json() - return { - ...json, - relatedStreams: json.relatedStreams.slice(0, 5) - } + return json } async function getVideoDownload(url, quality) {