From d9ca7beaa9494cf34590853901cf8be44e243775 Mon Sep 17 00:00:00 2001 From: RblSb Date: Thu, 16 Jan 2025 03:07:31 +0300 Subject: Cache on server feature Server will download video from supported players and add as raw video to playlist (only youtube is supported for now). Cache for YT player is available after installing optional dependencies, see readme. For cache size see `cacheStorageLimitGiB ` in config. There is also minor ux improvement, latest checkbox states will be keeped in local storage now. --- src/client/Buttons.hx | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) (limited to 'src/client/Buttons.hx') diff --git a/src/client/Buttons.hx b/src/client/Buttons.hx index c3581e2..f5f26e8 100644 --- a/src/client/Buttons.hx +++ b/src/client/Buttons.hx @@ -22,6 +22,12 @@ class Buttons { setSplitSize(settings.chatSize); initChatInput(main); + for (item in settings.checkboxes) { + if (item.checked == null) continue; + final checkbox:InputElement = ge('#${item.id}') ?? continue; + checkbox.checked = item.checked; + } + final passIcon = ge("#guestpass_icon"); passIcon.onclick = e -> { final icon = passIcon.firstElementChild; @@ -213,12 +219,15 @@ class Buttons { final mediaUrl:InputElement = cast ge("#mediaurl"); mediaUrl.oninput = () -> { - final value = mediaUrl.value; - final isRawSingleVideo = value != "" && main.isRawPlayerLink(value) - && main.isSingleVideoLink(value); - ge("#mediatitleblock").style.display = isRawSingleVideo ? "" : "none"; - ge("#subsurlblock").style.display = isRawSingleVideo ? "" : "none"; - ge("#voiceoverblock").style.display = value.length > 0 ? "" : "none"; + final url = mediaUrl.value; + final playerType = main.getLinkPlayerType(url); + final isSingle = main.isSingleVideoUrl(url); + final isSingleRawVideo = url != "" && playerType == RawType && isSingle; + ge("#mediatitleblock").style.display = isSingleRawVideo ? "" : "none"; + ge("#subsurlblock").style.display = isSingleRawVideo ? "" : "none"; + ge("#voiceoverblock").style.display = (url.length > 0 && isSingle) ? "" : "none"; + final showCache = isSingle && main.playersCacheSupport.contains(playerType); + ge("#cache-on-server").parentElement.style.display = showCache ? "" : "none"; final panel = ge("#addfromurl"); final oldH = panel.style.height; // save for animation panel.style.height = ""; // to calculate height from content @@ -482,6 +491,19 @@ class Buttons { if (Utils.isTouch()) chatline.blur(); return true; }); + final checkboxes:Array = [ + ge("#add-temp"), + ge("#cache-on-server"), + ]; + for (checkbox in checkboxes) { + checkbox.addEventListener("change", () -> { + final checked = checkbox.checked; + final item = settings.checkboxes.find(item -> item.id == checkbox.id); + settings.checkboxes.remove(item); + settings.checkboxes.push({id: checkbox.id, checked: checked}); + Settings.write(settings); + }); + } } static inline function getVisualViewport():Null { -- cgit v1.2.3