aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-08-25 11:36:23 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-08-25 11:36:23 +0200
commit93e1258c7cbc0d1235ca6d2a1f7c1875985328b8 (patch)
treeb0a1f77af7ab54dc5f58f569fcd1e9d84b04c533 /client/src
parent69f224587e99d56008e1fa129d0641840a486620 (diff)
downloadPeerTube-93e1258c7cbc0d1235ca6d2a1f7c1875985328b8.tar.gz
PeerTube-93e1258c7cbc0d1235ca6d2a1f7c1875985328b8.tar.zst
PeerTube-93e1258c7cbc0d1235ca6d2a1f7c1875985328b8.zip
Move video file metadata in their own table
Will be used for user video quotas and multiple video resolutions
Diffstat (limited to 'client/src')
-rw-r--r--client/src/app/videos/shared/video.model.ts21
-rw-r--r--client/src/app/videos/video-watch/video-magnet.component.html2
-rw-r--r--client/src/app/videos/video-watch/video-watch.component.ts10
-rw-r--r--client/src/standalone/videos/embed.ts6
4 files changed, 25 insertions, 14 deletions
diff --git a/client/src/app/videos/shared/video.model.ts b/client/src/app/videos/shared/video.model.ts
index f0556343f..438791368 100644
--- a/client/src/app/videos/shared/video.model.ts
+++ b/client/src/app/videos/shared/video.model.ts
@@ -1,4 +1,4 @@
1import { Video as VideoServerModel } from '../../../../../shared' 1import { Video as VideoServerModel, VideoFile } from '../../../../../shared'
2import { User } from '../../shared' 2import { User } from '../../shared'
3 3
4export class Video implements VideoServerModel { 4export class Video implements VideoServerModel {
@@ -17,7 +17,6 @@ export class Video implements VideoServerModel {
17 id: number 17 id: number
18 uuid: string 18 uuid: string
19 isLocal: boolean 19 isLocal: boolean
20 magnetUri: string
21 name: string 20 name: string
22 podHost: string 21 podHost: string
23 tags: string[] 22 tags: string[]
@@ -29,6 +28,7 @@ export class Video implements VideoServerModel {
29 likes: number 28 likes: number
30 dislikes: number 29 dislikes: number
31 nsfw: boolean 30 nsfw: boolean
31 files: VideoFile[]
32 32
33 private static createByString (author: string, podHost: string) { 33 private static createByString (author: string, podHost: string) {
34 return author + '@' + podHost 34 return author + '@' + podHost
@@ -57,7 +57,6 @@ export class Video implements VideoServerModel {
57 id: number, 57 id: number,
58 uuid: string, 58 uuid: string,
59 isLocal: boolean, 59 isLocal: boolean,
60 magnetUri: string,
61 name: string, 60 name: string,
62 podHost: string, 61 podHost: string,
63 tags: string[], 62 tags: string[],
@@ -66,7 +65,8 @@ export class Video implements VideoServerModel {
66 views: number, 65 views: number,
67 likes: number, 66 likes: number,
68 dislikes: number, 67 dislikes: number,
69 nsfw: boolean 68 nsfw: boolean,
69 files: VideoFile[]
70 }) { 70 }) {
71 this.author = hash.author 71 this.author = hash.author
72 this.createdAt = new Date(hash.createdAt) 72 this.createdAt = new Date(hash.createdAt)
@@ -82,7 +82,6 @@ export class Video implements VideoServerModel {
82 this.id = hash.id 82 this.id = hash.id
83 this.uuid = hash.uuid 83 this.uuid = hash.uuid
84 this.isLocal = hash.isLocal 84 this.isLocal = hash.isLocal
85 this.magnetUri = hash.magnetUri
86 this.name = hash.name 85 this.name = hash.name
87 this.podHost = hash.podHost 86 this.podHost = hash.podHost
88 this.tags = hash.tags 87 this.tags = hash.tags
@@ -94,6 +93,7 @@ export class Video implements VideoServerModel {
94 this.likes = hash.likes 93 this.likes = hash.likes
95 this.dislikes = hash.dislikes 94 this.dislikes = hash.dislikes
96 this.nsfw = hash.nsfw 95 this.nsfw = hash.nsfw
96 this.files = hash.files
97 97
98 this.by = Video.createByString(hash.author, hash.podHost) 98 this.by = Video.createByString(hash.author, hash.podHost)
99 } 99 }
@@ -115,6 +115,13 @@ export class Video implements VideoServerModel {
115 return (this.nsfw && (!user || user.displayNSFW === false)) 115 return (this.nsfw && (!user || user.displayNSFW === false))
116 } 116 }
117 117
118 getDefaultMagnetUri () {
119 if (this.files === undefined || this.files.length === 0) return ''
120
121 // TODO: choose the original file
122 return this.files[0].magnetUri
123 }
124
118 patch (values: Object) { 125 patch (values: Object) {
119 Object.keys(values).forEach((key) => { 126 Object.keys(values).forEach((key) => {
120 this[key] = values[key] 127 this[key] = values[key]
@@ -132,7 +139,6 @@ export class Video implements VideoServerModel {
132 duration: this.duration, 139 duration: this.duration,
133 id: this.id, 140 id: this.id,
134 isLocal: this.isLocal, 141 isLocal: this.isLocal,
135 magnetUri: this.magnetUri,
136 name: this.name, 142 name: this.name,
137 podHost: this.podHost, 143 podHost: this.podHost,
138 tags: this.tags, 144 tags: this.tags,
@@ -140,7 +146,8 @@ export class Video implements VideoServerModel {
140 views: this.views, 146 views: this.views,
141 likes: this.likes, 147 likes: this.likes,
142 dislikes: this.dislikes, 148 dislikes: this.dislikes,
143 nsfw: this.nsfw 149 nsfw: this.nsfw,
150 files: this.files
144 } 151 }
145 } 152 }
146} 153}
diff --git a/client/src/app/videos/video-watch/video-magnet.component.html b/client/src/app/videos/video-watch/video-magnet.component.html
index 3fa82f1be..5b0324e37 100644
--- a/client/src/app/videos/video-watch/video-magnet.component.html
+++ b/client/src/app/videos/video-watch/video-magnet.component.html
@@ -10,7 +10,7 @@
10 </div> 10 </div>
11 11
12 <div class="modal-body"> 12 <div class="modal-body">
13 <input #magnetUriInput (click)="magnetUriInput.select()" type="text" class="form-control input-sm readonly" readonly [value]="video.magnetUri" /> 13 <input #magnetUriInput (click)="magnetUriInput.select()" type="text" class="form-control input-sm readonly" readonly [value]="video.getDefaultMagnetUri()" />
14 </div> 14 </div>
15 </div> 15 </div>
16 </div> 16 </div>
diff --git a/client/src/app/videos/video-watch/video-watch.component.ts b/client/src/app/videos/video-watch/video-watch.component.ts
index cd11aa33c..255757692 100644
--- a/client/src/app/videos/video-watch/video-watch.component.ts
+++ b/client/src/app/videos/video-watch/video-watch.component.ts
@@ -90,8 +90,8 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
90 window.clearInterval(this.torrentInfosInterval) 90 window.clearInterval(this.torrentInfosInterval)
91 window.clearTimeout(this.errorTimer) 91 window.clearTimeout(this.errorTimer)
92 92
93 if (this.video !== null && this.webTorrentService.has(this.video.magnetUri)) { 93 if (this.video !== null && this.webTorrentService.has(this.video.getDefaultMagnetUri())) {
94 this.webTorrentService.remove(this.video.magnetUri) 94 this.webTorrentService.remove(this.video.getDefaultMagnetUri())
95 } 95 }
96 96
97 // Remove player 97 // Remove player
@@ -108,13 +108,13 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
108 // We are loading the video 108 // We are loading the video
109 this.loading = true 109 this.loading = true
110 110
111 console.log('Adding ' + this.video.magnetUri + '.') 111 console.log('Adding ' + this.video.getDefaultMagnetUri() + '.')
112 112
113 // The callback might never return if there are network issues 113 // The callback might never return if there are network issues
114 // So we create a timer to inform the user the load is abnormally long 114 // So we create a timer to inform the user the load is abnormally long
115 this.errorTimer = window.setTimeout(() => this.loadTooLong(), VideoWatchComponent.LOADTIME_TOO_LONG) 115 this.errorTimer = window.setTimeout(() => this.loadTooLong(), VideoWatchComponent.LOADTIME_TOO_LONG)
116 116
117 const torrent = this.webTorrentService.add(this.video.magnetUri, torrent => { 117 const torrent = this.webTorrentService.add(this.video.getDefaultMagnetUri(), torrent => {
118 // Clear the error timer 118 // Clear the error timer
119 window.clearTimeout(this.errorTimer) 119 window.clearTimeout(this.errorTimer)
120 // Maybe the error was fired by the timer, so reset it 120 // Maybe the error was fired by the timer, so reset it
@@ -123,7 +123,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
123 // We are not loading the video anymore 123 // We are not loading the video anymore
124 this.loading = false 124 this.loading = false
125 125
126 console.log('Added ' + this.video.magnetUri + '.') 126 console.log('Added ' + this.video.getDefaultMagnetUri() + '.')
127 torrent.files[0].renderTo(this.playerElement, (err) => { 127 torrent.files[0].renderTo(this.playerElement, (err) => {
128 if (err) { 128 if (err) {
129 this.notificationsService.error('Error', 'Cannot append the file in the video element.') 129 this.notificationsService.error('Error', 'Cannot append the file in the video element.')
diff --git a/client/src/standalone/videos/embed.ts b/client/src/standalone/videos/embed.ts
index 64a0f0798..0698344b0 100644
--- a/client/src/standalone/videos/embed.ts
+++ b/client/src/standalone/videos/embed.ts
@@ -57,7 +57,11 @@ loadVideoInfos(videoId, (err, videoInfos) => {
57 return 57 return
58 } 58 }
59 59
60 const magnetUri = videoInfos.magnetUri 60 let magnetUri = ''
61 if (videoInfos.files !== undefined && videoInfos.files.length !== 0) {
62 magnetUri = videoInfos.files[0].magnetUri
63 }
64
61 const videoContainer = document.getElementById('video-container') as HTMLVideoElement 65 const videoContainer = document.getElementById('video-container') as HTMLVideoElement
62 const previewUrl = window.location.origin + videoInfos.previewPath 66 const previewUrl = window.location.origin + videoInfos.previewPath
63 videoContainer.poster = previewUrl 67 videoContainer.poster = previewUrl