Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions default.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import xbmcplugin
import xbmcgui
import xbmcaddon
import signal


addon = xbmcaddon.Addon()
Expand All @@ -28,6 +29,7 @@
userDataFolder = xbmc.translatePath("special://profile/addon_data/"+addonID)
profileFolder = os.path.join(userDataFolder, 'profile')
siteFolder = os.path.join(userDataFolder, 'sites')
browserPIDFile = os.path.join(userDataFolder, 'browser.pid')

if not os.path.isdir(userDataFolder):
os.mkdir(userDataFolder)
Expand Down Expand Up @@ -119,6 +121,7 @@ def getFullPath(path, url, useKiosk, userAgent):


def showSite(url, stopPlayback, kiosk, userAgent):
fullUrl = ""
if stopPlayback == "yes":
xbmc.Player().stop()
if osWin:
Expand Down Expand Up @@ -170,6 +173,44 @@ def showSite(url, stopPlayback, kiosk, userAgent):
else:
xbmc.executebuiltin('XBMC.Notification(Info:,'+str(translation(30005))+'!,5000)')
addon.openSettings()
print("fullUrl: %s" % fullUrl)

if fullUrl != "":
if os.path.exists(browserPIDFile):
os.unlink(browserPIDFile)
fh = open(browserPIDFile, 'w+')
fh.write(fullUrl)
fh.close()

xbmcgui.Dialog().ok(addon.getAddonInfo('name') , translation(30017))
killBrowser()


def killBrowser():
if os.path.exists(browserPIDFile):
fh = open(browserPIDFile)
fullUrl = fh.read()
fh.close()
browserPID = -1
if len(fullUrl) > 0:
# a full re.escape() is too much
fullUrlEsc = fullUrl.replace('"','')
if osWin:
# WINDOWS VERSION NEEDS TO BE FIXED
psgrep = 'tasklist | FIND "chrome"'
if osLinux:
psgrep = '/bin/ps ax | /bin/grep "'+fullUrlEsc+'"'
if osOsx:
psgrep = '/bin/ps ax | /usr/bin/grep "'+fullUrlEsc+'"'
print("process grep: %s" % psgrep)
processList = subprocess.check_output( psgrep, shell=True )
processMatch = re.findall('^\d*', processList).pop(0)
browserPID = int(processMatch)
else:
browserPID = -1
if browserPID > 0:
os.kill(browserPID, signal.SIGTERM)
os.unlink(browserPIDFile)


def removeSite(title):
Expand Down Expand Up @@ -275,3 +316,4 @@ def addSiteDir(name, url, mode, iconimage, stopPlayback, kiosk):
editSite(url)
else:
index()

1 change: 1 addition & 0 deletions resources/language/English/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@
<string id="30014">Script path</string>
<string id="30015">Delay after script (in seconds)</string>
<string id="30016">Use kiosk mode?</string>
<string id="30017">Click "OK" to close Chrome</string>
</strings>
1 change: 1 addition & 0 deletions resources/language/German/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@
<string id="30013">Benutzerdefiniertes Skript vor Chrome starten</string>
<string id="30014">Script Pfad</string>
<string id="30015">Pause nach Skript (in Sekunden)</string>
<string id="30017">Klicken Sie auf OK, um Chrom zu schließen</string>
</strings>