mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-04-12 16:31:27 +03:00
Fixed several bugs with categories
Code cleanup
This commit is contained in:
@@ -66,6 +66,7 @@ async function getCategoriesAsPlaylists(files = null) {
|
|||||||
category['thumbnailPath'] = files_that_match[0].thumbnailPath;
|
category['thumbnailPath'] = files_that_match[0].thumbnailPath;
|
||||||
category['duration'] = files_that_match.reduce((a, b) => a + utils.durationStringToNumber(b.duration), 0);
|
category['duration'] = files_that_match.reduce((a, b) => a + utils.durationStringToNumber(b.duration), 0);
|
||||||
category['id'] = category['uid'];
|
category['id'] = category['uid'];
|
||||||
|
category['auto'] = true;
|
||||||
categories_as_playlists.push(category);
|
categories_as_playlists.push(category);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -207,6 +207,8 @@ async function collectInfo(download_uid) {
|
|||||||
info = await exports.getVideoInfoByURL(url, args, download_uid);
|
info = await exports.getVideoInfoByURL(url, args, download_uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
download['category'] = category;
|
||||||
|
|
||||||
// setup info required to calculate download progress
|
// setup info required to calculate download progress
|
||||||
|
|
||||||
const expected_file_size = utils.getExpectedFileSize(info);
|
const expected_file_size = utils.getExpectedFileSize(info);
|
||||||
|
|||||||
@@ -13,4 +13,5 @@ export type Playlist = {
|
|||||||
registered: number;
|
registered: number;
|
||||||
duration: number;
|
duration: number;
|
||||||
user_uid?: string;
|
user_uid?: string;
|
||||||
|
auto?: boolean;
|
||||||
};
|
};
|
||||||
@@ -122,26 +122,6 @@ export class DownloadsComponent implements OnInit, OnDestroy {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
clearFinishedDownloads(): void {
|
|
||||||
const dialogRef = this.dialog.open(ConfirmDialogComponent, {
|
|
||||||
data: {
|
|
||||||
dialogTitle: $localize`Clear finished downloads`,
|
|
||||||
dialogText: $localize`Would you like to clear your finished downloads?`,
|
|
||||||
submitText: $localize`Clear`,
|
|
||||||
warnSubmitColor: true
|
|
||||||
}
|
|
||||||
});
|
|
||||||
dialogRef.afterClosed().subscribe(confirmed => {
|
|
||||||
if (confirmed) {
|
|
||||||
this.postsService.clearDownloads(true, false, false).subscribe(res => {
|
|
||||||
if (!res['success']) {
|
|
||||||
this.postsService.openSnackBar('Failed to clear finished downloads!');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
clearDownloadsByType(): void {
|
clearDownloadsByType(): void {
|
||||||
const clearEmitter = new EventEmitter<boolean>();
|
const clearEmitter = new EventEmitter<boolean>();
|
||||||
const dialogRef = this.dialog.open(ConfirmDialogComponent, {
|
const dialogRef = this.dialog.open(ConfirmDialogComponent, {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { Component, OnInit, Input, Output, EventEmitter, ViewChild } from '@angular/core';
|
import { Component, OnInit, Input, Output, EventEmitter, ViewChild } from '@angular/core';
|
||||||
import { MatDialog } from '@angular/material/dialog';
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
import { VideoInfoDialogComponent } from 'app/dialogs/video-info-dialog/video-info-dialog.component';
|
import { VideoInfoDialogComponent } from 'app/dialogs/video-info-dialog/video-info-dialog.component';
|
||||||
import { DomSanitizer } from '@angular/platform-browser';
|
|
||||||
import { MatMenuTrigger } from '@angular/material/menu';
|
import { MatMenuTrigger } from '@angular/material/menu';
|
||||||
import { registerLocaleData } from '@angular/common';
|
import { registerLocaleData } from '@angular/common';
|
||||||
import localeGB from '@angular/common/locales/en-GB';
|
import localeGB from '@angular/common/locales/en-GB';
|
||||||
@@ -10,6 +9,7 @@ import localeES from '@angular/common/locales/es';
|
|||||||
import localeDE from '@angular/common/locales/de';
|
import localeDE from '@angular/common/locales/de';
|
||||||
import localeZH from '@angular/common/locales/zh';
|
import localeZH from '@angular/common/locales/zh';
|
||||||
import localeNB from '@angular/common/locales/nb';
|
import localeNB from '@angular/common/locales/nb';
|
||||||
|
import { DatabaseFile, Playlist } from 'api-types';
|
||||||
|
|
||||||
registerLocaleData(localeGB);
|
registerLocaleData(localeGB);
|
||||||
registerLocaleData(localeFR);
|
registerLocaleData(localeFR);
|
||||||
@@ -41,7 +41,7 @@ export class UnifiedFileCardComponent implements OnInit {
|
|||||||
// input/output
|
// input/output
|
||||||
@Input() loading = true;
|
@Input() loading = true;
|
||||||
@Input() theme = null;
|
@Input() theme = null;
|
||||||
@Input() file_obj = null;
|
@Input() file_obj: DatabaseFile | Playlist = null;
|
||||||
@Input() card_size = 'medium';
|
@Input() card_size = 'medium';
|
||||||
@Input() use_youtubedl_archive = false;
|
@Input() use_youtubedl_archive = false;
|
||||||
@Input() is_playlist = false;
|
@Input() is_playlist = false;
|
||||||
@@ -51,7 +51,7 @@ export class UnifiedFileCardComponent implements OnInit {
|
|||||||
@Input() jwtString = null;
|
@Input() jwtString = null;
|
||||||
@Input() availablePlaylists = null;
|
@Input() availablePlaylists = null;
|
||||||
@Output() goToFile = new EventEmitter<any>();
|
@Output() goToFile = new EventEmitter<any>();
|
||||||
@Output() goToSubscription = new EventEmitter<any>();
|
@Output() goToSubscription = new EventEmitter<DatabaseFile>();
|
||||||
@Output() deleteFile = new EventEmitter<any>();
|
@Output() deleteFile = new EventEmitter<any>();
|
||||||
@Output() addFileToPlaylist = new EventEmitter<any>();
|
@Output() addFileToPlaylist = new EventEmitter<any>();
|
||||||
@Output() editPlaylist = new EventEmitter<any>();
|
@Output() editPlaylist = new EventEmitter<any>();
|
||||||
@@ -67,7 +67,7 @@ export class UnifiedFileCardComponent implements OnInit {
|
|||||||
big: 250x200
|
big: 250x200
|
||||||
*/
|
*/
|
||||||
|
|
||||||
constructor(private dialog: MatDialog, private sanitizer: DomSanitizer) { }
|
constructor(private dialog: MatDialog) { }
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
if (!this.loading) {
|
if (!this.loading) {
|
||||||
@@ -76,10 +76,6 @@ export class UnifiedFileCardComponent implements OnInit {
|
|||||||
|
|
||||||
if (this.file_obj && this.file_obj.thumbnailPath) {
|
if (this.file_obj && this.file_obj.thumbnailPath) {
|
||||||
this.thumbnailBlobURL = `${this.baseStreamPath}thumbnail/${encodeURIComponent(this.file_obj.thumbnailPath)}?jwt=${this.jwtString}`;
|
this.thumbnailBlobURL = `${this.baseStreamPath}thumbnail/${encodeURIComponent(this.file_obj.thumbnailPath)}?jwt=${this.jwtString}`;
|
||||||
/*const mime = getMimeByFilename(this.file_obj.thumbnailPath);
|
|
||||||
const blob = new Blob([new Uint8Array(this.file_obj.thumbnailBlob.data)], {type: mime});
|
|
||||||
const bloburl = URL.createObjectURL(blob);
|
|
||||||
this.thumbnailBlobURL = this.sanitizer.bypassSecurityTrustUrl(bloburl);*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.file_obj) this.streamURL = this.generateStreamURL();
|
if (this.file_obj) this.streamURL = this.generateStreamURL();
|
||||||
@@ -181,16 +177,3 @@ function fancyTimeFormat(time) {
|
|||||||
ret += '' + secs;
|
ret += '' + secs;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getMimeByFilename(name) {
|
|
||||||
switch (name.substring(name.length-4, name.length)) {
|
|
||||||
case '.jpg':
|
|
||||||
return 'image/jpeg';
|
|
||||||
case '.png':
|
|
||||||
return 'image/png';
|
|
||||||
case 'webp':
|
|
||||||
return 'image/webp';
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user