mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-04-22 11:43:20 +03:00
Unified videos videos are now properly retrieved from the server
This commit is contained in:
@@ -2047,21 +2047,50 @@ app.post('/api/getFile', optionalJwt, function (req, res) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
app.post('/api/getAllFiles', optionalJwt, function (req, res) {
|
app.post('/api/getAllFiles', optionalJwt, function (req, res) {
|
||||||
files = null;
|
// these are returned
|
||||||
playlists = null;
|
let files = [];
|
||||||
if (req.isAuthenticated()) {
|
let playlists = [];
|
||||||
const videos = auth_api.getUserVideos(req.user.uid, 'video');
|
let subscription_files = [];
|
||||||
const audios = auth_api.getUserVideos(req.user.uid, 'audio');
|
|
||||||
const audio_playlists = null;
|
|
||||||
const video_playlists = null;
|
|
||||||
} else {
|
|
||||||
|
|
||||||
|
let videos = null;
|
||||||
|
let audios = null;
|
||||||
|
let audio_playlists = null;
|
||||||
|
let video_playlists = null;
|
||||||
|
let subscriptions = subscriptions_api.getAllSubscriptions(req.isAuthenticated() ? req.user.uid : null);
|
||||||
|
|
||||||
|
// get basic info depending on multi-user mode being enabled
|
||||||
|
if (req.isAuthenticated()) {
|
||||||
|
videos = auth_api.getUserVideos(req.user.uid, 'video');
|
||||||
|
audios = auth_api.getUserVideos(req.user.uid, 'audio');
|
||||||
|
audio_playlists = auth_api.getUserPlaylists(req.user.uid, 'audio');
|
||||||
|
video_playlists = auth_api.getUserPlaylists(req.user.uid, 'video');
|
||||||
|
} else {
|
||||||
|
videos = db.get('files.audio').value();
|
||||||
|
audios = db.get('files.video').value();
|
||||||
|
audio_playlists = db.get('playlists.audio').value();
|
||||||
|
video_playlists = db.get('playlists.video').value();
|
||||||
|
}
|
||||||
|
|
||||||
|
files = videos.concat(audios);
|
||||||
|
playlists = video_playlists.concat(audio_playlists);
|
||||||
|
|
||||||
|
// loop through subscriptions and add videos
|
||||||
|
for (let i = 0; i < subscriptions.length; i++) {
|
||||||
|
sub = subscriptions[i];
|
||||||
|
console.log(sub);
|
||||||
|
if (!sub.videos) continue;
|
||||||
|
// add sub id for UI
|
||||||
|
for (let j = 0; j < sub.videos.length; j++) {
|
||||||
|
sub.videos[j].sub_id = sub.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
files = files.concat(sub.videos);
|
||||||
}
|
}
|
||||||
|
|
||||||
res.send({
|
res.send({
|
||||||
files: files,
|
files: files,
|
||||||
playlists: playlists
|
playlists: playlists
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// video sharing
|
// video sharing
|
||||||
|
|||||||
@@ -15,10 +15,19 @@ export class RecentVideosComponent implements OnInit {
|
|||||||
constructor(private postsService: PostsService) { }
|
constructor(private postsService: PostsService) { }
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
this.postsService.service_initialized.subscribe(init => {
|
||||||
|
if (init) {
|
||||||
|
this.getAllFiles();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getAllFiles() {
|
getAllFiles() {
|
||||||
|
this.normal_files_received = false;
|
||||||
|
this.postsService.getAllFiles().subscribe(res => {
|
||||||
|
this.files = res['files'];
|
||||||
|
this.files.sort(this.sortFiles);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
sortFiles(a, b) {
|
sortFiles(a, b) {
|
||||||
|
|||||||
@@ -14,8 +14,8 @@
|
|||||||
</mat-menu>
|
</mat-menu>
|
||||||
<mat-card (click)="navigateToFile()" matRipple class="example-card mat-elevation-z6">
|
<mat-card (click)="navigateToFile()" matRipple class="example-card mat-elevation-z6">
|
||||||
<div style="padding:5px">
|
<div style="padding:5px">
|
||||||
<div *ngIf="fileThumbnail" class="img-div">
|
<div *ngIf="file_obj.thumbnailURL" class="img-div">
|
||||||
<img class="image" [src]="file_thumbnail" alt="Thumbnail">
|
<img class="image" [src]="file_obj.thumbnailURL" alt="Thumbnail">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<span class="max-two-lines"><strong>{{file_title}}</strong></span>
|
<span class="max-two-lines"><strong>{{file_title}}</strong></span>
|
||||||
|
|||||||
@@ -207,6 +207,10 @@ export class PostsService implements CanActivate {
|
|||||||
return this.http.post(this.path + 'getFile', {uid: uid, type: type, uuid: uuid}, this.httpOptions);
|
return this.http.post(this.path + 'getFile', {uid: uid, type: type, uuid: uuid}, this.httpOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getAllFiles() {
|
||||||
|
return this.http.post(this.path + 'getAllFiles', {}, this.httpOptions);
|
||||||
|
}
|
||||||
|
|
||||||
downloadFileFromServer(fileName, type, outputName = null, fullPathProvided = null, subscriptionName = null, subPlaylist = null,
|
downloadFileFromServer(fileName, type, outputName = null, fullPathProvided = null, subscriptionName = null, subPlaylist = null,
|
||||||
uid = null, uuid = null) {
|
uid = null, uuid = null) {
|
||||||
return this.http.post(this.path + 'downloadFile', {fileNames: fileName,
|
return this.http.post(this.path + 'downloadFile', {fileNames: fileName,
|
||||||
|
|||||||
Reference in New Issue
Block a user