+ proxying protected videos

18l-fix
Dominika Liberda 2021-05-02 23:06:01 +00:00
parent 85c57e8bd4
commit aee1ca3f15
4 changed files with 17 additions and 0 deletions

View File

@ -7,3 +7,4 @@ router "/channel/:id" "${cfg[namespace]}/webroot/channel.shs"
router "/user/:user" "${cfg[namespace]}/webroot/channel.shs"
router "/playlist" "${cfg[namespace]}/webroot/playlist.shs"
router "/watch" "${cfg[namespace]}/webroot/watch.shs"
router "/proxy" "${cfg[namespace]}/webroot/proxy.shs"

View File

@ -179,6 +179,12 @@ window.addEventListener('DOMContentLoaded', (event) => {
localStorage.removeItem("audioStream");
}
function handleProtected(e) {
console.log(e)
if(e.originalTarget.error.code == 4 && ! e.originalTarget.currentSrc.startsWith("https://"+window.location.hostname)) {
e.target.src="https://"+window.location.hostname+"/proxy?url="+encodeURIComponent(encodeURIComponent(e.originalTarget.currentSrc))
}
}
function getMimeType(fmt) {
const mainType = fmt.vcodec !== 'none' ? 'video' : 'audio';
let secondary = {
@ -248,6 +254,8 @@ window.addEventListener('DOMContentLoaded', (event) => {
// document.querySelector('.ytp-play-progress').addEventListener('click', (e) => scrub(e));
document.querySelector('.ytp-volume-slider').addEventListener('click', (e) => volume(e));
document.querySelector('.ytp-button-fullscreen-enter').addEventListener('click', () => toggleFullscreen());
document.querySelector('video').addEventListener('error', (e) => handleProtected(e));
document.querySelector('audio').addEventListener('error', (e) => handleProtected(e));
if(localStorage.getItem("autoplay") == "true") {
toggleVideo(true);

5
webroot/proxy.shs Normal file
View File

@ -0,0 +1,5 @@
#!/bin/bash
url="$(url_decode "${get_data[url]}" | tr -d '\n\r')"
if [[ "$url" == "https://"[a-z0-9-]*".googlevideo.com/"* ]]; then
curl -H "Range: bytes=${r[range]}" "$url" -o -
fi

3
webroot/robots.txt Normal file
View File

@ -0,0 +1,3 @@
User-agent: *
Disallow: /
Disallow: /*