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) {