diff --git a/src/app/components/recent-videos/recent-videos.component.html b/src/app/components/recent-videos/recent-videos.component.html
index ad39fa5..88a276b 100644
--- a/src/app/components/recent-videos/recent-videos.component.html
+++ b/src/app/components/recent-videos/recent-videos.component.html
@@ -2,7 +2,7 @@
diff --git a/src/app/components/recent-videos/recent-videos.component.ts b/src/app/components/recent-videos/recent-videos.component.ts
index dec95fd..9555507 100644
--- a/src/app/components/recent-videos/recent-videos.component.ts
+++ b/src/app/components/recent-videos/recent-videos.component.ts
@@ -13,6 +13,7 @@ export class RecentVideosComponent implements OnInit {
subscription_files_received = false;
files: any[] = null;
card_size = 'medium';
+ downloading_content = {'video': {}, 'audio': {}};
constructor(private postsService: PostsService, private router: Router) { }
@@ -32,6 +33,8 @@ export class RecentVideosComponent implements OnInit {
});
}
+ // navigation
+
goToFile(file) {
if (this.postsService.config['Extra']['download_only_mode']) {
this.downloadFile(file);
@@ -57,18 +60,84 @@ export class RecentVideosComponent implements OnInit {
}
}
- downloadFile(file) {
- if (file.sub_id) {
-
- } else {
-
- }
- }
-
goToSubscription(file) {
this.router.navigate(['/subscription', {id: file.sub_id}]);
}
+ // downloading
+
+ downloadFile(file) {
+ if (file.sub_id) {
+ this.downloadSubscriptionFile(file);
+ } else {
+ this.downloadNormalFile(file);
+ }
+ }
+
+ downloadSubscriptionFile(file) {
+ const type = file.isAudio ? 'audio' : 'video';
+ const ext = type === 'audio' ? '.mp3' : '.mp4'
+ const sub = this.postsService.getSubscriptionByID(file.sub_id);
+ console.log(sub.isPlaylist)
+ this.postsService.downloadFileFromServer(file.id, type, null, null, sub.name, sub.isPlaylist,
+ this.postsService.user ? this.postsService.user.uid : null, null).subscribe(res => {
+ const blob: Blob = res;
+ saveAs(blob, file.id + ext);
+ }, err => {
+ console.log(err);
+ });
+ }
+
+ downloadNormalFile(file) {
+ const type = file.isAudio ? 'audio' : 'video';
+ const ext = type === 'audio' ? '.mp3' : '.mp4'
+ const name = file.id;
+ this.downloading_content[type][name] = true;
+ this.postsService.downloadFileFromServer(name, type).subscribe(res => {
+ this.downloading_content[type][name] = false;
+ const blob: Blob = res;
+ saveAs(blob, decodeURIComponent(name) + ext);
+
+ if (!this.postsService.config.Extra.file_manager_enabled) {
+ // tell server to delete the file once downloaded
+ this.postsService.deleteFile(name, false).subscribe(delRes => {
+ // reload mp4s
+ this.getAllFiles();
+ });
+ }
+ });
+ }
+
+ // deleting
+
+ deleteAndRedownload(file) {
+ const sub = this.postsService.getSubscriptionByID(file.sub_id);
+ this.postsService.deleteSubscriptionFile(sub, file.id, false, file.uid).subscribe(res => {
+ this.postsService.openSnackBar(`Successfully deleted file: '${file.id}'`);
+ });
+ }
+
+ deleteForever(file) {
+ const sub = this.postsService.getSubscriptionByID(file.sub_id);
+ this.postsService.deleteSubscriptionFile(sub, file.id, true, file.uid).subscribe(res => {
+ this.postsService.openSnackBar(`Successfully deleted file: '${file.id}'`);
+ });
+ }
+
+ deleteNormalFile(file, blacklistMode = false) {
+ this.postsService.deleteFile(file.uid, file.isAudio, blacklistMode).subscribe(result => {
+ if (result) {
+ this.postsService.openSnackBar('Delete success!', 'OK.');
+ } else {
+ this.postsService.openSnackBar('Delete failed!', 'OK.');
+ }
+ }, err => {
+ this.postsService.openSnackBar('Delete failed!', 'OK.');
+ });
+ }
+
+ // sorting and filtering
+
sortFiles(a, b) {
// uses the 'registered' flag as the timestamp
const result = b.registered - a.registered;
diff --git a/src/app/components/unified-file-card/unified-file-card.component.html b/src/app/components/unified-file-card/unified-file-card.component.html
index 862b6ab..e61e082 100644
--- a/src/app/components/unified-file-card/unified-file-card.component.html
+++ b/src/app/components/unified-file-card/unified-file-card.component.html
@@ -1,18 +1,20 @@
-
+
{{file_obj.isAudio ? 'audiotrack' : 'movie'}} {{file_obj.registered | date:'shortDate'}}
-
-
-
+
diff --git a/src/app/components/unified-file-card/unified-file-card.component.ts b/src/app/components/unified-file-card/unified-file-card.component.ts
index ca8e27e..7c27721 100644
--- a/src/app/components/unified-file-card/unified-file-card.component.ts
+++ b/src/app/components/unified-file-card/unified-file-card.component.ts
@@ -14,10 +14,11 @@ export class UnifiedFileCardComponent implements OnInit {
file_length = '';
file_thumbnail = '';
type = null;
- use_youtubedl_archive = false;
+ elevated = false;
@Input() file_obj = null;
@Input() card_size = 'medium';
+ @Input() use_youtubedl_archive = false;
@Output() goToFile = new EventEmitter
();
@Output() goToSubscription = new EventEmitter();
diff --git a/src/app/main/main.component.html b/src/app/main/main.component.html
index 63cb3a2..3993de4 100644
--- a/src/app/main/main.component.html
+++ b/src/app/main/main.component.html
@@ -1,9 +1,6 @@