Skip to content

Commit

Permalink
Merge pull request #47 from jeronimo/reload-limiter-setting
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanLobbenmeier committed Apr 15, 2023
2 parents 09e0537 + 7060e67 commit 2bdce6f
Show file tree
Hide file tree
Showing 10 changed files with 1,995 additions and 1,696 deletions.
5 changes: 5 additions & 0 deletions modules/download/DownloadQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@ class DownloadQuery extends Query {
args.push('--keep-video');
}

if(this.environment.settings.retries) {
args.push('--retries');
args.push(this.environment.settings.retries);
}

let destinationCount = 0;
let initialReset = false;
let result = null;
Expand Down
4 changes: 4 additions & 0 deletions modules/info/InfoQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ class InfoQuery extends Query {
async connect() {
try {
let args = ["-J", "--flat-playlist"]
if(this.environment.settings.fileAccessRetries) {
args.push('--file-access-retries');
args.push(this.environment.settings.fileAccessRetries);
}
let data = await this.environment.metadataLimiter.schedule(() => this.start(this.url, args));
return JSON.parse(data);
} catch (e) {
Expand Down
10 changes: 9 additions & 1 deletion modules/persistence/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Settings {
paths, env, outputFormat, audioOutputFormat, downloadPath,
proxy, rateLimit, autoFillClipboard, noPlaylist, globalShortcut, userAgent,
validateCertificate, enableEncoding, taskList, nameFormat, nameFormatMode,
sizeMode, splitMode, maxConcurrent, updateBinary, downloadType, updateApplication, cookiePath,
sizeMode, splitMode, maxConcurrent, retries, fileAccessRetries, updateBinary, downloadType, updateApplication, cookiePath,
statSend, sponsorblockMark, sponsorblockRemove, sponsorblockApi, downloadMetadata, downloadJsonMetadata,
downloadThumbnail, keepUnmerged, avoidFailingToSaveDuplicateFileName, calculateTotalSize, theme
) {
Expand Down Expand Up @@ -39,6 +39,8 @@ class Settings {
this.sizeMode = sizeMode == null ? "click" : sizeMode;
this.splitMode = splitMode == null? "49" : splitMode;
this.maxConcurrent = (maxConcurrent == null || maxConcurrent <= 0) ? this.getDefaultMaxConcurrent() : maxConcurrent; //Max concurrent is standard half of the system's available cores
this.retries = retries || 10;
this.fileAccessRetries = fileAccessRetries || 3;
this.updateBinary = updateBinary == null ? true : updateBinary;
this.downloadType = downloadType == null ? "video" : downloadType;
this.updateApplication = updateApplication == null ? true : updateApplication;
Expand Down Expand Up @@ -83,6 +85,8 @@ class Settings {
data.sizeMode,
data.splitMode,
data.maxConcurrent,
data.retries,
data.fileAccessRetries,
data.updateBinary,
data.downloadType,
data.updateApplication,
Expand Down Expand Up @@ -137,6 +141,8 @@ class Settings {
this.maxConcurrent = settings.maxConcurrent;
this.env.changeMaxConcurrent(settings.maxConcurrent);
}
this.retries = settings.retries;
this.fileAccessRetries = settings.fileAccessRetries;
this.updateBinary = settings.updateBinary;
this.downloadType = settings.downloadType;
this.updateApplication = settings.updateApplication;
Expand Down Expand Up @@ -167,6 +173,8 @@ class Settings {
sizeMode: this.sizeMode,
splitMode: this.splitMode,
maxConcurrent: this.maxConcurrent,
retries: this.retries,
fileAccessRetries: this.fileAccessRetries,
defaultConcurrent: this.getDefaultMaxConcurrent(),
updateBinary: this.updateBinary,
downloadType: this.downloadType,
Expand Down
Loading

0 comments on commit 2bdce6f

Please sign in to comment.