From 3d6725dce414e45cac28dcabcdd3f88eb0e2cc0b Mon Sep 17 00:00:00 2001 From: Inrixia Date: Sun, 26 Mar 2023 00:54:38 +1300 Subject: [PATCH] Removed downloadThreads, retries & downloadEdge settings --- src/Downloader.ts | 11 ++++++----- src/lib/defaults.ts | 3 --- src/lib/prompts/settings.ts | 16 ---------------- src/lib/types.ts | 3 --- src/quickStart.ts | 1 - wiki/settings.md | 32 -------------------------------- 6 files changed, 6 insertions(+), 60 deletions(-) diff --git a/src/Downloader.ts b/src/Downloader.ts index ddf9d66..6f174f6 100644 --- a/src/Downloader.ts +++ b/src/Downloader.ts @@ -14,6 +14,8 @@ const bl = (str: string | number) => `\u001b[34;1m${str}\u001b[0m`; type DownloadProgress = { total: number; transferred: number; percent: number }; type Task = { video: Video; res: promiseFunction; formattedTitle: string }; +const MaxRetries = 5; + // Ew, I really need to refactor this monster of a class export default class Downloader { @@ -36,7 +38,7 @@ export default class Downloader { private tickQueue(): void { if (this.runQueue === false) return; - while (this.taskQueue.length !== 0 && (settings.downloadThreads === -1 || this.videosProcessing < settings.downloadThreads)) { + while (this.taskQueue.length !== 0 && this.videosProcessing < 2) { this.videosProcessing++; this.barsQueued--; const task = this.taskQueue.pop(); @@ -182,12 +184,11 @@ export default class Downloader { if (!(error instanceof Error)) info = new Error(`Something weird happened, whatever was thrown was not a error! ${error}`); else info = error; // Handle errors when downloading nicely - if (retries < settings.floatplane.retries) { - this.log(formattedTitle, { message: `\u001b[31m\u001b[1mERR\u001b[0m: ${info.message} - Retrying ${retries}/${settings.floatplane.retries}` }, true); + if (retries < MaxRetries) { + this.log(formattedTitle, { message: `\u001b[31m\u001b[1mERR\u001b[0m: ${info.message} - Retrying ${retries}/${MaxRetries}` }, true); if (info.message.indexOf("Range Not Satisfiable")) await this.processVideo(task, ++retries); else await this.processVideo(task, ++retries); - } else - this.log(formattedTitle, { message: `\u001b[31m\u001b[1mERR\u001b[0m: ${info.message} Max Retries! ${retries}/${settings.floatplane.retries}` }, true); + } else this.log(formattedTitle, { message: `\u001b[31m\u001b[1mERR\u001b[0m: ${info.message} Max Retries! ${retries}/${MaxRetries}` }, true); } } diff --git a/src/lib/defaults.ts b/src/lib/defaults.ts index fa32930..d657aab 100644 --- a/src/lib/defaults.ts +++ b/src/lib/defaults.ts @@ -186,15 +186,12 @@ export const defaultArgs: Args = { export const defaultSettings: Settings = { runQuickstartPrompts: true, - downloadThreads: 1, floatplane: { videosToSearch: 5, forceFullSearch: false, videoResolution: "1080", waitForNewVideos: true, _availableResolutions: defaultResolutions, - downloadEdge: "", - retries: 9, seekAndDestroy: [], }, _filePathFormattingOPTIONS: ["%channelTitle%", "%videoTitle%", "%year%", "%month%", "%day%", "%hour%", "%minute%", "%second%"], diff --git a/src/lib/prompts/settings.ts b/src/lib/prompts/settings.ts index 4a6b51e..395b957 100644 --- a/src/lib/prompts/settings.ts +++ b/src/lib/prompts/settings.ts @@ -1,22 +1,6 @@ import prompts from "prompts"; import type { Extras, Resolution } from "../types.js"; -/** - * Prompts user to set the max number of parallel downloads. - * @param {number} initial Default value - * @returns {Promise} Max number of parallel downloads - */ -export const downloadThreads = async (initial: number): Promise => - ( - await prompts({ - type: "number", - name: "downloadThreads", - message: "What is the number of threads to use for downloads? (-1 for unlimited).", - initial, - min: -1, - }) - ).downloadThreads || initial; - /** * Prompts user for the video resolution they want to download in. * @param {number} initial Initial resolution to be selected diff --git a/src/lib/types.ts b/src/lib/types.ts index 3376ed9..8e98a06 100644 --- a/src/lib/types.ts +++ b/src/lib/types.ts @@ -65,15 +65,12 @@ export type Resolution = ValueOfA; export type Settings = { runQuickstartPrompts: boolean; - downloadThreads: number; floatplane: { videoResolution: Resolution; videosToSearch: number; forceFullSearch: boolean; waitForNewVideos: boolean; _availableResolutions: Resolutions; - downloadEdge: string; - retries: number; seekAndDestroy: string[]; }; _filePathFormattingOPTIONS: (keyof FilePathFormattingOptions)[]; diff --git a/src/quickStart.ts b/src/quickStart.ts index 0a6d74e..47a0be3 100644 --- a/src/quickStart.ts +++ b/src/quickStart.ts @@ -52,7 +52,6 @@ export const quickStart = async (): Promise => { console.log("\n== \u001b[38;5;208mGeneral\u001b[0m ==\n"); settings.floatplane.videosToSearch = await prompts.floatplane.videosToSearch(settings.floatplane.videosToSearch); - settings.downloadThreads = await prompts.settings.downloadThreads(settings.downloadThreads); settings.floatplane.videoResolution = await prompts.settings.videoResolution(settings.floatplane.videoResolution, defaultResolutions); settings.filePathFormatting = await prompts.settings.fileFormatting(settings.filePathFormatting, settings._filePathFormattingOPTIONS); diff --git a/wiki/settings.md b/wiki/settings.md index 9718c04..2240953 100644 --- a/wiki/settings.md +++ b/wiki/settings.md @@ -15,15 +15,6 @@ Setting this to true will cause the quickStartPrompts to run on startup.
-**downloadThreads**:
-Sets the maximum amount of downloads that can run concurrently. Default's to 1, 2 would mean only 2 videos download at once, -1 is unlimited. This value should be set low when downloading a large number of videos.
- -```json -"downloadThreads": 1 -``` - -
- ## Floatplane **floatplane.videosToSearch**:
@@ -70,29 +61,6 @@ Controls if the downloader should wait for new videos to download after finishin
-**floatplane.downloadEdge**:
-If not set to "", overrides the download edge used for video downloads.
- -```json -"floatplane": { - "downloadEdge": "edge03-na.floatplane.com" -} -``` - -
- -**floatplane.retries**:
-Sets the number of times a download will retry before giving up.
-Defaults to 3 - -```json -"floatplane": { - "retries": 3 -} -``` - -
- **floatplane.seekAndDestroy**:
You can put video id's here and the downloader will find, sort and download them normally.