From e39b0ae7b3b09e1a0444810a6f35bf703f1ed604 Mon Sep 17 00:00:00 2001 From: wukko Date: Mon, 20 Jan 2025 19:41:02 +0600 Subject: [PATCH] api/xiaohongshu: deduplicate h264 stream extraction reduce() isn't called on 1 item arrays, so this is just fine Co-authored-by: jj --- api/src/processing/services/xiaohongshu.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/api/src/processing/services/xiaohongshu.js b/api/src/processing/services/xiaohongshu.js index 6e141f5a..45d7acc5 100644 --- a/api/src/processing/services/xiaohongshu.js +++ b/api/src/processing/services/xiaohongshu.js @@ -75,12 +75,9 @@ export default async function ({ id, token, shareId, h265, isAudioOnly, dispatch if (!videoURL) { const h264Streams = video.media?.stream?.h264; - if (!h264Streams) return { error: "fetch.empty" }; - if (h264Streams.length > 1) { + if (h264Streams?.length) { videoURL = h264Streams.reduce((a, b) => Number(a?.videoBitrate) > Number(b?.videoBitrate) ? a : b).masterUrl; - } else { - videoURL = h264Streams[0].masterUrl; } }