mirror of
https://github.com/imputnet/cobalt.git
synced 2025-07-18 11:18:28 +00:00
improvement: sort().shift() -> reduce() in nicovideo
This commit is contained in:
parent
05b48f15a9
commit
4124c503c4
@ -77,8 +77,9 @@ async function fetchGuestData(id, actionTrackId) {
|
|||||||
// getting the HQ audio
|
// getting the HQ audio
|
||||||
const { id: audioId } = audios
|
const { id: audioId } = audios
|
||||||
.filter((audio) => audio.isAvailable)
|
.filter((audio) => audio.isAvailable)
|
||||||
.sort((firstAudio, secondAudio) => firstAudio.bitrate - secondAudio.bitrate)
|
.reduce((firstAudio, secondAudio) =>
|
||||||
.shift();
|
firstAudio.bitRate > secondAudio.bitRate ? firstAudio : secondAudio
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
accessRightKey,
|
accessRightKey,
|
||||||
@ -125,12 +126,11 @@ async function getHLSContent(contentURL, quality, isAudioOnly, isAudioMuted) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (hlsContent === undefined) {
|
if (hlsContent === undefined) {
|
||||||
hlsContent = hls.variants
|
hlsContent = hls.variants.reduce((firstVariant, secondVariant) =>
|
||||||
.sort(
|
firstVariant.bandwidth > secondVariant.bandwidth
|
||||||
(firstVariant, secondVariant) =>
|
? firstVariant
|
||||||
firstVariant.bandwidth - secondVariant.bandwidth
|
: secondVariant
|
||||||
)
|
);
|
||||||
.shift();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const audioUrl = hlsContent.audio.pop().uri;
|
const audioUrl = hlsContent.audio.pop().uri;
|
||||||
|
Loading…
Reference in New Issue
Block a user