Added logging
This commit is contained in:
parent
8110fa2b7d
commit
914bcb9234
|
@ -20,6 +20,8 @@
|
||||||
<email>cyrille.bollu2@gmail.com</email>
|
<email>cyrille.bollu2@gmail.com</email>
|
||||||
<source>https://github.com/StCyr/plugin.video.peertube</source>
|
<source>https://github.com/StCyr/plugin.video.peertube</source>
|
||||||
<news>
|
<news>
|
||||||
|
0.0.3
|
||||||
|
Second PoC (download in background is almost there)
|
||||||
0.0.2
|
0.0.2
|
||||||
First PoC (download not in background)
|
First PoC (download not in background)
|
||||||
0.0.1
|
0.0.1
|
||||||
|
|
|
@ -30,6 +30,7 @@ class PeertubeAddon():
|
||||||
"""
|
"""
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
xbmc.log('PeertubeAddon: Initialising', xbmc.LOGINFO)
|
||||||
# Nothing to play at initialisation
|
# Nothing to play at initialisation
|
||||||
self.play = 0
|
self.play = 0
|
||||||
self.torrent_name = ''
|
self.torrent_name = ''
|
||||||
|
@ -119,6 +120,7 @@ class PeertubeAddon():
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
xbmc.log('PeertubeAddon: Received metadata_downloaded signal, will start playing media', xbmc.LOGINFO)
|
||||||
self.play = 1
|
self.play = 1
|
||||||
self.torrent_name = data['name']
|
self.torrent_name = data['name']
|
||||||
|
|
||||||
|
@ -131,6 +133,7 @@ class PeertubeAddon():
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
xbmc.log('PeertubeAddon: playing video ' + magnet_f, xbmc.LOGINFO)
|
||||||
# Start a downloader thread
|
# Start a downloader thread
|
||||||
AddonSignals.sendSignal('start_download', {'magnet_f': magnet_f})
|
AddonSignals.sendSignal('start_download', {'magnet_f': magnet_f})
|
||||||
|
|
||||||
|
|
14
service.py
14
service.py
|
@ -24,6 +24,7 @@ class PeertubeDownloader(Thread):
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
xbmc.log('PeertubeDownloader: Starting a torrent download', xbmc.LOGINFO)
|
||||||
# Open bitTorrent session
|
# Open bitTorrent session
|
||||||
ses = libtorrent.session()
|
ses = libtorrent.session()
|
||||||
ses.listen_on(6881, 6891)
|
ses.listen_on(6881, 6891)
|
||||||
|
@ -33,6 +34,7 @@ class PeertubeDownloader(Thread):
|
||||||
magnet = f.read()
|
magnet = f.read()
|
||||||
|
|
||||||
# Add torrent
|
# Add torrent
|
||||||
|
xbmc.log('PeertubeDownloader: Adding torrent ' + magnet, xbmc.LOGINFO)
|
||||||
fpath = xbmc.translatePath('special://temp')
|
fpath = xbmc.translatePath('special://temp')
|
||||||
h = ses.add_torrent({'url': magnet, 'save_path': fpath})
|
h = ses.add_torrent({'url': magnet, 'save_path': fpath})
|
||||||
|
|
||||||
|
@ -42,10 +44,11 @@ class PeertubeDownloader(Thread):
|
||||||
# Download torrent
|
# Download torrent
|
||||||
signal_sent = 0
|
signal_sent = 0
|
||||||
while not h.is_seed():
|
while not h.is_seed():
|
||||||
time.sleep(1)
|
xbmc.sleep(1000)
|
||||||
s = h.status()
|
s = h.status()
|
||||||
# Inform addon that all the metadata has been downloaded and that it may start playing the torrent
|
# Inform addon that all the metadata has been downloaded and that it may start playing the torrent
|
||||||
if s.state >=3 and signal_sent == 0:
|
if s.state >=3 and signal_sent == 0:
|
||||||
|
xbmc.log('PeertubeDownloader: Received all torrent metadata, notifying PeertubeAddon', xbmc.LOGINFO)
|
||||||
AddonSignals.sendSignal('metadata_downloaded', {'name': h.name()} )
|
AddonSignals.sendSignal('metadata_downloaded', {'name': h.name()} )
|
||||||
signal_sent = 1
|
signal_sent = 1
|
||||||
|
|
||||||
|
@ -61,6 +64,7 @@ class PeertubeService():
|
||||||
PeertubeService initialisation function
|
PeertubeService initialisation function
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
xbmc.log('PeertubeService: Initialising', xbmc.LOGINFO)
|
||||||
# Create our temporary directory
|
# Create our temporary directory
|
||||||
fpath = xbmc.translatePath('special://temp') + '/plugin.video.peertube'
|
fpath = xbmc.translatePath('special://temp') + '/plugin.video.peertube'
|
||||||
if not xbmcvfs.exists(fpath):
|
if not xbmcvfs.exists(fpath):
|
||||||
|
@ -73,8 +77,11 @@ class PeertubeService():
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
xbmc.log('PeertubeService: Received a start_download signal', xbmc.LOGINFO)
|
||||||
downloader = PeertubeDownloader(data['magnet_f'])
|
downloader = PeertubeDownloader(data['magnet_f'])
|
||||||
downloader.start()
|
downloader.start()
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
"""
|
"""
|
||||||
|
@ -86,15 +93,20 @@ class PeertubeService():
|
||||||
AddonSignals.registerSlot('plugin.video.peertube', 'start_download', self.download_torrent)
|
AddonSignals.registerSlot('plugin.video.peertube', 'start_download', self.download_torrent)
|
||||||
|
|
||||||
# Monitor Kodi's shutdown signal
|
# Monitor Kodi's shutdown signal
|
||||||
|
xbmc.log('PeertubeService: service started, Waiting for signals', xbmc.LOGINFO)
|
||||||
monitor = xbmc.Monitor()
|
monitor = xbmc.Monitor()
|
||||||
while not monitor.abortRequested():
|
while not monitor.abortRequested():
|
||||||
if monitor.waitForAbort(1):
|
if monitor.waitForAbort(1):
|
||||||
# Abort was requested while waiting. We must exit
|
# Abort was requested while waiting. We must exit
|
||||||
# TODO: I must delete all temp files before exiting
|
# TODO: I must delete all temp files before exiting
|
||||||
break
|
break
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# Start a peertubeService instance
|
# Start a peertubeService instance
|
||||||
|
xbmc.log('PeertubeService: Starting', xbmc.LOGINFO)
|
||||||
service = PeertubeService()
|
service = PeertubeService()
|
||||||
service.run()
|
service.run()
|
||||||
|
xbmc.log('PeertubeService: Exiting', xbmc.LOGINFO)
|
||||||
|
|
Loading…
Reference in New Issue