mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-03-22 04:30:56 +03:00
Subscriptions now support multi-user-mode
Fixed bug where playlist subscription downloads would fail due to a mislabeled parameter Components that are routes now make sure auth is finished before sending requests to the backend
This commit is contained in:
@@ -196,6 +196,7 @@ export class MainComponent implements OnInit {
|
||||
|
||||
selectedQuality = '';
|
||||
formats_loading = false;
|
||||
config_loaded = false;
|
||||
|
||||
@ViewChild('urlinput', { read: ElementRef }) urlInput: ElementRef;
|
||||
@ViewChildren('audiofilecard') audioFileCards: QueryList<FileCardComponent>;
|
||||
@@ -294,7 +295,16 @@ export class MainComponent implements OnInit {
|
||||
|
||||
// app initialization.
|
||||
ngOnInit() {
|
||||
this.configLoad();
|
||||
if (this.postsService.config) {
|
||||
this.configLoad();
|
||||
} else {
|
||||
this.postsService.config_reloaded.subscribe(changed => {
|
||||
if (changed && !this.config_loaded) {
|
||||
this.config_loaded = true;
|
||||
this.configLoad();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
this.postsService.config_reloaded.subscribe(changed => {
|
||||
if (changed) {
|
||||
|
||||
@@ -79,45 +79,15 @@ export class PlayerComponent implements OnInit {
|
||||
this.uuid = this.route.snapshot.paramMap.get('uuid');
|
||||
|
||||
// loading config
|
||||
this.postsService.loadNavItems().subscribe(res => { // loads settings
|
||||
const result = !this.postsService.debugMode ? res['config_file'] : res;
|
||||
this.baseStreamPath = this.postsService.path;
|
||||
this.audioFolderPath = result['YoutubeDLMaterial']['Downloader']['path-audio'];
|
||||
this.videoFolderPath = result['YoutubeDLMaterial']['Downloader']['path-video'];
|
||||
this.subscriptionFolderPath = result['YoutubeDLMaterial']['Subscriptions']['subscriptions_base_path'];
|
||||
this.fileNames = this.route.snapshot.paramMap.get('fileNames') ? this.route.snapshot.paramMap.get('fileNames').split('|nvr|') : null;
|
||||
|
||||
if (!this.fileNames) {
|
||||
this.is_shared = true;
|
||||
}
|
||||
|
||||
if (this.uid && !this.id) {
|
||||
this.getFile();
|
||||
} else if (this.id) {
|
||||
this.getPlaylistFiles();
|
||||
}
|
||||
|
||||
if (this.url) {
|
||||
// if a url is given, just stream the URL
|
||||
this.playlist = [];
|
||||
const imedia: IMedia = {
|
||||
title: this.name,
|
||||
label: this.name,
|
||||
src: this.url,
|
||||
type: 'video/mp4'
|
||||
if (this.postsService.config) {
|
||||
this.processConfig();
|
||||
} else {
|
||||
this.postsService.config_reloaded.subscribe(changed => { // loads settings
|
||||
if (changed) {
|
||||
this.processConfig();
|
||||
}
|
||||
this.playlist.push(imedia);
|
||||
this.currentItem = this.playlist[0];
|
||||
this.currentIndex = 0;
|
||||
this.show_player = true;
|
||||
} else if (this.type === 'subscription' || this.fileNames) {
|
||||
this.show_player = true;
|
||||
this.parseFileNames();
|
||||
}
|
||||
});
|
||||
|
||||
// this.getFileInfos();
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
constructor(private postsService: PostsService, private route: ActivatedRoute, private dialog: MatDialog, private router: Router,
|
||||
@@ -125,6 +95,42 @@ export class PlayerComponent implements OnInit {
|
||||
|
||||
}
|
||||
|
||||
processConfig() {
|
||||
this.baseStreamPath = this.postsService.path;
|
||||
this.audioFolderPath = this.postsService.config['Downloader']['path-audio'];
|
||||
this.videoFolderPath = this.postsService.config['Downloader']['path-video'];
|
||||
this.subscriptionFolderPath = this.postsService.config['Subscriptions']['subscriptions_base_path'];
|
||||
this.fileNames = this.route.snapshot.paramMap.get('fileNames') ? this.route.snapshot.paramMap.get('fileNames').split('|nvr|') : null;
|
||||
|
||||
if (!this.fileNames) {
|
||||
this.is_shared = true;
|
||||
}
|
||||
|
||||
if (this.uid && !this.id) {
|
||||
this.getFile();
|
||||
} else if (this.id) {
|
||||
this.getPlaylistFiles();
|
||||
}
|
||||
|
||||
if (this.url) {
|
||||
// if a url is given, just stream the URL
|
||||
this.playlist = [];
|
||||
const imedia: IMedia = {
|
||||
title: this.name,
|
||||
label: this.name,
|
||||
src: this.url,
|
||||
type: 'video/mp4'
|
||||
}
|
||||
this.playlist.push(imedia);
|
||||
this.currentItem = this.playlist[0];
|
||||
this.currentIndex = 0;
|
||||
this.show_player = true;
|
||||
} else if (this.type === 'subscription' || this.fileNames) {
|
||||
this.show_player = true;
|
||||
this.parseFileNames();
|
||||
}
|
||||
}
|
||||
|
||||
getFile() {
|
||||
const already_has_filenames = !!this.fileNames;
|
||||
this.postsService.getFile(this.uid, null, this.uuid).subscribe(res => {
|
||||
@@ -191,10 +197,10 @@ export class PlayerComponent implements OnInit {
|
||||
|
||||
// adds user token if in multi-user-mode
|
||||
if (this.postsService.isLoggedIn) {
|
||||
fullLocation += `?jwt=${this.postsService.token}`;
|
||||
fullLocation += (this.subscriptionName ? '&' : '?') + `jwt=${this.postsService.token}`;
|
||||
if (this.is_shared) { fullLocation += `&uuid=${this.uuid}&uid=${this.db_file.uid}&type=${this.db_file.type}`; }
|
||||
} else if (this.is_shared) {
|
||||
fullLocation += `?uuid=${this.uuid}&uid=${this.db_file.uid}&type=${this.db_file.type}`;
|
||||
fullLocation += (this.subscriptionName ? '&' : '?') + `uuid=${this.uuid}&uid=${this.db_file.uid}&type=${this.db_file.type}`;
|
||||
}
|
||||
// if it has a slash (meaning it's in a directory), only get the file name for the label
|
||||
let label = null;
|
||||
|
||||
@@ -74,6 +74,8 @@ export class PostsService implements CanActivate {
|
||||
};
|
||||
this.jwtAuth();
|
||||
}
|
||||
} else {
|
||||
this.config_reloaded.next(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -107,7 +109,7 @@ export class PostsService implements CanActivate {
|
||||
const result = !this.debugMode ? res['config_file'] : res;
|
||||
if (result) {
|
||||
this.config = result['YoutubeDLMaterial'];
|
||||
this.config_reloaded = true;
|
||||
this.config_reloaded.next(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -348,6 +350,7 @@ export class PostsService implements CanActivate {
|
||||
call.subscribe(res => {
|
||||
if (res['token']) {
|
||||
this.afterLogin(res['user'], res['token']);
|
||||
this.config_reloaded.next(true);
|
||||
}
|
||||
}, err => {
|
||||
if (err.status === 401) {
|
||||
|
||||
@@ -49,10 +49,10 @@ export class SubscriptionComponent implements OnInit {
|
||||
if (this.route.snapshot.paramMap.get('id')) {
|
||||
this.id = this.route.snapshot.paramMap.get('id');
|
||||
|
||||
this.getSubscription();
|
||||
this.postsService.config_reloaded.subscribe(changed => {
|
||||
if (changed) {
|
||||
this.getConfig();
|
||||
this.getSubscription();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -93,7 +93,7 @@ export class SubscriptionComponent implements OnInit {
|
||||
this.router.navigate(['/player', {name: name, url: url}]);
|
||||
} else {
|
||||
this.router.navigate(['/player', {fileNames: name, type: 'subscription', subscriptionName: this.subscription.name,
|
||||
subPlaylist: this.subscription.isPlaylist}]);
|
||||
subPlaylist: this.subscription.isPlaylist, uuid: this.postsService.user ? this.postsService.user.uid : null}]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,16 +22,23 @@ export class SubscriptionsComponent implements OnInit {
|
||||
constructor(private dialog: MatDialog, public postsService: PostsService, private router: Router, private snackBar: MatSnackBar) { }
|
||||
|
||||
ngOnInit() {
|
||||
this.getSubscriptions();
|
||||
if (this.postsService.config) {
|
||||
this.getSubscriptions();
|
||||
}
|
||||
this.postsService.config_reloaded.subscribe(changed => {
|
||||
if (changed) {
|
||||
this.getSubscriptions();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
getSubscriptions() {
|
||||
this.subscriptions_loading = true;
|
||||
this.subscriptions = null;
|
||||
this.channel_subscriptions = [];
|
||||
this.playlist_subscriptions = [];
|
||||
this.postsService.getAllSubscriptions().subscribe(res => {
|
||||
this.subscriptions_loading = false;
|
||||
this.channel_subscriptions = [];
|
||||
this.playlist_subscriptions = [];
|
||||
this.subscriptions_loading = false;
|
||||
this.subscriptions = res['subscriptions'];
|
||||
if (!this.subscriptions) {
|
||||
// set it to an empty array so it can notify the user there are no subscriptions
|
||||
|
||||
Reference in New Issue
Block a user