Merge branch 'download-fixes' into 'master'

Download fixes

See merge request videostreaming/grayjay!33
This commit is contained in:
Koen 2024-08-29 16:07:20 +00:00
commit 6ab3eff61c
2 changed files with 10 additions and 5 deletions

View file

@ -706,7 +706,12 @@ class VideoDownload {
}
else {
Logger.i(TAG, "Download $name Sequential");
sourceLength = downloadSource_Sequential(client, fileStream, videoUrl, onProgress);
try {
sourceLength = downloadSource_Sequential(client, fileStream, videoUrl, onProgress);
} catch (e: Throwable) {
Logger.w(TAG, "Failed to download sequentially (url = $videoUrl)")
throw e
}
}
Logger.i(TAG, "$name downloadSource Finished");
@ -762,7 +767,7 @@ class VideoDownload {
totalRead += read;
readSinceLastSpeedTest += read;
if (totalRead / progressRate > lastProgressCount) {
if (totalRead.toDouble() / progressRate > lastProgressCount) {
onProgress(sourceLength, totalRead, lastSpeed);
lastProgressCount++;
}

View file

@ -51,10 +51,10 @@ class DownloadService : Service() {
private val _client = ManagedHttpClient(OkHttpClient.Builder()
//.proxy(Proxy(Proxy.Type.HTTP, InetSocketAddress(InetAddress.getByName("192.168.1.175"), 8081)))
.readTimeout(Duration.ofSeconds(30))
.writeTimeout(Duration.ofSeconds(30))
.readTimeout(Duration.ofMinutes(30))
.writeTimeout(Duration.ofMinutes(30))
.connectTimeout(Duration.ofSeconds(30))
.callTimeout(Duration.ofMinutes(30)))
.callTimeout(Duration.ofMinutes(0)))
private var _started = false;