aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRblSb <msrblsb@gmail.com>2025-08-14 02:53:59 +0300
committerRblSb <msrblsb@gmail.com>2025-08-15 07:03:17 +0300
commite01ed5f5431551f8b159b4fd491c670efeca57ee (patch)
tree78737545fd27cce482cbfdd059aa72fe52ecc515
parent6b97957566fa8a01b7fa37fb735de19ee442c297 (diff)
Prefer original audio tracks
-rw-r--r--build/server.js31
-rw-r--r--res/index.html1
-rw-r--r--res/setup.html1
-rw-r--r--src/server/HttpServer.hx1
-rw-r--r--src/server/cache/YoutubeCache.hx7
-rw-r--r--test/tests/TestServer.hx6
-rw-r--r--test/tests/TestTimer.hx2
7 files changed, 40 insertions, 9 deletions
diff --git a/build/server.js b/build/server.js
index ecf4c3b..98f667e 100644
--- a/build/server.js
+++ b/build/server.js
@@ -4246,6 +4246,9 @@ server_HttpServer.prototype = {
}
}
,localizeHtml: function(data,lang) {
+ if(data.indexOf("<!-- localization-template -->") == -1) {
+ return data;
+ }
if(lang != null && this.matchLang.match(lang)) {
lang = this.matchLang.matched(0);
} else {
@@ -6381,7 +6384,14 @@ server_cache_YoutubeCache.prototype = {
while(_g1 < _this.length) {
var v = _this[_g1];
++_g1;
+ var onGetInfo;
if(v.acodec != "none" && v.vcodec == "none") {
+ var tmp = v.format_note;
+ onGetInfo = tmp != null ? tmp.indexOf("original") != -1 : null;
+ } else {
+ onGetInfo = false;
+ }
+ if(onGetInfo) {
_g.push(v);
}
}
@@ -6393,6 +6403,19 @@ server_cache_YoutubeCache.prototype = {
while(_g1 < _this.length) {
var v = _this[_g1];
++_g1;
+ if(v.acodec != "none" && v.vcodec == "none") {
+ _g.push(v);
+ }
+ }
+ aformats = _g;
+ }
+ if(aformats.length == 0) {
+ var _this = info.formats;
+ var _g = [];
+ var _g1 = 0;
+ while(_g1 < _this.length) {
+ var v = _this[_g1];
+ ++_g1;
if(v.acodec != "none") {
_g.push(v);
}
@@ -6412,7 +6435,7 @@ server_cache_YoutubeCache.prototype = {
if(tmp == null) {
_gthis.log(clientName,"Error: format with audio not found");
var _g = 0;
- while(_g < aformats.length) haxe_Log.trace(aformats[_g++],{ fileName : "src/server/cache/YoutubeCache.hx", lineNumber : 95, className : "server.cache.YoutubeCache", methodName : "cacheYoutubeVideo"});
+ while(_g < aformats.length) haxe_Log.trace(aformats[_g++],{ fileName : "src/server/cache/YoutubeCache.hx", lineNumber : 99, className : "server.cache.YoutubeCache", methodName : "cacheYoutubeVideo"});
return;
}
var _this = info.formats;
@@ -6441,7 +6464,7 @@ server_cache_YoutubeCache.prototype = {
} else {
_gthis.log(clientName,"Error: video format not found");
var _g1 = 0;
- while(_g1 < _g.length) haxe_Log.trace(_g[_g1++],{ fileName : "src/server/cache/YoutubeCache.hx", lineNumber : 105, className : "server.cache.YoutubeCache", methodName : "cacheYoutubeVideo"});
+ while(_g1 < _g.length) haxe_Log.trace(_g[_g1++],{ fileName : "src/server/cache/YoutubeCache.hx", lineNumber : 109, className : "server.cache.YoutubeCache", methodName : "cacheYoutubeVideo"});
return;
}
var ignoreQualities = [];
@@ -6483,7 +6506,7 @@ server_cache_YoutubeCache.prototype = {
var a = tmp1 != null ? tmp1 : 0;
var audioSizeRatio = (a < 2 ? 2 : a) / totalSize;
var isVideoFormatDownloading = true;
- var dlVideo = _gthis.ytDlp.downloadAsync(url,{ format : videoFormat.format_id == tmp.format_id ? videoFormat.format_id : "" + videoFormat.format_id + "+" + tmp.format_id, output : "" + _gthis.cache.cacheDir + "/" + inVideoName, remuxVideo : "mp4", cookies : useCookies ? _gthis.getCookiesPathOrNull() : null, onProgress : function(p) {
+ var dlVideo = _gthis.ytDlp.downloadAsync(url,{ format : videoFormat.format_id == tmp.format_id ? videoFormat.format_id : "" + videoFormat.format_id + "+" + tmp.format_id, output : "" + _gthis.cache.cacheDir + "/" + inVideoName, remuxVideo : "mp4", cookies : useCookies ? _gthis.getCookiesPathOrNull() : null, forceIpv4 : true, onProgress : function(p) {
var isFinished = p.status == "finished";
var ratio;
if(isFinished) {
@@ -6525,7 +6548,7 @@ server_cache_YoutubeCache.prototype = {
});
};
this.getInfoAsync(url,useCookies).then(onGetInfo).catch(function(err) {
- haxe_Log.trace(err,{ fileName : "src/server/cache/YoutubeCache.hx", lineNumber : 181, className : "server.cache.YoutubeCache", methodName : "cacheYoutubeVideo"});
+ haxe_Log.trace(err,{ fileName : "src/server/cache/YoutubeCache.hx", lineNumber : 186, className : "server.cache.YoutubeCache", methodName : "cacheYoutubeVideo"});
useCookies = true;
return _gthis.getInfoAsync(url,useCookies).then(onGetInfo).catch(function(err) {
_gthis.cleanYtInputFiles(inVideoName);
diff --git a/res/index.html b/res/index.html
index dfcbcd8..2f620c6 100644
--- a/res/index.html
+++ b/res/index.html
@@ -1,3 +1,4 @@
+<!-- localization-template -->
<!DOCTYPE html>
<html>
diff --git a/res/setup.html b/res/setup.html
index 5d39518..8068a9d 100644
--- a/res/setup.html
+++ b/res/setup.html
@@ -1,3 +1,4 @@
+<!-- localization-template -->
<!DOCTYPE html>
<html>
diff --git a/src/server/HttpServer.hx b/src/server/HttpServer.hx
index 4f283a4..f6fb27f 100644
--- a/src/server/HttpServer.hx
+++ b/src/server/HttpServer.hx
@@ -391,6 +391,7 @@ class HttpServer {
final matchVarString = ~/\${([A-z_]+)}/g;
function localizeHtml(data:String, lang:String):String {
+ if (!data.contains("<!-- localization-template -->")) return data;
if (lang != null && matchLang.match(lang)) {
lang = matchLang.matched(0);
} else lang = "en";
diff --git a/src/server/cache/YoutubeCache.hx b/src/server/cache/YoutubeCache.hx
index cb3d954..5b94bbb 100644
--- a/src/server/cache/YoutubeCache.hx
+++ b/src/server/cache/YoutubeCache.hx
@@ -85,7 +85,11 @@ class YoutubeCache {
function onGetInfo(info:VideoInfo):Void {
trace('Get info with ${info.formats.length} formats');
- var aformats = info.formats.filter(f -> f.acodec != "none" && f.vcodec == "none");
+ var aformats = info.formats.filter(f -> f.acodec != "none"
+ && f.vcodec == "none" && f.format_note?.contains("original"));
+ if (aformats.length == 0) {
+ aformats = info.formats.filter(f -> f.acodec != "none" && f.vcodec == "none");
+ }
if (aformats.length == 0) {
aformats = info.formats.filter(f -> f.acodec != "none");
}
@@ -136,6 +140,7 @@ class YoutubeCache {
output: '${cache.cacheDir}/$inVideoName',
remuxVideo: "mp4",
cookies: useCookies ? getCookiesPathOrNull() : null,
+ forceIpv4: true,
onProgress: p -> {
final isFinished = p.status == "finished";
var ratio = if (isFinished) {
diff --git a/test/tests/TestServer.hx b/test/tests/TestServer.hx
index f9074b3..2d0b71d 100644
--- a/test/tests/TestServer.hx
+++ b/test/tests/TestServer.hx
@@ -28,7 +28,7 @@ class TestServer extends Test {
Assert.equals("File Приветмир! not found.", data);
});
request('$url/Ы%ы%00ы!', data -> {
- Assert.equals("<!DOCTYPE html>", splitLines(data)[0]);
+ Assert.equals("<!DOCTYPE html>", splitLines(data)[1]);
});
request('$url/video/skins/default.php?dir_inc=/etc/passwd%00', data -> {
var line = "File video/skins/default.php not found.";
@@ -36,13 +36,13 @@ class TestServer extends Test {
Assert.equals(line, data);
});
request('$url/%20', data -> {
- Assert.equals("<!DOCTYPE html>", splitLines(data)[0]);
+ Assert.equals("<!DOCTYPE html>", splitLines(data)[1]);
});
request('$url/build/../../server.js', data -> {
Assert.equals("File server.js not found.", data);
});
request('$url/?meh', data -> {
- Assert.equals("<!DOCTYPE html>", splitLines(data)[0]);
+ Assert.equals("<!DOCTYPE html>", splitLines(data)[1]);
async.done();
});
}
diff --git a/test/tests/TestTimer.hx b/test/tests/TestTimer.hx
index 2e6e9e8..ce8723f 100644
--- a/test/tests/TestTimer.hx
+++ b/test/tests/TestTimer.hx
@@ -27,7 +27,7 @@ class TestTimer extends Test {
Assert.equals(false, timer.isPaused());
Assert.equals(true, timer.isStarted);
timer.stop();
- Assert.equals(0, timer.getTime());
+ Assert.equals(0.0, timer.getTime());
Assert.equals(true, timer.isPaused());
Assert.equals(false, timer.isStarted);
timer.start();
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage