|
|
|
|
@ -231,80 +231,72 @@ export class MainComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
async loadConfig() {
|
|
|
|
|
// loading config
|
|
|
|
|
this.postsService.loadNavItems().subscribe(res => { // loads settings
|
|
|
|
|
const result = !this.postsService.debugMode ? res['config_file'] : res;
|
|
|
|
|
this.fileManagerEnabled = result['YoutubeDLMaterial']['Extra']['file_manager_enabled'];
|
|
|
|
|
this.downloadOnlyMode = result['YoutubeDLMaterial']['Extra']['download_only_mode'];
|
|
|
|
|
this.allowMultiDownloadMode = result['YoutubeDLMaterial']['Extra']['allow_multi_download_mode'];
|
|
|
|
|
this.audioFolderPath = result['YoutubeDLMaterial']['Downloader']['path-audio'];
|
|
|
|
|
this.videoFolderPath = result['YoutubeDLMaterial']['Downloader']['path-video'];
|
|
|
|
|
this.use_youtubedl_archive = result['YoutubeDLMaterial']['Downloader']['use_youtubedl_archive'];
|
|
|
|
|
this.globalCustomArgs = result['YoutubeDLMaterial']['Downloader']['custom_args'];
|
|
|
|
|
this.youtubeSearchEnabled = result['YoutubeDLMaterial']['API'] && result['YoutubeDLMaterial']['API']['use_youtube_API'] &&
|
|
|
|
|
result['YoutubeDLMaterial']['API']['youtube_API_key'];
|
|
|
|
|
this.youtubeAPIKey = this.youtubeSearchEnabled ? result['YoutubeDLMaterial']['API']['youtube_API_key'] : null;
|
|
|
|
|
this.allowQualitySelect = result['YoutubeDLMaterial']['Extra']['allow_quality_select'];
|
|
|
|
|
this.allowAdvancedDownload = result['YoutubeDLMaterial']['Advanced']['allow_advanced_download'];
|
|
|
|
|
this.useDefaultDownloadingAgent = result['YoutubeDLMaterial']['Advanced']['use_default_downloading_agent'];
|
|
|
|
|
this.customDownloadingAgent = result['YoutubeDLMaterial']['Advanced']['custom_downloading_agent'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this.fileManagerEnabled) {
|
|
|
|
|
this.getMp3s();
|
|
|
|
|
this.getMp4s();
|
|
|
|
|
}
|
|
|
|
|
this.fileManagerEnabled = this.postsService.config['Extra']['file_manager_enabled'];
|
|
|
|
|
this.downloadOnlyMode = this.postsService.config['Extra']['download_only_mode'];
|
|
|
|
|
this.allowMultiDownloadMode = this.postsService.config['Extra']['allow_multi_download_mode'];
|
|
|
|
|
this.audioFolderPath = this.postsService.config['Downloader']['path-audio'];
|
|
|
|
|
this.videoFolderPath = this.postsService.config['Downloader']['path-video'];
|
|
|
|
|
this.use_youtubedl_archive = this.postsService.config['Downloader']['use_youtubedl_archive'];
|
|
|
|
|
this.globalCustomArgs = this.postsService.config['Downloader']['custom_args'];
|
|
|
|
|
this.youtubeSearchEnabled = this.postsService.config['API'] && this.postsService.config['API']['use_youtube_API'] &&
|
|
|
|
|
this.postsService.config['API']['youtube_API_key'];
|
|
|
|
|
this.youtubeAPIKey = this.youtubeSearchEnabled ? this.postsService.config['API']['youtube_API_key'] : null;
|
|
|
|
|
this.allowQualitySelect = this.postsService.config['Extra']['allow_quality_select'];
|
|
|
|
|
this.allowAdvancedDownload = this.postsService.config['Advanced']['allow_advanced_download'];
|
|
|
|
|
this.useDefaultDownloadingAgent = this.postsService.config['Advanced']['use_default_downloading_agent'];
|
|
|
|
|
this.customDownloadingAgent = this.postsService.config['Advanced']['custom_downloading_agent'];
|
|
|
|
|
|
|
|
|
|
if (this.youtubeSearchEnabled && this.youtubeAPIKey) {
|
|
|
|
|
this.youtubeSearch.initializeAPI(this.youtubeAPIKey);
|
|
|
|
|
this.attachToInput();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// set final cache items
|
|
|
|
|
if (this.allowAdvancedDownload) {
|
|
|
|
|
if (localStorage.getItem('customArgsEnabled') !== null) {
|
|
|
|
|
this.customArgsEnabled = localStorage.getItem('customArgsEnabled') === 'true';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (localStorage.getItem('customOutputEnabled') !== null) {
|
|
|
|
|
this.customOutputEnabled = localStorage.getItem('customOutputEnabled') === 'true';
|
|
|
|
|
}
|
|
|
|
|
if (this.fileManagerEnabled) {
|
|
|
|
|
this.getMp3s();
|
|
|
|
|
this.getMp4s();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (localStorage.getItem('youtubeAuthEnabled') !== null) {
|
|
|
|
|
this.youtubeAuthEnabled = localStorage.getItem('youtubeAuthEnabled') === 'true';
|
|
|
|
|
}
|
|
|
|
|
if (this.youtubeSearchEnabled && this.youtubeAPIKey) {
|
|
|
|
|
this.youtubeSearch.initializeAPI(this.youtubeAPIKey);
|
|
|
|
|
this.attachToInput();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// set advanced inputs
|
|
|
|
|
const customArgs = localStorage.getItem('customArgs');
|
|
|
|
|
const customOutput = localStorage.getItem('customOutput');
|
|
|
|
|
const youtubeUsername = localStorage.getItem('youtubeUsername');
|
|
|
|
|
// set final cache items
|
|
|
|
|
if (this.allowAdvancedDownload) {
|
|
|
|
|
if (localStorage.getItem('customArgsEnabled') !== null) {
|
|
|
|
|
this.customArgsEnabled = localStorage.getItem('customArgsEnabled') === 'true';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (customArgs && customArgs !== 'null') { this.customArgs = customArgs };
|
|
|
|
|
if (customOutput && customOutput !== 'null') { this.customOutput = customOutput };
|
|
|
|
|
if (youtubeUsername && youtubeUsername !== 'null') { this.youtubeUsername = youtubeUsername };
|
|
|
|
|
if (localStorage.getItem('customOutputEnabled') !== null) {
|
|
|
|
|
this.customOutputEnabled = localStorage.getItem('customOutputEnabled') === 'true';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// get downloads routine
|
|
|
|
|
setInterval(() => {
|
|
|
|
|
if (this.current_download) {
|
|
|
|
|
this.getCurrentDownload();
|
|
|
|
|
}
|
|
|
|
|
}, 500);
|
|
|
|
|
if (localStorage.getItem('youtubeAuthEnabled') !== null) {
|
|
|
|
|
this.youtubeAuthEnabled = localStorage.getItem('youtubeAuthEnabled') === 'true';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
// set advanced inputs
|
|
|
|
|
const customArgs = localStorage.getItem('customArgs');
|
|
|
|
|
const customOutput = localStorage.getItem('customOutput');
|
|
|
|
|
const youtubeUsername = localStorage.getItem('youtubeUsername');
|
|
|
|
|
|
|
|
|
|
}, error => {
|
|
|
|
|
console.log(error);
|
|
|
|
|
if (customArgs && customArgs !== 'null') { this.customArgs = customArgs };
|
|
|
|
|
if (customOutput && customOutput !== 'null') { this.customOutput = customOutput };
|
|
|
|
|
if (youtubeUsername && youtubeUsername !== 'null') { this.youtubeUsername = youtubeUsername };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
// get downloads routine
|
|
|
|
|
setInterval(() => {
|
|
|
|
|
if (this.current_download) {
|
|
|
|
|
this.getCurrentDownload();
|
|
|
|
|
}
|
|
|
|
|
}, 500);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// app initialization.
|
|
|
|
|
ngOnInit() {
|
|
|
|
|
this.configLoad();
|
|
|
|
|
|
|
|
|
|
this.postsService.settings_changed.subscribe(changed => {
|
|
|
|
|
this.postsService.config_reloaded.subscribe(changed => {
|
|
|
|
|
if (changed) {
|
|
|
|
|
this.loadConfig();
|
|
|
|
|
}
|
|
|
|
|
|