Refactored with feedback

This commit is contained in:
rdiaz738 2025-03-04 16:16:19 -08:00
parent 2e86a4875d
commit 92f5d34ce2
4 changed files with 34 additions and 28 deletions

View file

@ -61,12 +61,15 @@ Certain values can be set via environment variables, using the `-e` parameter on
* __YTDL_OPTIONS__: Additional options to pass to youtube-dl, in JSON format. [See available options here](https://github.com/yt-dlp/yt-dlp/blob/master/yt_dlp/YoutubeDL.py#L183). They roughly correspond to command-line options, though some do not have exact equivalents here, for example `--recode-video` has to be specified via `postprocessors`. Also note that dashes are replaced with underscores.
* __YTDL_OPTIONS_FILE__: A path to a JSON file that will be loaded and used for populating `YTDL_OPTIONS` above. Please note that if both `YTDL_OPTIONS_FILE` and `YTDL_OPTIONS` are specified, the options in `YTDL_OPTIONS` take precedence.
* __ROBOTS_TXT__: A path to a `robots.txt` file mounted in the container
* __DOWNLOAD_MODE__ :This flag controls how downloads are scheduled and executed. There are three possible values:
* **sequential**: Downloads are processed one at a time. A new download won’t start until the previous one has finished. This mode is useful for conserving system resources or ensuring downloads occur in a strict order.
* **concurrent**: Downloads are started immediately as they are added, with no built-in limit on how many run simultaneously. This mode may overwhelm your system if too many downloads start at once.
* **limited**: Downloads are started concurrently but are capped by a concurrency limit. In this mode, a semaphore is used so that at most a fixed number of downloads run at any given time.
* **MAX\_CONCURRENT\_DOWNLOADS**
This flag is used only when **DOWNLOAD\_MODE** is set to **limited**. It specifies the maximum number of simultaneous downloads allowed. For example, if set to `3`, then at most three downloads will run concurrently, and any additional downloads will wait until one of the active downloads completes.
* __DOWNLOAD_MODE__ :This flag controls how downloads are scheduled and executed. Options are `sequential`, `concurrent`, and `limited`. Defaults to `limited`:
* `sequential`: Downloads are processed one at a time. A new download won’t start until the previous one has finished. This mode is useful for conserving system resources or ensuring downloads occur in a strict order.
* `concurrent`: Downloads are started immediately as they are added, with no built-in limit on how many run simultaneously. This mode may overwhelm your system if too many downloads start at once.
* `limited`: Downloads are started concurrently but are capped by a concurrency limit. In this mode, a semaphore is used so that at most a fixed number of downloads run at any given time.
* **MAX\_CONCURRENT\_DOWNLOADS** This flag is used only when **DOWNLOAD\_MODE** is set to **limited**.
It specifies the maximum number of simultaneous downloads allowed. For example, if set to `5`, then at most five downloads will run concurrently, and any additional downloads will wait until one of the active downloads completes. Defaults to `3`.
The following example value for `YTDL_OPTIONS` embeds English subtitles and chapter markers (for videos that have them), and also changes the permissions on the downloaded video and sets the file modification timestamp to the date of when it was downloaded:
```yaml
environment:

View file

@ -43,8 +43,8 @@ class Config:
'KEYFILE': '',
'BASE_DIR': '',
'DEFAULT_THEME': 'auto',
'DOWNLOAD_MODE': 'limited', # Can be 'sequential', 'concurrent', or 'limited'
'MAX_CONCURRENT_DOWNLOADS': 3, # Used if DOWNLOAD_MODE is 'limited'
'DOWNLOAD_MODE': 'limited',
'MAX_CONCURRENT_DOWNLOADS': 3,
}
_BOOLEAN = ('DOWNLOAD_DIRS_INDEXABLE', 'CUSTOM_DIRS', 'CREATE_CUSTOM_DIRS', 'DELETE_FILE_ON_TRASHCAN', 'DEFAULT_OPTION_PLAYLIST_STRICT_MODE', 'HTTPS')
@ -184,7 +184,7 @@ async def history(request):
history['queue'].append(v)
for _, v in dqueue.done.saved_items():
history['done'].append(v)
for _ ,v in dqueue.pending.saved_items():
for _, v in dqueue.pending.saved_items():
history['pending'].append(v)
log.info("Sending download history")

View file

@ -380,10 +380,7 @@ class DownloadQueue:
if auto_start is True:
download = Download(dldirectory, self.config.TEMP_DIR, output, output_chapter, quality, format, ytdl_options, dl)
self.queue.put(download)
if self.config.DOWNLOAD_MODE == 'sequential':
asyncio.create_task(self.__start_download(download))
else:
asyncio.create_task(self.__start_download(download))
asyncio.create_task(self.__start_download(download))
else:
self.pending.put(Download(dldirectory, self.config.TEMP_DIR, output, output_chapter, quality, format, ytdl_options, dl))
await self.notifier.added(dl)

View file

@ -75,7 +75,7 @@
</select>
</div>
</div>
<div class="col-md-6 col-lg-3 add-url-component">
<div class="col-md-6 col-lg-3 add-url-component d-flex align-items-center">
<div [attr.class]="showAdvanced() ? 'btn-group add-url-group' : 'add-url-group'" ngbDropdown #advancedDropdown="ngbDropdown" display="dynamic" placement="bottom-end">
<button class="btn btn-primary add-url" type="submit" (click)="addDownload()" [disabled]="addInProgress || downloads.loading">
<span class="spinner-border spinner-border-sm" role="status" id="add-spinner" *ngIf="addInProgress"></span>
@ -115,24 +115,30 @@
</div>
</div>
</div>
<div class="btn-group ms-2" ngbDropdown>
<button type="button" class="btn btn-secondary" (click)="openBatchImportModal()">
Import
</button>
<button type="button" class="btn btn-secondary dropdown-toggle dropdown-toggle-split" ngbDropdownToggle>
<span class="visually-hidden">Toggle Dropdown</span>
</button>
<ul ngbDropdownMenu class="dropdown-menu dropdown-menu-end">
<li>
<button class="dropdown-item" (click)="exportBatchUrls('all')">
Export All URLs
</button>
</li>
<li>
<button class="dropdown-item" (click)="copyBatchUrls('all')">
Copy All URLs
</button>
</li>
</ul>
</div>
</div>
</div>
</div>
</form>
<div class="d-flex justify-content-end align-items-center my-3">
<!-- Batch Import Button (opens modal) -->
<button class="btn btn-secondary me-2" (click)="openBatchImportModal()">
Batch Import
</button>
<!-- Batch Export All -->
<button class="btn btn-secondary me-2" (click)="exportBatchUrls('all')">
Batch Export All
</button>
<!-- Batch Copy All -->
<button class="btn btn-secondary me-2" (click)="copyBatchUrls('all')">
Batch Copy All
</button>
</div>
<!-- Batch Import Modal -->
<div class="modal fade" tabindex="-1" role="dialog" [ngClass]="{'show': batchImportModalOpen}" [ngStyle]="{'display': batchImportModalOpen ? 'block' : 'none'}">