player sorting fixes
parent
4cd00fc54e
commit
ee3654c950
|
@ -29,6 +29,12 @@ window.addEventListener('DOMContentLoaded', (event) => {
|
|||
formats = JSON.parse(document.getElementById('yt_formats').innerText)
|
||||
.filter((fmt) => isFormatSupported(fmt) === true)
|
||||
.sort((a, b) => {
|
||||
if (a.format_note.includes("maybe throttled") && ! b.format_note.includes("maybe throttled")) {
|
||||
return 1;
|
||||
}
|
||||
if (! a.format_note.includes("maybe throttled") && b.format_note.includes("maybe throttled")) {
|
||||
return -1;
|
||||
}
|
||||
if (a.vcodec === 'none' && b.vcodec !== 'none') {
|
||||
return -1;
|
||||
}
|
||||
|
@ -36,10 +42,29 @@ window.addEventListener('DOMContentLoaded', (event) => {
|
|||
return 1;
|
||||
}
|
||||
if (a.vcodec !== 'none' && b.vcodec !== 'none') {
|
||||
return b.height - a.height;
|
||||
if (a.height !== b.height) {
|
||||
return b.height - a.height;
|
||||
}
|
||||
if (a.fps !== b.fps) {
|
||||
return b.fps - a.fps;
|
||||
}
|
||||
if (a.acodec === 'none' && b.acodec !== 'none') {
|
||||
return -1;
|
||||
}
|
||||
if (a.acodec !== 'none' && b.acodec === 'none') {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if (a.acodec !== 'none' && b.acodec !== 'none') {
|
||||
return b.abr - a.abr;
|
||||
if (a.acodec === 'opus' && b.acodec !== 'opus') {
|
||||
return -1;
|
||||
}
|
||||
if (a.acodec !== 'opus' && b.acodec === 'opus') {
|
||||
return 1;
|
||||
}
|
||||
if (a.abr !== b.abr) {
|
||||
return b.abr - a.abr;
|
||||
}
|
||||
}
|
||||
});
|
||||
console.log(formats);
|
||||
|
@ -426,13 +451,13 @@ window.addEventListener('DOMContentLoaded', (event) => {
|
|||
uwu.innerText = ''
|
||||
audioStreamInput.append(uwu);
|
||||
|
||||
let selectedAudioIndex = 0;
|
||||
let selectedAudioIndex = 1;
|
||||
let selectedVideoIndex = 0;
|
||||
formats.forEach((e) => {
|
||||
let uwu = document.createElement("option");
|
||||
uwu.value = e.format_id;
|
||||
if (e.acodec == "none") {
|
||||
uwu.innerText = `${e.ext} ${e.height}p (${e.format_id})`;
|
||||
uwu.innerText = `${e.format_note} ${e.vcodec.substring(0, 4)} (${e.format_id})`;
|
||||
if (uwu.value == localStorage.getItem("videoStream")) {
|
||||
selectedVideoIndex = videoStreamInput.length;
|
||||
console.log(selectedVideoIndex)
|
||||
|
@ -448,7 +473,7 @@ window.addEventListener('DOMContentLoaded', (event) => {
|
|||
audioStreamInput.append(uwu);
|
||||
console.log(`- ${e.format_id}, czyli ${e.acodec} ${e.abr}kbps`)
|
||||
} else {
|
||||
uwu.innerText = `${e.ext} ${e.height}p (${e.format_id})`;
|
||||
uwu.innerText = `${e.format_note} ${e.vcodec.substring(0, 4)}+${e.acodec.substring(0, 4)} (${e.format_id})`;
|
||||
if (uwu.value == localStorage.getItem("videoStream")) {
|
||||
selectedVideoIndex = videoStreamInput.length;
|
||||
console.log(selectedVideoIndex)
|
||||
|
|
|
@ -93,7 +93,7 @@ if [[ "${get_data[v]}" ]]; then
|
|||
}' <<< "$video" | sed 's/</\</g;s/>/\>/g;')"'</script>'
|
||||
source templates/head.sh
|
||||
fi
|
||||
formats=$(jq -c '[.formats[] | select(.protocol == "https") | {"format_id":.format_id,"url":.url,"ext":.ext,"width":.width,"height":.height,"acodec":.acodec,"vcodec":.vcodec,"abr":.abr,"fps":.fps}]' <<< "$video")
|
||||
formats=$(jq -c '[.formats[] | select(.protocol == "https") | {"format_id":.format_id,"url":.url,"ext":.ext,"width":.width,"height":.height,"format_note":.format_note,"acodec":.acodec,"vcodec":.vcodec,"abr":.abr,"fps":.fps}]' <<< "$video")
|
||||
|
||||
sub_array=()
|
||||
|
||||
|
|
Loading…
Reference in New Issue