mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-03-25 22:20:56 +03:00
Quality preferences can now be selected for non-YT videos and YT playlists
This commit is contained in:
@@ -77,11 +77,6 @@ export class MainComponent implements OnInit {
|
||||
|
||||
qualityOptions = {
|
||||
'video': [
|
||||
{
|
||||
'resolution': null,
|
||||
'value': '',
|
||||
'label': 'Max'
|
||||
},
|
||||
{
|
||||
'resolution': '3840x2160',
|
||||
'value': '2160',
|
||||
@@ -124,50 +119,47 @@ export class MainComponent implements OnInit {
|
||||
}
|
||||
],
|
||||
'audio': [
|
||||
{
|
||||
'kbitrate': null,
|
||||
'value': '',
|
||||
'label': 'Max'
|
||||
},
|
||||
{
|
||||
'kbitrate': '256',
|
||||
'value': '256K',
|
||||
'label': '256 Kbps'
|
||||
},
|
||||
{
|
||||
'kbitrate': '160',
|
||||
'value': '160K',
|
||||
'label': '160 Kbps'
|
||||
},
|
||||
{
|
||||
'kbitrate': '128',
|
||||
'value': '128K',
|
||||
'label': '128 Kbps'
|
||||
},
|
||||
{
|
||||
'kbitrate': '96',
|
||||
'value': '96K',
|
||||
'label': '96 Kbps'
|
||||
},
|
||||
{
|
||||
'kbitrate': '70',
|
||||
'value': '70K',
|
||||
'label': '70 Kbps'
|
||||
},
|
||||
{
|
||||
'kbitrate': '50',
|
||||
'value': '50K',
|
||||
'label': '50 Kbps'
|
||||
},
|
||||
{
|
||||
'kbitrate': '32',
|
||||
'value': '32K',
|
||||
'label': '32 Kbps'
|
||||
}
|
||||
// TODO: implement
|
||||
// {
|
||||
// 'kbitrate': '256',
|
||||
// 'value': '256K',
|
||||
// 'label': '256 Kbps'
|
||||
// },
|
||||
// {
|
||||
// 'kbitrate': '160',
|
||||
// 'value': '160K',
|
||||
// 'label': '160 Kbps'
|
||||
// },
|
||||
// {
|
||||
// 'kbitrate': '128',
|
||||
// 'value': '128K',
|
||||
// 'label': '128 Kbps'
|
||||
// },
|
||||
// {
|
||||
// 'kbitrate': '96',
|
||||
// 'value': '96K',
|
||||
// 'label': '96 Kbps'
|
||||
// },
|
||||
// {
|
||||
// 'kbitrate': '70',
|
||||
// 'value': '70K',
|
||||
// 'label': '70 Kbps'
|
||||
// },
|
||||
// {
|
||||
// 'kbitrate': '50',
|
||||
// 'value': '50K',
|
||||
// 'label': '50 Kbps'
|
||||
// },
|
||||
// {
|
||||
// 'kbitrate': '32',
|
||||
// 'value': '32K',
|
||||
// 'label': '32 Kbps'
|
||||
// }
|
||||
]
|
||||
}
|
||||
|
||||
selectedQuality = '';
|
||||
selectedMaxQuality = '';
|
||||
selectedQuality: string | unknown = '';
|
||||
formats_loading = false;
|
||||
|
||||
@ViewChild('urlinput', { read: ElementRef }) urlInput: ElementRef;
|
||||
@@ -378,7 +370,7 @@ export class MainComponent implements OnInit {
|
||||
const urls = this.getURLArray(this.url);
|
||||
for (let i = 0; i < urls.length; i++) {
|
||||
const url = urls[i];
|
||||
this.postsService.downloadFile(url, type as FileType, (selected_quality === '' ? null : selected_quality),
|
||||
this.postsService.downloadFile(url, type as FileType, (customQualityConfiguration || selected_quality === '' || typeof selected_quality !== 'string' ? null : selected_quality),
|
||||
customQualityConfiguration, customArgs, additionalArgs, customOutput, youtubeUsername, youtubePassword, cropFileSettings).subscribe(res => {
|
||||
this.current_download = res['download'];
|
||||
this.downloads.push(res['download']);
|
||||
@@ -410,7 +402,7 @@ export class MainComponent implements OnInit {
|
||||
}
|
||||
|
||||
getSelectedAudioFormat(): string {
|
||||
if (this.selectedQuality === '') { return null; }
|
||||
if (typeof this.selectedQuality === 'string') { return null; }
|
||||
const cachedFormatsExists = this.cachedAvailableFormats[this.url] && this.cachedAvailableFormats[this.url]['formats'];
|
||||
if (cachedFormatsExists) {
|
||||
return this.selectedQuality['format_id'];
|
||||
@@ -420,7 +412,7 @@ export class MainComponent implements OnInit {
|
||||
}
|
||||
|
||||
getSelectedVideoFormat(): string {
|
||||
if (this.selectedQuality === '') { return null; }
|
||||
if (typeof this.selectedQuality === 'string') { return null; }
|
||||
const cachedFormats = this.cachedAvailableFormats[this.url] && this.cachedAvailableFormats[this.url]['formats'];
|
||||
if (cachedFormats) {
|
||||
if (this.selectedQuality) {
|
||||
@@ -496,6 +488,7 @@ export class MainComponent implements OnInit {
|
||||
}
|
||||
|
||||
inputChanged(new_val: string): void {
|
||||
this.selectedQuality = '';
|
||||
if (new_val === '' || !new_val) {
|
||||
this.results_showing = false;
|
||||
} else {
|
||||
@@ -537,13 +530,16 @@ export class MainComponent implements OnInit {
|
||||
}
|
||||
|
||||
getURLInfo(url: string): void {
|
||||
// if url is a youtube playlist, skip getting url info
|
||||
if (url.includes('playlist')) {
|
||||
return;
|
||||
}
|
||||
if (!this.cachedAvailableFormats[url]) {
|
||||
this.cachedAvailableFormats[url] = {};
|
||||
}
|
||||
// if url is a youtube playlist, skip getting url info
|
||||
if (url.includes('playlist')) {
|
||||
// make it think that formats errored so that users have options
|
||||
this.cachedAvailableFormats[url]['formats_loading'] = false;
|
||||
this.cachedAvailableFormats[url]['formats_failed'] = true;
|
||||
return;
|
||||
}
|
||||
if (!(this.cachedAvailableFormats[url] && this.cachedAvailableFormats[url]['formats'])) {
|
||||
this.cachedAvailableFormats[url]['formats_loading'] = true;
|
||||
this.postsService.getFileFormats([url]).subscribe(res => {
|
||||
@@ -584,7 +580,7 @@ export class MainComponent implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
this.postsService.generateArgs(this.url, type as FileType, (this.selectedQuality === '' ? null : this.selectedQuality),
|
||||
this.postsService.generateArgs(this.url, type as FileType, (customQualityConfiguration || this.selectedQuality === '' || typeof this.selectedQuality !== 'string' ? null : this.selectedQuality),
|
||||
customQualityConfiguration, customArgs, additionalArgs, customOutput, youtubeUsername, youtubePassword, cropFileSettings).subscribe(res => {
|
||||
const simulated_args = res['args'];
|
||||
if (simulated_args) {
|
||||
@@ -601,6 +597,7 @@ export class MainComponent implements OnInit {
|
||||
|
||||
errorFormats(url: string): void {
|
||||
this.cachedAvailableFormats[url]['formats_loading'] = false;
|
||||
this.cachedAvailableFormats[url]['formats_failed'] = true;
|
||||
console.error('Could not load formats for url ' + url);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user