Update update.js

This commit is contained in:
Aleksandr Statciuk 2022-02-13 05:04:24 +03:00
parent 95ba14bbdd
commit 25cfecbbf9
1 changed files with 9 additions and 13 deletions

View File

@ -133,20 +133,16 @@ function findOrigin(requests = [], origins = {}) {
}
function parseStreams(streams) {
const data = streams
.filter(s => s.codec_type === 'video')
.reduce(
(acc, curr) => {
if (curr.height > acc.height) {
const bitrate = curr.tags.variant_bitrate ? parseInt(curr.tags.variant_bitrate) : 0
return { width: curr.width, height: curr.height, bitrate }
}
return acc
},
{ width: 0, height: 0, bitrate: 0 }
)
streams = streams.filter(s => s.codec_type === 'video')
streams = _.orderBy(streams, ['height', 'bitrate'], ['desc', 'desc'])
return data
const data = _.head(streams)
if (data) {
const bitrate = data.tags.variant_bitrate ? parseInt(data.tags.variant_bitrate) : 0
return { width: data.width, height: data.height, bitrate }
}
return {}
}
function parseError(error) {