1 import { Component, Input, OnInit, ViewChild } from '@angular/core'
2 import { ModalDirective } from 'ngx-bootstrap/modal'
3 import { VideoDetails } from '../../shared/video/video-details.model'
6 selector: 'my-video-download',
7 templateUrl: './video-download.component.html',
8 styleUrls: [ './video-download.component.scss' ]
10 export class VideoDownloadComponent implements OnInit {
11 @Input() video: VideoDetails = null
13 @ViewChild('modal') modal: ModalDirective
15 downloadType: 'direct' | 'torrent' = 'torrent'
23 this.resolution = this.video.files[0].resolution
35 const file = this.video.files.find(f => f.resolution === this.resolution)
37 console.error('Could not find file with resolution %d.', this.resolution)
41 const link = this.downloadType === 'direct' ? file.fileUrl : file.torrentUrl