Skip to content

Commit

Permalink
Removed downloadThreads, retries & downloadEdge settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Inrixia committed Mar 25, 2023
1 parent 9d680ee commit 3d6725d
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 60 deletions.
11 changes: 6 additions & 5 deletions src/Downloader.ts
Expand Up @@ -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 {
Expand All @@ -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();
Expand Down Expand Up @@ -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);
}
}

Expand Down
3 changes: 0 additions & 3 deletions src/lib/defaults.ts
Expand Up @@ -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%"],
Expand Down
16 changes: 0 additions & 16 deletions 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<number>} Max number of parallel downloads
*/
export const downloadThreads = async (initial: number): Promise<number> =>
(
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
Expand Down
3 changes: 0 additions & 3 deletions src/lib/types.ts
Expand Up @@ -65,15 +65,12 @@ export type Resolution = ValueOfA<Resolutions>;

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)[];
Expand Down
1 change: 0 additions & 1 deletion src/quickStart.ts
Expand Up @@ -52,7 +52,6 @@ export const quickStart = async (): Promise<void> => {

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);

Expand Down
32 changes: 0 additions & 32 deletions wiki/settings.md
Expand Up @@ -15,15 +15,6 @@ Setting this to true will cause the quickStartPrompts to run on startup.

<br>

**downloadThreads**:<br>
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.<br>

```json
"downloadThreads": 1
```

<br>

## Floatplane

**floatplane.videosToSearch**:<br>
Expand Down Expand Up @@ -70,29 +61,6 @@ Controls if the downloader should wait for new videos to download after finishin

<br>

**floatplane.downloadEdge**:<br>
If not set to "", overrides the download edge used for video downloads.<br>

```json
"floatplane": {
"downloadEdge": "edge03-na.floatplane.com"
}
```

<br>

**floatplane.retries**:<br>
Sets the number of times a download will retry before giving up.<br>
Defaults to 3

```json
"floatplane": {
"retries": 3
}
```

<br>

**floatplane.seekAndDestroy**:<br>
You can put video id's here and the downloader will find, sort and download them normally.<br>

Expand Down

0 comments on commit 3d6725d

Please sign in to comment.