X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fvideos%2F%2Bvideo-watch%2Fmodal%2Fvideo-download.component.ts;h=12f31b011a093fbbd6e0916b1b3eb12263edfb9c;hb=960a11e89da4e4a6ad6fbad61c71625f89e267b6;hp=1a73ea6df0de8796e62ad23f4935db614c1bee1c;hpb=4635f59d7c3fea4b97029f10886c62fdf38b2084;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/videos/+video-watch/modal/video-download.component.ts b/client/src/app/videos/+video-watch/modal/video-download.component.ts index 1a73ea6df..12f31b011 100644 --- a/client/src/app/videos/+video-watch/modal/video-download.component.ts +++ b/client/src/app/videos/+video-watch/modal/video-download.component.ts @@ -13,14 +13,14 @@ export class VideoDownloadComponent implements OnInit { @ViewChild('modal') modal: ModalDirective downloadType: 'direct' | 'torrent' = 'torrent' - resolution = -1 + resolutionId: number | string = -1 constructor () { // empty } ngOnInit () { - this.resolution = this.video.files[0].resolution + this.resolutionId = this.video.files[0].resolution.id } show () { @@ -32,13 +32,16 @@ export class VideoDownloadComponent implements OnInit { } download () { - const file = this.video.files.find(f => f.resolution === this.resolution) + // HTML select send us a string, so convert it to a number + this.resolutionId = parseInt(this.resolutionId.toString(), 10) + + const file = this.video.files.find(f => f.resolution.id === this.resolutionId) if (!file) { - console.error('Could not find file with resolution %d.', this.resolution) + console.error('Could not find file with resolution %d.', this.resolutionId) return } - const link = this.downloadType === 'direct' ? file.fileUrl : file.torrentUrl - window.open(link) + const link = this.downloadType === 'direct' ? file.fileDownloadUrl : file.torrentDownloadUrl + window.location.assign(link) } }