+ proxying protected videos
This commit is contained in:
parent
85c57e8bd4
commit
aee1ca3f15
|
@ -7,3 +7,4 @@ router "/channel/:id" "${cfg[namespace]}/webroot/channel.shs"
|
||||||
router "/user/:user" "${cfg[namespace]}/webroot/channel.shs"
|
router "/user/:user" "${cfg[namespace]}/webroot/channel.shs"
|
||||||
router "/playlist" "${cfg[namespace]}/webroot/playlist.shs"
|
router "/playlist" "${cfg[namespace]}/webroot/playlist.shs"
|
||||||
router "/watch" "${cfg[namespace]}/webroot/watch.shs"
|
router "/watch" "${cfg[namespace]}/webroot/watch.shs"
|
||||||
|
router "/proxy" "${cfg[namespace]}/webroot/proxy.shs"
|
||||||
|
|
|
@ -179,6 +179,12 @@ window.addEventListener('DOMContentLoaded', (event) => {
|
||||||
localStorage.removeItem("audioStream");
|
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) {
|
function getMimeType(fmt) {
|
||||||
const mainType = fmt.vcodec !== 'none' ? 'video' : 'audio';
|
const mainType = fmt.vcodec !== 'none' ? 'video' : 'audio';
|
||||||
let secondary = {
|
let secondary = {
|
||||||
|
@ -248,6 +254,8 @@ window.addEventListener('DOMContentLoaded', (event) => {
|
||||||
// document.querySelector('.ytp-play-progress').addEventListener('click', (e) => scrub(e));
|
// document.querySelector('.ytp-play-progress').addEventListener('click', (e) => scrub(e));
|
||||||
document.querySelector('.ytp-volume-slider').addEventListener('click', (e) => volume(e));
|
document.querySelector('.ytp-volume-slider').addEventListener('click', (e) => volume(e));
|
||||||
document.querySelector('.ytp-button-fullscreen-enter').addEventListener('click', () => toggleFullscreen());
|
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") {
|
if(localStorage.getItem("autoplay") == "true") {
|
||||||
toggleVideo(true);
|
toggleVideo(true);
|
||||||
|
|
5
webroot/proxy.shs
Normal file
5
webroot/proxy.shs
Normal 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
3
webroot/robots.txt
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
User-agent: *
|
||||||
|
Disallow: /
|
||||||
|
Disallow: /*
|
Loading…
Reference in a new issue