From c0c587e5f5d69c030ea0f438b20df64a377afcf1 Mon Sep 17 00:00:00 2001 From: ThaUnknown Date: Fri, 2 Oct 2020 22:10:20 +0200 Subject: [PATCH] subtitle fixes, destroying fixes --- app/css/player.css | 1 - app/index.html | 2 +- app/js/playerHandler.js | 6 ++--- app/js/subtitleHandler.js | 4 +-- app/js/torrentHandler.js | 54 ++++++++++++++++++++++----------------- index.html | 9 ++++--- 6 files changed, 42 insertions(+), 34 deletions(-) diff --git a/app/css/player.css b/app/css/player.css index b08ffaf..7016539 100644 --- a/app/css/player.css +++ b/app/css/player.css @@ -196,7 +196,6 @@ input#progress[type=range]::before { color: #ececec; white-space: nowrap; align-self: center; - padding: 0 1.2rem; left: var(--progress); font-weight: 600; transition: .2s opacity ease; diff --git a/app/index.html b/app/index.html index 699de3a..5d73b86 100644 --- a/app/index.html +++ b/app/index.html @@ -156,7 +156,7 @@ 0 B/s
- + get_app diff --git a/app/js/playerHandler.js b/app/js/playerHandler.js index 4fe60f6..b754cfb 100644 --- a/app/js/playerHandler.js +++ b/app/js/playerHandler.js @@ -314,8 +314,8 @@ function btncap() { for (let track of video.textTracks) { let template = document.createElement("a") - template.classList.add("dropdown-item", "pointer") - template.innerHTML = track.language + template.classList.add("dropdown-item", "pointer", "text-capitalize") + template.innerHTML = track.language || (!Object.values(video.textTracks).some(track => track.language == "eng" || track.language == "en") ? "eng" : track.label) if (track.mode == "showing") { template.classList.add("text-white") off.classList.add("text-muted") @@ -341,7 +341,7 @@ function selectLang(lang) { track.mode = 'hidden'; } } - bcap() + btncap() } // keybinds diff --git a/app/js/subtitleHandler.js b/app/js/subtitleHandler.js index 61c37ed..a0a78c0 100644 --- a/app/js/subtitleHandler.js +++ b/app/js/subtitleHandler.js @@ -8,9 +8,9 @@ function parseSubs(stream) { subtitleStream = new SubtitleStream(subtitleStream) } else { subtitleStream = new SubtitleStream() - subtitleStream.once('tracks', function (pTracks) { + subtitleStream.once('tracks', pTracks => { pTracks.forEach(track => { - tracks[track.number] = video.addTextTrack('captions', track.type, track.language || track.number) + tracks[track.number] = video.addTextTrack('captions', track.type, track.language) }) if (video.textTracks[0]) { video.textTracks[0].mode = "showing" diff --git a/app/js/torrentHandler.js b/app/js/torrentHandler.js index fc134f2..ed7eeaf 100644 --- a/app/js/torrentHandler.js +++ b/app/js/torrentHandler.js @@ -1,28 +1,29 @@ -var client = new WebTorrent() -window.onbeforeunload = ()=>{ - client.torrents[0].store.destroy() - client.torrents[0].destroy() +let client = new WebTorrent() +window.onbeforeunload = () => { + client.torrents[0] ? client.torrents[0].store.destroy() : "" + client.torrents[0] ? client.torrents[0].destroy() : "" client.destroy() - } +} + const announceList = [ - ['wss://tracker.openwebtorrent.com'], - ['wss://tracker.btorrent.xyz'], - // ['wss://tracker.webtorrent.io'], - // ['wss://tracker.fastcast.nz'], - ['wss://video.blender.org:443/tracker/socket'], - ['wss://tube.privacytools.io:443/tracker/socket'], - ['wss://tracker.sloppyta.co:443/announce'], - ['wss://tracker.lab.vvc.niif.hu:443/announce'], - ['wss://tracker.files.fm:7073/announce'], - ['wss://open.tube:443/tracker/socket'], - ['wss://hub.bugout.link:443/announce'], - ['wss://peertube.cpy.re:443/tracker/socket'], - ['ws://tracker.sloppyta.co:80/announce'], - ['ws://tracker.lab.vvc.niif.hu:80/announce'], - ['ws://tracker.files.fm:7072/announce'], - ['ws://tracker.btsync.cf:6969/announce'], - ['ws://hub.bugout.link:80/announce'] - ], + ['wss://tracker.openwebtorrent.com'], + ['wss://tracker.btorrent.xyz'], + // ['wss://tracker.webtorrent.io'], + // ['wss://tracker.fastcast.nz'], + // ['wss://video.blender.org:443/tracker/socket'], + // ['wss://tube.privacytools.io:443/tracker/socket'], + ['wss://tracker.sloppyta.co:443/announce'], + ['wss://tracker.lab.vvc.niif.hu:443/announce'], + ['wss://tracker.files.fm:7073/announce'], + ['wss://open.tube:443/tracker/socket'], + ['wss://hub.bugout.link:443/announce'], + // ['wss://peertube.cpy.re:443/tracker/socket'], + ['ws://tracker.sloppyta.co:80/announce'], + ['ws://tracker.lab.vvc.niif.hu:80/announce'], + ['ws://tracker.files.fm:7072/announce'], + ['ws://tracker.btsync.cf:6969/announce'], + ['ws://hub.bugout.link:80/announce'] +], videoExtensions = [ '.avi', '.mp4', '.m4v', '.webm', '.mov', '.mkv', '.mpg', '.mpeg', '.ogv', '.webm', '.wmv', '.m2ts' ], @@ -54,7 +55,7 @@ let nowPlaying, selectedTorrent async function addTorrent(magnet) { if (client.torrents.length >= maxTorrents) { - client.torrents[0].store.destroy() + client.torrents[0].store ? client.torrents[0].store.destroy() : "" client.torrents[0].destroy() } halfmoon.hideModal("tsearch") @@ -143,6 +144,7 @@ function serveFile(file, req) { } // kind of a fetch event from service worker but for the main thread. +let lastport navigator.serviceWorker.addEventListener('message', evt => { const request = new Request(evt.data.url, { headers: evt.data.headers, @@ -168,6 +170,10 @@ navigator.serviceWorker.addEventListener('message', evt => { } port.onmessage = pull + + // hack: stop hiding the old stream somewhere in memory land + if (lastport) lastport.onmessage = null + lastport = port }) function prettyBytes(num) { diff --git a/index.html b/index.html index 2640a70..0f7fe6f 100644 --- a/index.html +++ b/index.html @@ -27,7 +27,7 @@ e.preventDefault(); deferredPrompt = e; }); - document.querySelector(".btn").addEventListener('click', (e) => { + add.addEventListener('click', (e) => { deferredPrompt.prompt(); deferredPrompt.userChoice.then((choiceResult) => { if (choiceResult.outcome === 'accepted') { @@ -61,9 +61,12 @@ no buffering, no ads, no delays, everything done client-side for free.