From c0e148df43845829d78b171ef10199b62772d9d0 Mon Sep 17 00:00:00 2001 From: schumi2004 Date: Thu, 4 Apr 2013 23:11:37 +0200 Subject: [PATCH] Add ability to exclude http, livetv and 3 custom pathes from jumpback feature --- script.xbmc.unpausejumpback/addon.xml | 2 +- script.xbmc.unpausejumpback/changelog.txt | 3 + script.xbmc.unpausejumpback/default.py | 64 +++++++++++++++++-- .../resources/language/English/strings.xml | 17 +++++ .../resources/settings.xml | 28 +++++--- 5 files changed, 98 insertions(+), 16 deletions(-) create mode 100644 script.xbmc.unpausejumpback/resources/language/English/strings.xml diff --git a/script.xbmc.unpausejumpback/addon.xml b/script.xbmc.unpausejumpback/addon.xml index f6db1b3..f9bf560 100644 --- a/script.xbmc.unpausejumpback/addon.xml +++ b/script.xbmc.unpausejumpback/addon.xml @@ -1,5 +1,5 @@ - + diff --git a/script.xbmc.unpausejumpback/changelog.txt b/script.xbmc.unpausejumpback/changelog.txt index 76b9ffd..c945150 100644 --- a/script.xbmc.unpausejumpback/changelog.txt +++ b/script.xbmc.unpausejumpback/changelog.txt @@ -1,3 +1,6 @@ +2.3.0 +- add exclude settings + 2.2.0 - add jumpback/forward after fwd or rwd based on the fwd/rwd speed (can be adjusted for each speed). diff --git a/script.xbmc.unpausejumpback/default.py b/script.xbmc.unpausejumpback/default.py index f3e69d0..edb5277 100644 --- a/script.xbmc.unpausejumpback/default.py +++ b/script.xbmc.unpausejumpback/default.py @@ -53,6 +53,50 @@ def log(msg): log( "[%s] - Version: %s Started" % (__scriptname__,__version__)) +# helper function to get string type from settings +def getSetting(setting): + return __addon__.getSetting(setting).strip() + +# helper function to get bool type from settings +def getSettingAsBool(setting): + return getSetting(setting).lower() == "true" + +# check exclusion settings for filename passed as argument +def isExcluded(fullpath): + + if not fullpath: + return True + + log("isExcluded(): Checking exclusion settings for '%s'." % fullpath) + + if (fullpath.find("pvr://") > -1) and getSettingAsBool('ExcludeLiveTV'): + log("isExcluded(): Video is playing via Live TV, which is currently set as excluded location.") + return True + + if (fullpath.find("http://") > -1) and getSettingAsBool('ExcludeHTTP'): + log("isExcluded(): Video is playing via HTTP source, which is currently set as excluded location.") + return True + + ExcludePath = getSetting('ExcludePath') + if ExcludePath and getSettingAsBool('ExcludePathOption'): + if (fullpath.find(ExcludePath) > -1): + log("isExcluded(): Video is playing from '%s', which is currently set as excluded path 1." % ExcludePath) + return True + + ExcludePath2 = getSetting('ExcludePath2') + if ExcludePath2 and getSettingAsBool('ExcludePathOption2'): + if (fullpath.find(ExcludePath2) > -1): + log("isExcluded(): Video is playing from '%s', which is currently set as excluded path 2." % ExcludePath2) + return True + + ExcludePath3 = getSetting('ExcludePath3') + if ExcludePath3 and getSettingAsBool('ExcludePathOption3'): + if (fullpath.find(ExcludePath3) > -1): + log("isExcluded(): Video is playing from '%s', which is currently set as excluded path 3." % ExcludePath3) + return True + + return False + def loadSettings(): global g_jumpBackSecsAfterPause global g_waitForJumpback @@ -116,13 +160,20 @@ def onPlayBackResumed( self ): if g_pausedTime > 0: log('Resuming. Was paused for %d seconds.' % (time() - g_pausedTime)) - #handle humpback after pause - if g_jumpBackSecsAfterPause != 0 and xbmc.Player().isPlayingVideo() and xbmc.Player().getTime() > g_jumpBackSecsAfterPause and g_pausedTime > 0 and (time() - g_pausedTime) > g_waitForJumpback: - resumeTime = xbmc.Player().getTime() - g_jumpBackSecsAfterPause - xbmc.Player().seekTime(resumeTime) - log( 'Resumed with %ds jumpback' % g_jumpBackSecsAfterPause ) + # check for exclusion + _filename = self.getPlayingFile() + if isExcluded(_filename): + log("Ignored because '%s' is in exclusion settings." % _filename) + return + + else: + #handle humpback after pause + if g_jumpBackSecsAfterPause != 0 and xbmc.Player().isPlayingVideo() and xbmc.Player().getTime() > g_jumpBackSecsAfterPause and g_pausedTime > 0 and (time() - g_pausedTime) > g_waitForJumpback: + resumeTime = xbmc.Player().getTime() - g_jumpBackSecsAfterPause + xbmc.Player().seekTime(resumeTime) + log( 'Resumed with %ds jumpback' % g_jumpBackSecsAfterPause ) - g_pausedTime = 0 + g_pausedTime = 0 try: class MyMonitor( xbmc.Monitor ): def __init__( self, *args, **kwargs ): @@ -141,3 +192,4 @@ def onSettingsChanged( self ): while not xbmc.abortRequested: xbmc.sleep(100) + diff --git a/script.xbmc.unpausejumpback/resources/language/English/strings.xml b/script.xbmc.unpausejumpback/resources/language/English/strings.xml new file mode 100644 index 0000000..6db283c --- /dev/null +++ b/script.xbmc.unpausejumpback/resources/language/English/strings.xml @@ -0,0 +1,17 @@ + + + Jump back on unpause + Jump seconds + Minimum pause before jumpback + Jump forward/back after rwd/fwd + Jump after x2 + Jump after x4 + Jump after x8 + Jump after x16 + Jump after x32 + Exclude + Exclude Live TV + Exclude HTTP sources + Exclude path + Folder's path (and subfolders) + diff --git a/script.xbmc.unpausejumpback/resources/settings.xml b/script.xbmc.unpausejumpback/resources/settings.xml index a133f12..3b434e7 100644 --- a/script.xbmc.unpausejumpback/resources/settings.xml +++ b/script.xbmc.unpausejumpback/resources/settings.xml @@ -1,14 +1,24 @@ - - - + + + - - - - - - + + + + + + + + + + + + + + + +