aboutsummaryrefslogtreecommitdiffstats
path: root/src/server/cache/Cache.hx
diff options
context:
space:
mode:
authorPinapelz <yukais@pinapelz.com>2026-10-19 15:32:53 -0700
committerPinapelz <yukais@pinapelz.com>2026-10-19 15:32:53 -0700
commit304bd1e77a5442f614aacd2b35f330777118b2cd (patch)
tree970e7da13bb1bd8edf1f9b453af4d0994c665e94 /src/server/cache/Cache.hx
parenta4f3064542ddad6939598e7e60ca0090be07df60 (diff)
merge with upstream https://github.com/RblSb/SyncTubeHEADmaster
Diffstat (limited to 'src/server/cache/Cache.hx')
-rw-r--r--src/server/cache/Cache.hx39
1 files changed, 30 insertions, 9 deletions
diff --git a/src/server/cache/Cache.hx b/src/server/cache/Cache.hx
index cfe2f66..f0fe741 100644
--- a/src/server/cache/Cache.hx
+++ b/src/server/cache/Cache.hx
@@ -18,6 +18,7 @@ class Cache {
public final freeSpaceBlock = 10 * 1024 * 1024; // 10MB
final cachedFiles:Array<String> = [];
+ var ytdlpCache:YtdlpCache;
var youtubeCache:YoutubeCache;
var rawCache:RawCache;
@@ -25,12 +26,13 @@ class Cache {
this.main = main;
this.cacheDir = cacheDir;
Utils.ensureDir(cacheDir);
- youtubeCache = new YoutubeCache(main, this);
+ ytdlpCache = new YtdlpCache(main, this);
+ youtubeCache = new YoutubeCache(main, this, ytdlpCache);
rawCache = new RawCache(main, this);
- isYtReady = youtubeCache.checkYtDeps();
+ isYtReady = ytdlpCache.checkYtDeps();
if (isYtReady) {
- youtubeCache.cleanYtInputFiles();
- youtubeCache.checkUpdate();
+ ytdlpCache.cleanInputFiles();
+ ytdlpCache.checkUpdate();
}
}
@@ -75,12 +77,31 @@ class Cache {
}
}
- public function cacheYoutubeVideo(client:Client, url:String, callback:(name:String) -> Void) {
- youtubeCache.cacheYoutubeVideo(client, url, callback);
+ public function cacheYoutubeVideo(client:Client, url:String, callbacks:CacheCallbacks) {
+ youtubeCache.cacheYoutubeVideo(client, url, callbacks);
}
- public function cacheRawVideo(client:Client, url:String, callback:(name:String) -> Void) {
- rawCache.cacheRawVideo(client, url, callback);
+ /** Site-specific extractor download via yt-dlp, no fallback. **/
+ public function cacheYtdlpVideo(client:Client, url:String, callbacks:CacheCallbacks) {
+ if (!isYtReady) {
+ rawCache.cacheRawVideo(client, url, callbacks);
+ return;
+ }
+ ytdlpCache.cacheVideo(client, url, callbacks);
+ }
+
+ /**
+ use yt-dlp if a site-specific extractor supports the url, otherwise fallback to raw download.
+ **/
+ public function cacheRawVideo(client:Client, url:String, callbacks:CacheCallbacks) {
+ if (!isYtReady) {
+ rawCache.cacheRawVideo(client, url, callbacks);
+ return;
+ }
+ ytdlpCache.checkUrlSupported(url, supported -> {
+ if (supported) ytdlpCache.cacheVideo(client, url, callbacks);
+ else rawCache.cacheRawVideo(client, url, callbacks);
+ });
}
public function setStorageLimit(bytes:Int) {
@@ -105,7 +126,7 @@ class Cache {
callback(storageLimit);
return;
}
- statfs("/", (err, stats) -> {
+ statfs(cacheDir, (err, stats) -> {
if (err != null) {
trace(err);
callback(storageLimit);
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage