Show message when Kodi Player fails to get the stream (#40)
This commit is contained in:
parent
fd83e93b1d
commit
c88e7f37c0
@ -156,6 +156,14 @@ msgctxt "#30718"
|
||||
msgid "There is no live stream available for {channel}."
|
||||
msgstr ""
|
||||
|
||||
msgctxt "#30719"
|
||||
msgid "This video cannot be played."
|
||||
msgstr ""
|
||||
|
||||
msgctxt "#30720"
|
||||
msgid "This video is not available abroad."
|
||||
msgstr ""
|
||||
|
||||
|
||||
### SETTINGS
|
||||
msgctxt "#30800"
|
||||
|
@ -157,6 +157,13 @@ msgctxt "#30718"
|
||||
msgid "There is no live stream available for {channel}."
|
||||
msgstr "Er is geen live stream beschikbaar voor {channel}."
|
||||
|
||||
msgctxt "#30719"
|
||||
msgid "This video cannot be played."
|
||||
msgstr "Deze video kan niet afgespeeld worden."
|
||||
|
||||
msgctxt "#30720"
|
||||
msgid "This video is not available abroad."
|
||||
msgstr "Deze video is niet beschikbaar in het buitenland."
|
||||
|
||||
|
||||
### SETTINGS
|
||||
|
@ -48,3 +48,4 @@ def config():
|
||||
""" Setup the logger with this handler """
|
||||
logger = logging.getLogger()
|
||||
logger.addHandler(KodiLogHandler())
|
||||
logger.setLevel(logging.DEBUG)
|
||||
|
@ -8,7 +8,7 @@ import logging
|
||||
import os
|
||||
from time import time
|
||||
|
||||
from xbmc import Monitor
|
||||
from xbmc import getInfoLabel, Monitor, Player
|
||||
|
||||
from resources.lib import kodilogging, kodiutils
|
||||
from resources.lib.viervijfzes.auth import AuthApi
|
||||
@ -25,6 +25,7 @@ class BackgroundService(Monitor):
|
||||
self.update_interval = 24 * 3600 # Every 24 hours
|
||||
self.cache_expiry = 30 * 24 * 3600 # One month
|
||||
self._auth = AuthApi(kodiutils.get_setting('username'), kodiutils.get_setting('password'), kodiutils.get_tokens_path())
|
||||
self._kodiplayer = KodiPlayer()
|
||||
|
||||
def run(self):
|
||||
""" Background loop for maintenance tasks """
|
||||
@ -95,6 +96,87 @@ class BackgroundService(Monitor):
|
||||
os.unlink(fullpath)
|
||||
|
||||
|
||||
class KodiPlayer(Player):
|
||||
"""Communication with Kodi Player"""
|
||||
|
||||
def __init__(self):
|
||||
"""KodiPlayer initialisation"""
|
||||
Player.__init__(self)
|
||||
self.listen = False
|
||||
self.path = None
|
||||
self.av_started = False
|
||||
self.stream_path = None
|
||||
|
||||
def onPlayBackStarted(self): # pylint: disable=invalid-name
|
||||
"""Called when user starts playing a file"""
|
||||
self.path = getInfoLabel('Player.FilenameAndPath')
|
||||
if self.path.startswith('plugin://plugin.video.viervijfzes/'):
|
||||
self.listen = True
|
||||
else:
|
||||
self.listen = False
|
||||
return
|
||||
_LOGGER.debug('KodiPlayer onPlayBackStarted')
|
||||
self.av_started = False
|
||||
self.stream_path = self.getPlayingFile()
|
||||
|
||||
def onAVStarted(self): # pylint: disable=invalid-name
|
||||
"""Called when Kodi has a video or audiostream"""
|
||||
if not self.listen:
|
||||
return
|
||||
_LOGGER.debug('KodiPlayer onAVStarted')
|
||||
self.av_started = True
|
||||
|
||||
def onAVChange(self): # pylint: disable=invalid-name
|
||||
"""Called when Kodi has a video, audio or subtitle stream. Also happens when the stream changes."""
|
||||
if not self.listen:
|
||||
return
|
||||
_LOGGER.debug('KodiPlayer onAVChange')
|
||||
|
||||
def onPlayBackSeek(self, time, seekOffset): # pylint: disable=invalid-name, redefined-outer-name
|
||||
"""Called when user seeks to a time"""
|
||||
if not self.listen:
|
||||
return
|
||||
_LOGGER.debug('KodiPlayer onPlayBackSeek time=%s offset=%s', time, seekOffset)
|
||||
|
||||
def onPlayBackPaused(self): # pylint: disable=invalid-name
|
||||
"""Called when user pauses a playing file"""
|
||||
if not self.listen:
|
||||
return
|
||||
_LOGGER.debug('KodiPlayer onPlayBackPaused')
|
||||
|
||||
def onPlayBackResumed(self): # pylint: disable=invalid-name
|
||||
"""Called when user resumes a paused file or a next playlist item is started"""
|
||||
if not self.listen:
|
||||
return
|
||||
_LOGGER.debug('KodiPlayer onPlayBackResumed')
|
||||
|
||||
def onPlayBackError(self): # pylint: disable=invalid-name
|
||||
"""Called when playback stops due to an error"""
|
||||
if not self.listen:
|
||||
return
|
||||
_LOGGER.debug('KodiPlayer onPlayBackError')
|
||||
|
||||
def onPlayBackStopped(self): # pylint: disable=invalid-name
|
||||
"""Called when user stops Kodi playing a file"""
|
||||
if not self.listen:
|
||||
return
|
||||
_LOGGER.debug('KodiPlayer onPlayBackStopped')
|
||||
if not self.av_started:
|
||||
# Check stream path
|
||||
import requests
|
||||
response = requests.get(self.stream_path)
|
||||
if response.status_code == 403:
|
||||
message_id = 30720
|
||||
else:
|
||||
message_id = 30719
|
||||
kodiutils.ok_dialog(message=kodiutils.localize(message_id))
|
||||
|
||||
def onPlayBackEnded(self): # pylint: disable=invalid-name
|
||||
"""Called when Kodi has ended playing a file"""
|
||||
if not self.listen:
|
||||
return
|
||||
_LOGGER.debug('KodiPlayer onPlayBackEnded')
|
||||
|
||||
def run():
|
||||
""" Run the BackgroundService """
|
||||
BackgroundService().run()
|
||||
|
Loading…
Reference in New Issue
Block a user