Skip to content

Commit

Permalink
api/xiaohongshu: deduplicate h264 stream extraction
Browse files Browse the repository at this point in the history
reduce() isn't called on 1 item arrays, so this is just fine

Co-authored-by: jj <[email protected]>
  • Loading branch information
wukko and dumbmoron authored Jan 20, 2025
1 parent 4963c9f commit e39b0ae
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions api/src/processing/services/xiaohongshu.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down

0 comments on commit e39b0ae

Please sign in to comment.