-
- getAppropriateMagnetUri (actualDownloadSpeed = 0) {
- if (this.files === undefined || this.files.length === 0) return ''
- if (this.files.length === 1) return this.files[0].magnetUri
-
- // Find first video that is good for our download speed (remember they are sorted)
- let betterResolutionFile = this.files.find(f => actualDownloadSpeed > (f.size / this.duration))
-
- // If the download speed is too bad, return the lowest resolution we have
- if (betterResolutionFile === undefined) {
- betterResolutionFile = this.files.find(f => f.resolution === VideoResolution.H_240P)
- }
-
- return betterResolutionFile.magnetUri
- }
-
- patch (values: Object) {
- Object.keys(values).forEach((key) => {
- this[key] = values[key]
- })
- }
-
- toJSON () {
- return {
- author: this.author,
- createdAt: this.createdAt,
- category: this.category,
- licence: this.licence,
- language: this.language,
- description: this.description,
- duration: this.duration,
- id: this.id,
- isLocal: this.isLocal,
- name: this.name,
- podHost: this.podHost,
- tags: this.tags,
- thumbnailPath: this.thumbnailPath,
- views: this.views,
- likes: this.likes,
- dislikes: this.dislikes,
- nsfw: this.nsfw,
- files: this.files
- }
- }