Skip to content

Commit

Permalink
Add ability to exclude http, livetv and 3 custom pathes from jumpback…
Browse files Browse the repository at this point in the history
… feature
  • Loading branch information
schumi2004 committed Apr 5, 2013
1 parent bc54e3c commit c0e148d
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 16 deletions.
2 changes: 1 addition & 1 deletion script.xbmc.unpausejumpback/addon.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="script.xbmc.unpausejumpback" name="XBMC Unpause Jumpback" version="2.2.0" provider-name="Memphiz, Lucleonhart">
<addon id="script.xbmc.unpausejumpback" name="XBMC Unpause Jumpback" version="2.3.0" provider-name="Memphiz, Lucleonhart">
<requires>
<import addon="xbmc.python" version="2.1.0"/>
</requires>
Expand Down
3 changes: 3 additions & 0 deletions 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).

Expand Down
64 changes: 58 additions & 6 deletions script.xbmc.unpausejumpback/default.py
Expand Up @@ -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
Expand Down Expand Up @@ -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 ):
Expand All @@ -141,3 +192,4 @@ def onSettingsChanged( self ):

while not xbmc.abortRequested:
xbmc.sleep(100)

17 changes: 17 additions & 0 deletions script.xbmc.unpausejumpback/resources/language/English/strings.xml
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<strings>
<string id="10000">Jump back on unpause</string>
<string id="10001">Jump seconds</string>
<string id="10002">Minimum pause before jumpback</string>
<string id="20000">Jump forward/back after rwd/fwd</string>
<string id="20001">Jump after x2</string>
<string id="20002">Jump after x4</string>
<string id="20003">Jump after x8</string>
<string id="20004">Jump after x16</string>
<string id="20005">Jump after x32</string>
<string id="30000">Exclude</string>
<string id="30001">Exclude Live TV</string>
<string id="30002">Exclude HTTP sources</string>
<string id="30003">Exclude path</string>
<string id="30004">Folder's path (and subfolders)</string>
</strings>
28 changes: 19 additions & 9 deletions script.xbmc.unpausejumpback/resources/settings.xml
@@ -1,14 +1,24 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<settings>
<category label="Jump back on unpause">
<setting id="jumpbacksecs" type="slider" label="Jump seconds" default="0" range="0,60" />
<setting id="waitforjumpback" type="slider" label="Minimum pause before jumpback" default="10" range="0,600" />
<category label="10000">
<setting id="jumpbacksecs" type="slider" label="10001" default="0" range="0,60" />
<setting id="waitforjumpback" type="slider" label="10002" default="10" range="0,600" />
</category>
<category label="Jump forward/back after rwd/fwd">
<setting id="jumpbacksecsx2" type="slider" label="Jump after x2" default="1" range="0,60" />
<setting id="jumpbacksecsx4" type="slider" label="Jump after x4" default="2" range="0,60" />
<setting id="jumpbacksecsx8" type="slider" label="Jump after x8" default="4" range="0,60" />
<setting id="jumpbacksecsx16" type="slider" label="Jump after x16" default="8" range="0,60" />
<setting id="jumpbacksecsx32" type="slider" label="Jump after x32" default="16" range="0,60" />
<category label="20000">
<setting id="jumpbacksecsx2" type="slider" label="20001" default="1" range="0,60" />
<setting id="jumpbacksecsx4" type="slider" label="20002" default="2" range="0,60" />
<setting id="jumpbacksecsx8" type="slider" label="20003" default="4" range="0,60" />
<setting id="jumpbacksecsx16" type="slider" label="20004" default="8" range="0,60" />
<setting id="jumpbacksecsx32" type="slider" label="20005" default="16" range="0,60" />
</category>
<category label="30000">
<setting id="ExcludeLiveTV" type="bool" label="30001" default="false"/>
<setting id="ExcludeHTTP" type="bool" label="30002" default="false"/>
<setting id="ExcludePathOption" type="bool" label="30003" default="false" />
<setting id="ExcludePath" type="folder" source="video" label="30004" default="" visible= "eq(-1,true)" enable="eq(-1,true)" />
<setting id="ExcludePathOption2" type="bool" label="30003" default="false" visible= "eq(-2,true)" enable="eq(-2,true)" />
<setting id="ExcludePath2" type="folder" source="video" label="30004" default="" visible= "eq(-1,true)" enable="eq(-1,true)" />
<setting id="ExcludePathOption3" type="bool" label="30003" default="false" visible= "eq(-2,true)" enable="eq(-2,true)" />
<setting id="ExcludePath3" type="folder" source="video" label="30004" default="" visible= "eq(-1,true)" enable="eq(-1,true)" />
</category>
</settings>

0 comments on commit c0e148d

Please sign in to comment.