* better compacting format data

merge-requests/6/head
Dominika Liberda 2021-07-01 16:54:23 +00:00
parent c0370c8309
commit 9f6a8c15f6
2 changed files with 21 additions and 14 deletions

View File

@ -225,8 +225,9 @@ window.addEventListener('DOMContentLoaded', (event) => {
}
function isFormatSupported(fmt) {
if (!['http', 'https'].includes(fmt.protocol))
return false;
//// currently, we remove other formats in the backend
//if (!['http', 'https'].includes(fmt.protocol))
// return false;
// must be very old: https://developer.mozilla.org/en-US/docs/Web/API/MediaSource/isTypeSupported#browser_compatibility
if (!('MediaSource' in window)) {
@ -304,4 +305,19 @@ window.addEventListener('DOMContentLoaded', (event) => {
document.querySelector('#autoplayInput').checked = true;
playbackWait();
}
// formats
console.log("w dzisiejszym menu")
formats.forEach((e) => {
if (e.acodec == "none") {
console.log(`- ${e.format_id}, czyli ${e.height}p`)
} else if (e.vcodec == "none") {
console.log(`- ${e.format_id}, czyli ${e.acodec} ${e.abr}kbps`)
} else {
console.log(`A TAKŻE SPECJALNEGO GOŚCIA ${e.format_id}, czyli ${e.height}p WRAZ Z RODZINĄ`)
}
})
});

View File

@ -29,16 +29,7 @@ if [[ "${get_data[v]}" ]]; then
"width": 640,
"ext": "webm",
"vcodec": "vp8",
"acodec": "vorbis",
"format": "44 - 640x480 (480p)",
"protocol": "https",
"http_headers": {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.54 Safari/537.36",
"Accept-Charset": "ISO-8859-1,utf-8;q=0.7,*;q=0.7",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "en-us,en;q=0.5"
}
"acodec": "vorbis"
}]'
if [[ "${r[host]}" == "${cfg[flash_host]}" ]]; then
url='http://f.sakamoto.pl/videoplayback_.flv'
@ -85,7 +76,7 @@ if [[ "${get_data[v]}" ]]; then
<meta property='og:image' content='https://i.ytimg.com/vi/$(html_encode "${get_data[v]}")/hqdefault.jpg'>
<meta property='og:type' content='video.other'>
<meta property='video:duration' content='$(jq -r '.duration' <<< "$video")'>
"'<script type="application/ld+json">'"$(jq '{
"'<script type="application/ld+json">'"$(jq -c '{
"@context": "https://schema.org",
"@type": "VideoObject",
"name": .title,
@ -96,7 +87,7 @@ if [[ "${get_data[v]}" ]]; then
}' <<< "$video" | sed 's/</\&#60;/g;s/>/\&#62;/g;')"'</script>'
source templates/head.sh
fi
formats=$(jq '.formats' <<< "$video")
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")
fi
if [[ "${r[host]}" == "${cfg[flash_host]}" ]]; then