add the ability to reload 'YTDL_OPTIONS' when file is modified

This commit is contained in:
xerdream
2025-07-21 11:20:53 +08:00
parent ca0aac4051
commit afbf8b07d6
7 changed files with 215 additions and 2 deletions

View File

@@ -388,6 +388,11 @@
<span class="version-value">{{metubeVersion}}</span>
</div>
<div class="version-separator"></div>
<div class="version-item" *ngIf="ytDlpOptionsUpdateTime">
<span class="version-label">yt-dlp-options</span>
<span class="version-value">{{ytDlpOptionsUpdateTime}}</span>
</div>
<div class="version-separator" *ngIf="ytDlpOptionsUpdateTime"></div>
<a href="https://github.com/alexta69/metube" target="_blank" class="github-link">
<fa-icon [icon]="faGithub"></fa-icon>
<span>GitHub</span>

View File

@@ -39,6 +39,7 @@ export class AppComponent implements AfterViewInit {
batchImportStatus = '';
importInProgress = false;
cancelImportFlag = false;
ytDlpOptionsUpdateTime: string | null = null;
ytDlpVersion: string | null = null;
metubeVersion: string | null = null;
isAdvancedOpen = false;
@@ -101,6 +102,7 @@ export class AppComponent implements AfterViewInit {
ngOnInit() {
this.getConfiguration();
this.getYtdlOptionsUpdateTime();
this.customDirs$ = this.getMatchingCustomDir();
this.setTheme(this.activeTheme);
@@ -174,6 +176,18 @@ export class AppComponent implements AfterViewInit {
);
}
getYtdlOptionsUpdateTime() {
this.downloads.ytdlOptionsChanged.subscribe({
next: (data) => {
if (data['success']){
const date = new Date(data['update_time'] * 1000);
this.ytDlpOptionsUpdateTime=date.toLocaleString();
}else{
alert("Error reload yt-dlp options: "+data['msg']);
}
}
});
}
getConfiguration() {
this.downloads.configurationChanged.subscribe({
next: (config) => {

View File

@@ -39,6 +39,7 @@ export class DownloadsService {
queueChanged = new Subject();
doneChanged = new Subject();
customDirsChanged = new Subject();
ytdlOptionsChanged = new Subject();
configurationChanged = new Subject();
updated = new Subject();
@@ -98,6 +99,10 @@ export class DownloadsService {
this.customDirs = data;
this.customDirsChanged.next(data);
});
socket.fromEvent('ytdl_options_changed').subscribe((strdata: string) => {
let data = JSON.parse(strdata);
this.ytdlOptionsChanged.next(data);
});
}
handleHTTPError(error: HttpErrorResponse) {