mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-03-26 22:50:58 +03:00
downloads refactor half done - videos are now implement, but audo files are now
Added downloads manager in the UI where downloads can be viewed/cleared
This commit is contained in:
@@ -8,6 +8,7 @@ import { THEMES_CONFIG } from '../themes';
|
||||
import { Router } from '@angular/router';
|
||||
import { DOCUMENT } from '@angular/common';
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
|
||||
@Injectable()
|
||||
export class PostsService {
|
||||
@@ -21,7 +22,9 @@ export class PostsService {
|
||||
theme;
|
||||
settings_changed = new BehaviorSubject<boolean>(false);
|
||||
auth_token = '4241b401-7236-493e-92b5-b72696b9d853';
|
||||
session_id = null;
|
||||
httpOptions = null;
|
||||
http_params: string = null;
|
||||
|
||||
debugMode = false;
|
||||
constructor(private http: HttpClient, private router: Router, @Inject(DOCUMENT) private document: Document) {
|
||||
@@ -29,15 +32,17 @@ export class PostsService {
|
||||
// this.startPath = window.location.href + '/api/';
|
||||
// this.startPathSSL = window.location.href + '/api/';
|
||||
this.path = this.document.location.origin + '/api/';
|
||||
|
||||
this.session_id = uuid();
|
||||
if (isDevMode()) {
|
||||
this.debugMode = true;
|
||||
this.path = 'http://localhost:17442/api/';
|
||||
}
|
||||
|
||||
this.http_params = `apiKey=${this.auth_token}&sessionID=${this.session_id}`
|
||||
|
||||
this.httpOptions = {
|
||||
params: new HttpParams({
|
||||
fromString: `apiKey=${this.auth_token}`
|
||||
fromString: this.http_params
|
||||
}),
|
||||
};
|
||||
}
|
||||
@@ -220,6 +225,13 @@ export class PostsService {
|
||||
return this.http.get(this.path + 'downloads', this.httpOptions);
|
||||
}
|
||||
|
||||
// clear downloads. download_id is optional, if it exists only 1 download will be cleared
|
||||
clearDownloads(delete_all = false, session_id = null, download_id = null) {
|
||||
return this.http.post(this.path + 'clearDownloads', {delete_all: delete_all,
|
||||
download_id: download_id,
|
||||
session_id: session_id ? session_id : this.session_id}, this.httpOptions);
|
||||
}
|
||||
|
||||
// updates the server to the latest version
|
||||
updateServer(tag) {
|
||||
return this.http.post(this.path + 'updateServer', {tag: tag}, this.httpOptions);
|
||||
|
||||
Reference in New Issue
Block a user