Redirect to custom video player on every url

This commit is contained in:
2022-06-18 01:13:54 +02:00
parent 9b4bcc6c64
commit 8990e25a72
4 changed files with 27 additions and 17 deletions

View File

@ -3,8 +3,8 @@
<head>
<meta charset="UTF-8">
<title>HLS</title>
<link rel="stylesheet" href="hls.css">
<script src="hls.js" defer></script>
<link rel="stylesheet" href="player.css">
<script src="player.js" defer></script>
</head>
<body>
<video id="video"></video>

View File

@ -1,4 +1,4 @@
import {matches, Reliability} from "../../match/match";
import {Match, matches, Reliability} from "../../match/match";
// @ts-ignore
import Hls from "hls.js";
@ -8,18 +8,13 @@ function show_message(message: string) {
document.getElementById('video').hidden = true
}
async function main() {
const urlQuery = new URLSearchParams(window.location.search)
const id = urlQuery.get('id')
const url = urlQuery.get('url')
const match = matches.find((m) => m.id === id)
if (match === undefined) {
show_message(`Invalid id: ${id}. Please report this <a href="https://github.com/ByteDream/stream-bypass/issues/new">here</a>`)
return
}
document.title = match.name
async function play_native(url: string, match: Match) {
const video = document.getElementById('video') as HTMLVideoElement
video.controls = true
video.src = url
}
async function play_hls(url: string, match: Match) {
const video = document.getElementById('video') as HTMLVideoElement
video.controls = true
@ -66,4 +61,19 @@ async function main() {
}
}
async function main() {
const urlQuery = new URLSearchParams(window.location.search)
const id = urlQuery.get('id')
const url = urlQuery.get('url')
const match = matches.find((m) => m.id === id)
if (match === undefined) {
show_message(`Invalid id: ${id}. Please report this <a href="https://github.com/ByteDream/stream-bypass/issues/new">here</a>`)
return
}
document.title = match.name
url.endsWith('.m3u8') ? await play_hls(url, match) : await play_native(url, match)
}
main()