From f874dcd3de368e7e512ab1c0defdd17bc3026ce5 Mon Sep 17 00:00:00 2001 From: RblSb Date: Tue, 25 Mar 2025 03:02:03 +0300 Subject: Initial cache support for raw videos m3u8 videos are cached without downloading segments, only m3u8 file is downloaded and segment links are updated to use synctube proxy, so you can add video to playlist as server, ignoring ip restrictions, and stream it to everyone --- src/client/Buttons.hx | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'src/client/Buttons.hx') diff --git a/src/client/Buttons.hx b/src/client/Buttons.hx index 11b8f7c..78b1c5a 100644 --- a/src/client/Buttons.hx +++ b/src/client/Buttons.hx @@ -222,6 +222,7 @@ class Buttons { } final mediaUrl:InputElement = getEl("#mediaurl"); + final checkboxCache:InputElement = getEl("#cache-on-server"); mediaUrl.oninput = () -> { final url = mediaUrl.value; final playerType = main.getLinkPlayerType(url); @@ -230,8 +231,13 @@ class Buttons { getEl("#mediatitleblock").style.display = isSingleRawVideo ? "" : "none"; getEl("#subsurlblock").style.display = isSingleRawVideo ? "" : "none"; getEl("#voiceoverblock").style.display = (url.length > 0 && isSingle) ? "" : "none"; - final showCache = isSingle && main.playersCacheSupport.contains(playerType); - getEl("#cache-on-server").parentElement.style.display = showCache ? "" : "none"; + + final isExternal = main.isExternalVideoUrl(url); + final showCache = isSingle && isExternal + && main.playersCacheSupport.contains(playerType); + checkboxCache.parentElement.style.display = showCache ? "" : "none"; + checkboxCache.checked = settings.checkedCache.contains(playerType); + final panel = getEl("#addfromurl"); final oldH = panel.style.height; // save for animation panel.style.height = ""; // to calculate height from content @@ -241,6 +247,16 @@ class Buttons { } mediaUrl.onfocus = mediaUrl.oninput; + checkboxCache.addEventListener("change", () -> { + final url = mediaUrl.value; + final playerType = main.getLinkPlayerType(url); + final checked = checkboxCache.checked; + + settings.checkedCache.remove(playerType); + if (checked) settings.checkedCache.push(playerType); + Settings.write(settings); + }); + getEl("#insert_template").onclick = e -> { mediaUrl.value = main.getTemplateUrl(); mediaUrl.focus(); @@ -518,7 +534,6 @@ class Buttons { }); final checkboxes:Array = [ getEl("#add-temp"), - getEl("#cache-on-server"), ]; for (checkbox in checkboxes) { checkbox.addEventListener("change", () -> { -- cgit v1.2.3