diff --git a/packages/addons/service/downloadmanager/SABnzbd-Suite/changelog.txt b/packages/addons/service/downloadmanager/SABnzbd-Suite/changelog.txt
index 2d8c5a4c49..3ecab74198 100644
--- a/packages/addons/service/downloadmanager/SABnzbd-Suite/changelog.txt
+++ b/packages/addons/service/downloadmanager/SABnzbd-Suite/changelog.txt
@@ -1,3 +1,6 @@
+2.1.2
+- improve startup script
+
2.1.1
- update to addon version 2.1
- update to SABnzbd-0.6.15
diff --git a/packages/addons/service/downloadmanager/SABnzbd-Suite/meta b/packages/addons/service/downloadmanager/SABnzbd-Suite/meta
index e750b8dd6d..37851c76ff 100644
--- a/packages/addons/service/downloadmanager/SABnzbd-Suite/meta
+++ b/packages/addons/service/downloadmanager/SABnzbd-Suite/meta
@@ -20,7 +20,7 @@
PKG_NAME="SABnzbd-Suite"
PKG_VERSION="2.1"
-PKG_REV="1"
+PKG_REV="2"
PKG_ARCH="any"
PKG_LICENSE="OSS"
PKG_SITE="http://www.openelec.tv"
diff --git a/packages/addons/service/downloadmanager/SABnzbd-Suite/source/bin/SABnzbd-Suite.py b/packages/addons/service/downloadmanager/SABnzbd-Suite/source/bin/SABnzbd-Suite.py
index 8b1ff65847..1c58c11d5a 100755
--- a/packages/addons/service/downloadmanager/SABnzbd-Suite/source/bin/SABnzbd-Suite.py
+++ b/packages/addons/service/downloadmanager/SABnzbd-Suite/source/bin/SABnzbd-Suite.py
@@ -1,23 +1,22 @@
-################################################################################
-# This file is part of OpenELEC - http://www.openelec.tv
-# Copyright (C) 2012 Lukas Heiniger
-#
-# This Program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This Program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with OpenELEC.tv; see the file COPYING. If not, write to
-# the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, MA 02110, USA.
-# http://www.gnu.org/copyleft/gpl.html
################################################################################
-
+# This file is part of OpenELEC - http://www.openelec.tv
+# Copyright (C) 2012 Lukas Heiniger
+#
+# This Program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version
+#
+# This Program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with OpenELEC.tv; see the file COPYING. If not, write to
+# the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, MA 02110, USA.
+# http://www.gnu.org/copyleft/gpl.html
+################################################################################
# Initializes and launches SABnzbd, Couchpotato, Sickbeard and Headphones
@@ -33,24 +32,21 @@ import logging
logging.basicConfig(filename='/var/log/sabnzbd-suite.log',
filemode='w',
- format='%(asctime)s SABnzbd-Suite: %(message)s',
+ format='%(asctime)s SABnzbd-Suite: %(message)s',
level=logging.WARNING)
-
-
-
# helper functions
# ----------------
def createDir(dir):
if not os.path.isdir(dir):
os.makedirs(dir)
-
+
def getAddonSetting(doc,id):
for element in doc.getElementsByTagName('setting'):
if element.getAttribute('id')==id:
return element.getAttribute('value')
-
+
def loadWebInterface(url,user,pwd):
passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
passman.add_password(None, url, user, pwd)
@@ -59,9 +55,6 @@ def loadWebInterface(url,user,pwd):
urllib2.install_opener(opener)
pagehandle = urllib2.urlopen(url)
return pagehandle.read()
-
-
-
# define some things that we're gonna need, mainly paths
# ------------------------------------------------------
@@ -87,27 +80,23 @@ pSabNzbdIncomplete = '/storage/downloads/incomplete'
pSickBeardTvScripts = os.path.join(pAddon, 'SickBeard/autoProcessTV')
pSabNzbdScripts = os.path.join(pAddonHome, 'scripts')
-
# pylib
pPylib = os.path.join(pAddon, 'pylib')
# service commands
-sabnzbd = ['python', os.path.join(pAddon, 'SABnzbd/SABnzbd.py'),
+sabnzbd = ['python', os.path.join(pAddon, 'SABnzbd/SABnzbd.py'),
'-d', '-f', pSabNzbdSettings, '-l 0']
-sickBeard = ['python', os.path.join(pAddon, 'SickBeard/SickBeard.py'),
+sickBeard = ['python', os.path.join(pAddon, 'SickBeard/SickBeard.py'),
'--daemon', '--datadir', pAddonHome]
-couchPotato = ['python', os.path.join(pAddon, 'CouchPotato/CouchPotato.py'),
+couchPotato = ['python', os.path.join(pAddon, 'CouchPotato/CouchPotato.py'),
'-d', '--datadir', pAddonHome, '--config', pCouchPotatoSettings]
-headphones = ['python', os.path.join(pAddon, 'Headphones/Headphones.py'),
+headphones = ['python', os.path.join(pAddon, 'Headphones/Headphones.py'),
'-d', '--datadir', pAddonHome, '--config', pHeadphonesSettings]
# Other stuff
sabNzbdHost = '127.0.0.1:8081'
addonId = 'service.downloadmanager.SABnzbd-Suite'
-
-
-
# create directories and settings on first launch
# -----------------------------------------------
@@ -130,9 +119,6 @@ if firstLaunch:
for utility in {'par2','unrar','unzip'}:
os.chmod(os.path.join(pAddon, 'bin', utility), 0755)
-
-
-
# read addon and xbmc settings
# ----------------------------
@@ -162,17 +148,12 @@ try:
except:
xbmcPwd = ''
-
-
# prepare execution environment
# -----------------------------
signal.signal(signal.SIGCHLD, signal.SIG_DFL)
os.environ['PYTHONPATH'] = str(os.environ.get('PYTHONPATH')) + ':' + pPylib
-
-
-
# write SABnzbd settings
# ----------------------
@@ -207,7 +188,7 @@ if firstLaunch:
servers['localhost']['port'] = '119'
servers['localhost']['enable'] = '0'
categories = {}
- categories['tv'] = {}
+ categories['tv'] = {}
categories['tv']['name'] = 'tv'
categories['tv']['script'] = 'sabToSickBeard.py'
categories['tv']['priority'] = '-100'
@@ -221,7 +202,7 @@ if firstLaunch:
categories['music']['priority'] = '-100'
defaultConfig['servers'] = servers
defaultConfig['categories'] = categories
-
+
sabNzbdConfig.merge(defaultConfig)
sabNzbdConfig.write()
@@ -236,9 +217,6 @@ defaultConfig['SickBeard']['password'] = pwd
autoProcessConfig.merge(defaultConfig)
autoProcessConfig.write()
-
-
-
# launch SABnzbd and get the API key
# ----------------------------------
@@ -253,9 +231,6 @@ sabNzbdConfig.reload()
sabNzbdApiKey = sabNzbdConfig['misc']['api_key']
logging.debug('SABnzbd api key: ' + sabNzbdApiKey)
-
-
-
# write SickBeard settings
# ------------------------
@@ -297,22 +272,16 @@ if firstLaunch:
defaultConfig['SABnzbd']['sab_host'] = sabNzbdHost
defaultConfig['XBMC']['xbmc_notify_ondownload'] = '1'
defaultConfig['XBMC']['xbmc_update_library'] = '1'
-
+
sickBeardConfig.merge(defaultConfig)
sickBeardConfig.write()
-
-
-
# launch SickBeard
# ----------------
logging.debug('Launching SickBeard...')
subprocess.call(sickBeard)
logging.debug('...done')
-
-
-
# write CouchPotato settings
# --------------------------
@@ -345,13 +314,10 @@ if firstLaunch:
defaultConfig['Renamer']['destination'] = '/storage/videos'
defaultConfig['Renamer']['separator'] = '.'
defaultConfig['Renamer']['cleanup'] = 'True'
-
+
couchPotatoConfig.merge(defaultConfig)
couchPotatoConfig.write()
-
-
-
# launch CouchPotato
# ------------------
@@ -359,9 +325,6 @@ logging.debug('Launching CouchPotato...')
subprocess.call(couchPotato)
logging.debug('...done')
-
-
-
# write Headphones settings
# -------------------------
@@ -383,16 +346,13 @@ if firstLaunch:
defaultConfig['SABnzbd']['sab_category'] = 'music'
defaultConfig['General']['music_dir'] = '/storage/music'
defaultConfig['General']['destination_dir'] = '/storage/music'
- defaultConfig['General']['download_dir'] = '/storage/downloads/music'
- defaultConfig['General']['move_files'] = '1'
+ defaultConfig['General']['download_dir'] = '/storage/downloads/music'
+ defaultConfig['General']['move_files'] = '1'
defaultConfig['General']['rename_files'] = '1'
-
+
headphonesConfig.merge(defaultConfig)
headphonesConfig.write()
-
-
-
# launch Headphones
# -----------------
diff --git a/packages/addons/service/downloadmanager/SABnzbd-Suite/source/default.py b/packages/addons/service/downloadmanager/SABnzbd-Suite/source/default.py
index d56e31083f..aecda97fc3 100644
--- a/packages/addons/service/downloadmanager/SABnzbd-Suite/source/default.py
+++ b/packages/addons/service/downloadmanager/SABnzbd-Suite/source/default.py
@@ -60,10 +60,10 @@ if shouldKeepAwake:
xbmc.log('SABnzbd-Suite: will prevent idle sleep/shutdown while downloading')
while (not xbmc.abortRequested):
-
+
# reread setting in case it has changed
shouldKeepAwake = __settings__.getSetting('SABNZBD_KEEP_AWAKE')
-
+
# check if SABnzbd is downloading
sabIsActive = False
req = urllib2.Request(sabNzbdQueue)
@@ -74,16 +74,16 @@ while (not xbmc.abortRequested):
queue = handle.read()
handle.close()
sabIsActive = (queue.find('