Added a timeout of 10 seconds to download the torrent's metadata.
This commit is contained in:
parent
267e15cc0f
commit
0750029db7
15
peertube.py
15
peertube.py
|
@ -195,14 +195,23 @@ class PeertubeAddon():
|
||||||
"""
|
"""
|
||||||
|
|
||||||
xbmc.log('PeertubeAddon: playing video ' + torrent_url, xbmc.LOGDEBUG)
|
xbmc.log('PeertubeAddon: playing video ' + torrent_url, xbmc.LOGDEBUG)
|
||||||
|
|
||||||
# Start a downloader thread
|
# Start a downloader thread
|
||||||
AddonSignals.sendSignal('start_download', {'url': torrent_url})
|
AddonSignals.sendSignal('start_download', {'url': torrent_url})
|
||||||
|
|
||||||
# Wait until the PeerTubeDownloader has downloaded all the torrent's metadata + a little bit more
|
# Wait until the PeerTubeDownloader has downloaded all the torrent's metadata
|
||||||
# TODO: Add a timeout
|
|
||||||
AddonSignals.registerSlot('plugin.video.peertube', 'metadata_downloaded', self.play_video_continue)
|
AddonSignals.registerSlot('plugin.video.peertube', 'metadata_downloaded', self.play_video_continue)
|
||||||
while self.play == 0:
|
timeout = 0
|
||||||
|
while self.play == 0 and timeout < 10:
|
||||||
xbmc.sleep(1000)
|
xbmc.sleep(1000)
|
||||||
|
timeout += 1
|
||||||
|
|
||||||
|
# Abort in case of timeout
|
||||||
|
if timeout == 10:
|
||||||
|
xbmcgui.Dialog().notification('Download timeout', 'Timeout fetching ' + torrent_url, xbmcgui.NOTIFICATION_ERROR)
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
# Wait a little before starting playing the torrent
|
||||||
xbmc.sleep(3000)
|
xbmc.sleep(3000)
|
||||||
|
|
||||||
# Pass the item to the Kodi player for actual playback.
|
# Pass the item to the Kodi player for actual playback.
|
||||||
|
|
Loading…
Reference in New Issue