aboutsummaryrefslogtreecommitdiffstats
path: root/src/server
diff options
context:
space:
mode:
Diffstat (limited to 'src/server')
-rw-r--r--src/server/Cache.hx8
-rw-r--r--src/server/Main.hx15
2 files changed, 17 insertions, 6 deletions
diff --git a/src/server/Cache.hx b/src/server/Cache.hx
index 8681ea2..450a893 100644
--- a/src/server/Cache.hx
+++ b/src/server/Cache.hx
@@ -61,8 +61,8 @@ class Cache {
}
final ytdl:Dynamic = untyped require("@distube/ytdl-core");
log(client, 'Caching $url to $outName...');
- final opts = {playerClients: ["IOS", "WEB_CREATOR"]};
- final promise:Promise<YouTubeVideoInfo> = ytdl.getInfo(url, opts);
+ // final opts = {playerClients: ["IOS", "WEB_CREATOR"]};
+ final promise:Promise<YouTubeVideoInfo> = ytdl.getInfo(url);
promise.then(info -> {
// trace(info.formats.filter(item -> item.audioCodec != null));
trace('Get info with ${info.formats.length} formats');
@@ -85,14 +85,14 @@ class Cache {
final dlVideo:Readable<Dynamic> = ytdl(url, {
format: videoFormat,
- playerClients: opts.playerClients
+ // playerClients: opts.playerClients
});
dlVideo.pipe(Fs.createWriteStream('$cacheDir/input-video'));
dlVideo.on("error", err -> log(client, "Error during video download: " + err));
final dlAudio:Readable<Dynamic> = ytdl(url, {
format: audioFormat,
- playerClients: opts.playerClients
+ // playerClients: opts.playerClients
});
dlAudio.pipe(Fs.createWriteStream('$cacheDir/input-audio'));
dlAudio.on("error", err -> log(client, "Error during audio download: " + err));
diff --git a/src/server/Main.hx b/src/server/Main.hx
index b257e91..c863cce 100644
--- a/src/server/Main.hx
+++ b/src/server/Main.hx
@@ -70,6 +70,7 @@ class Main {
to stopped server time.
**/
var emptyRoomCallbackTimer:Null<Timer>;
+ var isServerPause = false;
static function main():Void {
new Main({
@@ -476,7 +477,9 @@ class Main {
if (!internal) return;
emptyRoomCallbackTimer?.stop();
if (clients.length == 1 && videoList.length > 0) {
- if (videoTimer.isPaused()) videoTimer.play();
+ if (!isServerPause) {
+ if (videoTimer.isPaused()) videoTimer.play();
+ }
}
checkBan(client);
@@ -505,7 +508,11 @@ class Main {
clients.remove(client);
sendClientList();
if (client.isLeader) {
- if (videoTimer.isPaused()) videoTimer.play();
+ // if (videoTimer.isPaused()) videoTimer.play();
+ if (videoList.length > 0) {
+ videoTimer.pause();
+ isServerPause = true;
+ }
}
if (clients.length == 0) {
emptyRoomCallbackTimer?.stop();
@@ -729,6 +736,7 @@ class Main {
saveFlashbackTime(videoList.currentItem);
}
videoTimer.setTime(data.play.time);
+ isServerPause = false;
videoTimer.play();
broadcast({
type: data.type,
@@ -759,6 +767,7 @@ class Main {
}
};
if (videoTimer.isPaused()) obj.getTime.paused = true;
+ if (isServerPause) obj.getTime.pausedByServer = true;
if (videoTimer.getRate() != 1) {
if (!clients.hasLeader()) videoTimer.setRate(1);
else obj.getTime.rate = videoTimer.getRate();
@@ -816,6 +825,7 @@ class Main {
} else if (!client.isLeader && clientName != "") {
if (!checkPermission(client, SetLeaderPerm)) return;
}
+ isServerPause = false;
clients.setLeader(clientName);
broadcast({
type: SetLeader,
@@ -1061,6 +1071,7 @@ class Main {
waitVideoStart?.stop();
loadedClientsCount = 0;
broadcast({type: VideoLoaded});
+ isServerPause = false;
videoTimer.start();
}
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage