aboutsummaryrefslogtreecommitdiffstats
path: root/src/client/Buttons.hx
diff options
context:
space:
mode:
authorRblSb <msrblsb@gmail.com>2025-03-25 03:02:03 +0300
committerRblSb <msrblsb@gmail.com>2025-03-25 08:16:04 +0300
commitf874dcd3de368e7e512ab1c0defdd17bc3026ce5 (patch)
tree74fecdf08577f2fc03b09b1170b9ffea9163af04 /src/client/Buttons.hx
parent8ee20a84cb35968f9247028a6a2daa57f04e90bb (diff)
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
Diffstat (limited to 'src/client/Buttons.hx')
-rw-r--r--src/client/Buttons.hx21
1 files changed, 18 insertions, 3 deletions
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<InputElement> = [
getEl("#add-temp"),
- getEl("#cache-on-server"),
];
for (checkbox in checkboxes) {
checkbox.addEventListener("change", () -> {
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage