mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-03-13 16:20:59 +03:00
82 lines
2.1 KiB
TypeScript
82 lines
2.1 KiB
TypeScript
import {Injectable, isDevMode} from '@angular/core';
|
|
import { HttpClient } from '@angular/common/http';
|
|
import config from '../assets/default.json';
|
|
import 'rxjs/add/operator/map';
|
|
import { Observable } from 'rxjs/Observable';
|
|
import 'rxjs/add/operator/map';
|
|
import 'rxjs/add/operator/catch';
|
|
import 'rxjs/add/observable/throw';
|
|
|
|
@Injectable()
|
|
export class PostsService {
|
|
path = '';
|
|
audioFolder = '';
|
|
videoFolder = '';
|
|
startPath = 'http://localhost:17442/';
|
|
startPathSSL = 'https://localhost:17442/'
|
|
handShakeComplete = false;
|
|
|
|
constructor(private http: HttpClient) {
|
|
console.log('PostsService Initialized...');
|
|
}
|
|
|
|
startHandshake(url: string) {
|
|
return this.http.get(url + 'geturl');
|
|
}
|
|
|
|
startHandshakeSSL(url: string) {
|
|
return this.http.get(url + 'geturl');
|
|
}
|
|
|
|
getVideoFolder() {
|
|
return this.http.get(this.startPath + 'videofolder');
|
|
}
|
|
|
|
getAudioFolder() {
|
|
return this.http.get(this.startPath + 'audiofolder');
|
|
}
|
|
|
|
makeMP3(url: string) {
|
|
return this.http.post(this.path + 'tomp3', {url: url});
|
|
}
|
|
|
|
makeMP4(url: string) {
|
|
return this.http.post(this.path + 'tomp4', {url: url});
|
|
}
|
|
|
|
getFileStatusMp3(name: string) {
|
|
return this.http.post(this.path + 'fileStatusMp3', {name: name});
|
|
}
|
|
|
|
getFileStatusMp4(name: string) {
|
|
return this.http.post(this.path + 'fileStatusMp4', {name: name});
|
|
}
|
|
|
|
loadNavItems() {
|
|
if (isDevMode()) {
|
|
return this.http.get('./assets/default.json');
|
|
}
|
|
console.log('Config location: ' + window.location.href + 'backend/config/default.json');
|
|
return this.http.get(window.location.href + 'backend/config/default.json');
|
|
}
|
|
|
|
deleteFile(name: string, isAudio: boolean) {
|
|
if (isAudio) {
|
|
return this.http.post(this.path + 'deleteMp3', {name: name});
|
|
} else {
|
|
return this.http.post(this.path + 'deleteMp4', {name: name});
|
|
}
|
|
}
|
|
|
|
getMp3s() {
|
|
return this.http.post(this.path + 'getMp3s', {});
|
|
}
|
|
|
|
getMp4s() {
|
|
return this.http.post(this.path + 'getMp4s', {});
|
|
}
|
|
}
|
|
|
|
|
|
|