aboutsummaryrefslogtreecommitdiffhomepage
path: root/client
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-03-23 09:46:08 +0100
committerChocobozzz <me@florianbigard.com>2018-03-23 09:46:08 +0100
commita216c6233d46689f73a7c542e6170555b7f287b6 (patch)
tree1fe332e7df218a20c0a90a05884c986bd3a5eb1d /client
parentd63fd4f7b1e41ef7b05fd97abff5c4cebbea63df (diff)
downloadPeerTube-a216c6233d46689f73a7c542e6170555b7f287b6.tar.gz
PeerTube-a216c6233d46689f73a7c542e6170555b7f287b6.tar.zst
PeerTube-a216c6233d46689f73a7c542e6170555b7f287b6.zip
Fallback to torrent file if there is an incorrect info hash
Diffstat (limited to 'client')
-rw-r--r--client/src/assets/player/peertube-videojs-plugin.ts23
1 files changed, 18 insertions, 5 deletions
diff --git a/client/src/assets/player/peertube-videojs-plugin.ts b/client/src/assets/player/peertube-videojs-plugin.ts
index c99363fb5..f4064c4b2 100644
--- a/client/src/assets/player/peertube-videojs-plugin.ts
+++ b/client/src/assets/player/peertube-videojs-plugin.ts
@@ -302,9 +302,16 @@ class PeerTubePlugin extends Plugin {
302 const previousVideoFile = this.currentVideoFile 302 const previousVideoFile = this.currentVideoFile
303 this.currentVideoFile = videoFile 303 this.currentVideoFile = videoFile
304 304
305 console.log('Adding ' + videoFile.magnetUri + '.') 305 this.addTorrent(this.currentVideoFile.magnetUri, previousVideoFile, done)
306 this.torrent = webtorrent.add(videoFile.magnetUri, torrent => { 306
307 console.log('Added ' + videoFile.magnetUri + '.') 307 this.trigger('videoFileUpdate')
308 }
309
310 addTorrent (magnetOrTorrentUrl: string, previousVideoFile: VideoFile, done: Function) {
311 console.log('Adding ' + magnetOrTorrentUrl + '.')
312
313 this.torrent = webtorrent.add(magnetOrTorrentUrl, torrent => {
314 console.log('Added ' + magnetOrTorrentUrl + '.')
308 315
309 this.flushVideoFile(previousVideoFile) 316 this.flushVideoFile(previousVideoFile)
310 317
@@ -325,19 +332,25 @@ class PeerTubePlugin extends Plugin {
325 }) 332 })
326 333
327 this.torrent.on('error', err => this.handleError(err)) 334 this.torrent.on('error', err => this.handleError(err))
335
328 this.torrent.on('warning', (err: any) => { 336 this.torrent.on('warning', (err: any) => {
329 // We don't support HTTP tracker but we don't care -> we use the web socket tracker 337 // We don't support HTTP tracker but we don't care -> we use the web socket tracker
330 if (err.message.indexOf('Unsupported tracker protocol') !== -1) return 338 if (err.message.indexOf('Unsupported tracker protocol') !== -1) return
339
331 // Users don't care about issues with WebRTC, but developers do so log it in the console 340 // Users don't care about issues with WebRTC, but developers do so log it in the console
332 if (err.message.indexOf('Ice connection failed') !== -1) { 341 if (err.message.indexOf('Ice connection failed') !== -1) {
333 console.error(err) 342 console.error(err)
334 return 343 return
335 } 344 }
336 345
346 // Magnet hash is not up to date with the torrent file, add directly the torrent file
347 if (err.message.indexOf('incorrect info hash') !== -1) {
348 console.error('Incorrect info hash detected, falling back to torrent file.')
349 return this.addTorrent(this.torrent['xs'], previousVideoFile, done)
350 }
351
337 return this.handleError(err) 352 return this.handleError(err)
338 }) 353 })
339
340 this.trigger('videoFileUpdate')
341 } 354 }
342 355
343 updateResolution (resolutionId: number) { 356 updateResolution (resolutionId: number) {