def timeexclusion(): time = xbmc.Player().getTotalTime() debug('Total time: %s' % str(datetime.timedelta(seconds=round(time)))) timeexcluded = int(setting('excludetime'))*60 if time > timeexcluded: return True else: debug('Excluded: the content time is lower than the exclusion') return False
def wordsexclusion(): if setting('excludewords'): words = setting('excludewords').split(',') if all(videopath().find (v) <= -1 for v in words): return True else: debug('Excluded: the video path have excluded words %s' % words) return False else: return True
def addonexclusion(): if setting('excludeaddon'): exaddon = setting('excludeaddon').split(',') if all(videosource().find (v) <= -1 for v in exaddon): return True else: debug('Excluded: the source addon is excluded %s' % exaddon) return False else: return True
def onAVStarted(self): """ Will be called when Kodi has a video or audiostream """ utils.trace("Player: [onAVStarted] called") if self.subs: utils.debug("Player: Setting subtitle: %s", self.subs[0]) self.setSubtitles(self.subs[0]) utils.debug("Player: Showing subtitles") self.showSubtitles(self.show_subs) self.__playback_started()
def subexclusion(): if boolsetting('excludesub'): langs = [] langs.append(utils.langdict[setting('excludesublang1')]) if not setting('excludesublang2') == "-----": langs.append(utils.langdict[setting('excludesublang2')]) if not setting('excludesublang3') == "-----": langs.append(utils.langdict[setting('excludesublang3')]) availablesubs = xbmc.Player().getAvailableSubtitleStreams() debug('Available sub languages: %s' % availablesubs) availablesubs = " ".join(availablesubs) if any(x in availablesubs for x in langs): debug('Subtitle is already present') return False return True return True
def waitForPlayBack(self, url=None, time_out=30): """ Blocks the call until playback is started. :param str url: The url that should start playing :param int time_out: Maximum time to wait. This method checks whether the playback started. If an url was specified, it will wait for that url to be the active one playing before returning. """ utils.debug("Player: Waiting for playback") if self.__is_url_playing(url): self.__playBackEventsTriggered = True utils.debug("Player: Already Playing") return # noinspection PyTypeChecker for i in range(0, int(time_out / self.__pollInterval)): if self.__monitor.abortRequested(): utils.debug("Player: Abort requested (%s)", i * self.__pollInterval) return if self.__is_url_playing(url): utils.debug("Player: PlayBack started (%s)", i * self.__pollInterval) return if self.__playPlayBackEndedEventsTriggered: utils.warning( "Player: PlayBackEnded triggered while waiting for start.") return self.__monitor.waitForAbort(self.__pollInterval) utils.trace("Player: Waiting for an abort (%s)", i * self.__pollInterval) utils.warning("Player: time-out occurred waiting for playback (%s)", time_out) return
def onAVStarted(self): self.run = True delay = int(setting('delay')) * 1000 if self.run: xbmc.sleep(delay) if xbmc.Player().isPlayingVideo() and globalexclusion(): self.run = False if setting('default') == '0': debug('Default: automatic subtitles') loadsub() elif setting('default') == '1': debug('Default: opening search dialog') xbmc.executebuiltin('ActivateWindow(SubtitleSearch)') else: debug('Default: do nothing...') else: self.run = False
def audioexclusion(): if boolsetting('excludeaudio'): langs = [] langs.append(utils.langdict[setting('excludeaudiolang1')]) if not setting('excludeaudiolang2') == "-----": langs.append(utils.langdict[setting('excludeaudiolang2')]) if not setting('excludeaudiolang3') == "-----": langs.append(utils.langdict[setting('excludeaudiolang3')]) availableaudio = xbmc.Player().getAvailableAudioStreams() debug('Available audio streams: %s' % availableaudio) availableaudio = " ".join(availableaudio) if any(x in availableaudio for x in langs): debug('Excluded: the audio language is excluded') return False if "und" in availableaudio and not boolsetting('audiound'): debug('Excluded: undertermined audio') return False return True return True
def onAVStarted(self): self.run = True delay = int(setting('delay')) * 1000 if self.run: xbmc.sleep(delay) if xbmc.Player().isPlayingVideo() and globalexclusion(): self.run = False if setting('default') == '0': debug('Default: automatic subtitles') loadsub() # xbmc.executebuiltin('XBMC.RunScript(special://home/addons/service.subloader/resources/lib/testes.py)') elif setting('default') == '1': debug('Default: opening search dialog') xbmc.executebuiltin('XBMC.ActivateWindow(SubtitleSearch)') else: debug('Default: do nothing...') else: self.run = False
def onPlayBackEnded(self): debug('Playback ended') self.run = True
def onPlayBackStopped(self): debug('Playback stopped') self.run = True
def __init__(self, *args, **kwargs): xbmc.Player.__init__(self) debug('Initalized player monitor') self.run = True
def onSettingsChanged(self): if self.run: if debugsetting(): self.run = False debug('Debug settings changed') setsetting('debugcheck', value=setting('debug')) global closedebug closedebug = boolsetting('debug') debug('Debug initalized') if not closedebug: debug('Debug stopped', force=True) if OSusersetting(): self.run = False debug('OS User settings changed') if OSuser(): xbmc.executebuiltin( 'Notification("SubLoader", "%s", "%s",)' % (localize(32033), 4000)) setsetting('OSusercheck', value=setting('OSuser')) setsetting('OSpasswordcheck', value=setting('OSpassword')) debug('OS Login: successful') else: xbmc.executebuiltin( 'Notification("SubLoader", "%s", "%s",)' % (localize(32034), 4000)) setsetting('OSusercheck', value='nouser') setsetting('OSpasswordcheck', value='nopassword') debug('OS Login: unsuccessful') else: xbmc.sleep(1000) self.run = True
def __init__(self): xbmc.Monitor.__init__(self) debug("Initalized main monitor") self.run = True
if self.run: xbmc.sleep(delay) if xbmc.Player().isPlayingVideo() and globalexclusion(): self.run = False if setting('default') == '0': debug('Default: automatic subtitles') loadsub() elif setting('default') == '1': debug('Default: opening search dialog') xbmc.executebuiltin('ActivateWindow(SubtitleSearch)') else: debug('Default: do nothing...') else: self.run = False player = SubLoaderPlayer() closedebug = boolsetting('debug') while not xbmc.Monitor().abortRequested(): if xbmc.Monitor().waitForAbort(10): if closedebug: debug('Shutdown requested', force=True) debug('Player monitor stopped', force=True) debug('Main monitor stopped', force=True) del player del monitor break
def pathexclusion(): debug('Content path: %s' % videopath()) if videopath().find("http://") > -1 or videopath().find("https://") > -1: debug('Content source: %s' % videosource()) if not videopath(): return False if (videopath().find("pvr://") > -1) and boolsetting('excludelivetv'): debug('Video is playing via Live TV, which is currently set as excluded location.') return False if (videopath().find("http://") > -1 or videopath().find("https://") > -1) and boolsetting('excludehttp'): debug('Video is playing via HTTP or HTTPS source, which is currently set as excluded location.') return False path = setting('path') if path and boolsetting('excludepath'): if (videopath().find(path) > -1): debug('Video is playing from %s, which is currently set as excluded path 1.' % path) return False path2 = setting('path2') if path2 and boolsetting('excludepath2'): if (videopath().find(path2) > -1): debug('Video is playing from %s, which is currently set as excluded path 2.' % path2) return False path3 = setting('path3') if path3 and boolsetting('excludepath3'): if (videopath().find(path3) > -1): debug('Video is playing from %s, which is currently set as excluded path 3.' % path3) return False path4 = setting('path4') if path4 and boolsetting('excludepath4'): if (videopath().find(path4) > -1): debug('Video is playing from %s, which is currently set as excluded path 4.' % path4) return False path5 = setting('path5') if path5 and boolsetting('excludepath5'): if (videopath().find(path5) > -1): debug('Video is playing from %s, which is currently set as excluded path 5.' % path5) return False return True