Added max concurrent downloads setting

Fixed issue where navigating to a subscription video would make the player behave like a playlist for the whole sub
This commit is contained in:
Isaac Abadi
2021-09-15 09:44:31 -06:00
parent dbefb66021
commit 775a1766d8
8 changed files with 18 additions and 7 deletions

View File

@@ -779,7 +779,9 @@ async function autoUpdateYoutubeDL() {
}) })
.catch(err => { .catch(err => {
logger.error(`Failed to check ${default_downloader} version for an update.`) logger.error(`Failed to check ${default_downloader} version for an update.`)
logger.error(err) logger.error(err);
resolve(false);
return false;
}); });
}); });
} }

View File

@@ -13,6 +13,7 @@
"safe_download_override": false, "safe_download_override": false,
"include_thumbnail": true, "include_thumbnail": true,
"include_metadata": true, "include_metadata": true,
"max_concurrent_downloads": 5,
"download_rate_limit": "" "download_rate_limit": ""
}, },
"Extra": { "Extra": {

View File

@@ -188,6 +188,7 @@ const DEFAULT_CONFIG = {
"safe_download_override": false, "safe_download_override": false,
"include_thumbnail": true, "include_thumbnail": true,
"include_metadata": true, "include_metadata": true,
"max_concurrent_downloads": 5,
"download_rate_limit": "" "download_rate_limit": ""
}, },
"Extra": { "Extra": {

View File

@@ -42,6 +42,10 @@ exports.CONFIG_ITEMS = {
'key': 'ytdl_include_metadata', 'key': 'ytdl_include_metadata',
'path': 'YoutubeDLMaterial.Downloader.include_metadata' 'path': 'YoutubeDLMaterial.Downloader.include_metadata'
}, },
'ytdl_max_concurrent_downloads': {
'key': 'ytdl_max_concurrent_downloads',
'path': 'YoutubeDLMaterial.Downloader.max_concurrent_downloads'
},
'ytdl_download_rate_limit': { 'ytdl_download_rate_limit': {
'key': 'ytdl_download_rate_limit', 'key': 'ytdl_download_rate_limit',
'path': 'YoutubeDLMaterial.Downloader.download_rate_limit' 'path': 'YoutubeDLMaterial.Downloader.download_rate_limit'

View File

@@ -156,7 +156,8 @@ async function checkDownloads() {
const waiting_downloads = downloads.filter(download => !download['paused'] && download['finished_step'] && !download['finished']); const waiting_downloads = downloads.filter(download => !download['paused'] && download['finished_step'] && !download['finished']);
for (let i = 0; i < waiting_downloads.length; i++) { for (let i = 0; i < waiting_downloads.length; i++) {
const waiting_download = waiting_downloads[i]; const waiting_download = waiting_downloads[i];
if (running_downloads_count >= 5/*config_api.getConfigItem('ytdl_max_concurrent_downloads')*/) break; const max_concurrent_downloads = config_api.getConfigItem('ytdl_max_concurrent_downloads');
if (max_concurrent_downloads < 0 || running_downloads_count >= max_concurrent_downloads) break;
if (waiting_download['finished_step'] && !waiting_download['finished']) { if (waiting_download['finished_step'] && !waiting_download['finished']) {
// move to next step // move to next step

View File

@@ -184,7 +184,7 @@ export class RecentVideosComponent implements OnInit {
// normal subscriptions // normal subscriptions
!new_tab ? this.router.navigate(['/player', {uid: file.uid, !new_tab ? this.router.navigate(['/player', {uid: file.uid,
type: file.isAudio ? 'audio' : 'video', sub_id: sub.id}]) type: file.isAudio ? 'audio' : 'video', sub_id: sub.id}])
: window.open(`/#/player;uid=${file.uid};type=${file.isAudio ? 'audio' : 'video'};sub_id=${sub.id}`); : window.open(`/#/player;uid=${file.uid};type=${file.isAudio ? 'audio' : 'video'}`);
} }
} else { } else {
// normal files // normal files

View File

@@ -141,10 +141,6 @@ export class UnifiedFileCardComponent implements OnInit {
fullLocation += `&jwt=${this.jwtString}`; fullLocation += `&jwt=${this.jwtString}`;
} }
if (this.file_obj['sub_id']) {
fullLocation += `&sub_id=${this.file_obj['sub_id']}`;
}
fullLocation += '&t=,10'; fullLocation += '&t=,10';
return fullLocation; return fullLocation;

View File

@@ -178,6 +178,12 @@
<div *ngIf="new_config" class="container-fluid"> <div *ngIf="new_config" class="container-fluid">
<div class="row"> <div class="row">
<div class="col-12 mt-3 mb-4"> <div class="col-12 mt-3 mb-4">
<mat-form-field class="text-field" color="accent">
<input type="number" [(ngModel)]="new_config['Downloader']['max_concurrent_downloads']" matInput placeholder="Max concurrent downloads" i18n-placeholder="Max concurrent downloads">
<mat-hint><ng-container i18n="Max concurrent downloads input hint">Limits the amount of downloads that can be simultaneously downloaded. Use -1 for no limit.</ng-container></mat-hint>
</mat-form-field>
</div>
<div class="col-12 mt-2 mb-4">
<mat-form-field class="text-field" color="accent"> <mat-form-field class="text-field" color="accent">
<input [(ngModel)]="new_config['Downloader']['download_rate_limit']" matInput placeholder="Download rate limit" i18n-placeholder="Download rate limit input placeholder"> <input [(ngModel)]="new_config['Downloader']['download_rate_limit']" matInput placeholder="Download rate limit" i18n-placeholder="Download rate limit input placeholder">
<mat-hint><ng-container i18n="Download rate limit input hint">Rate limits your downloads to the specified amount. Ex: 200K</ng-container></mat-hint> <mat-hint><ng-container i18n="Download rate limit input hint">Rate limits your downloads to the specified amount. Ex: 200K</ng-container></mat-hint>