mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-07-29 13:46:49 +00:00
SABnzbd: add initial settings support, cleanups
Signed-off-by: Stephan Raue <stephan@openelec.tv>
This commit is contained in:
parent
a3fe084ab1
commit
5ba70e258c
@ -24,6 +24,7 @@
|
||||
|
||||
mkdir -p $ADDON_BUILD/$PKG_ADDON_ID/$1
|
||||
cp -PR $PKG_BUILD/* $ADDON_BUILD/$PKG_ADDON_ID/$1
|
||||
cp -PR $PKG_DIR/config/settings.xml* $ADDON_BUILD/$PKG_ADDON_ID/settings-default.xml
|
||||
|
||||
mkdir -p $ADDON_BUILD/$PKG_ADDON_ID/bin
|
||||
cp $BUILD/par2cmdline*/par2 $ADDON_BUILD/$PKG_ADDON_ID/bin
|
||||
|
@ -0,0 +1,5 @@
|
||||
<settings>
|
||||
<setting id="SABNZBD_IP" value="0.0.0.0" />
|
||||
<setting id="SABNZBD_PWD" value="" />
|
||||
<setting id="SABNZBD_USER" value="" />
|
||||
</settings>
|
@ -1,42 +0,0 @@
|
||||
################################################################################
|
||||
# This file is part of OpenELEC - http://www.openelec.tv
|
||||
# Copyright (C) 2009-2011 Stephan Raue (stephan@openelec.tv)
|
||||
#
|
||||
# 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, 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
# http://www.gnu.org/copyleft/gpl.html
|
||||
################################################################################
|
||||
|
||||
# Starting SABnzbd Newsgroup downloader daemon
|
||||
#
|
||||
# runlevels: openelec, textmode
|
||||
|
||||
(
|
||||
if [ -f /var/config/settings.conf ]; then
|
||||
. /var/config/settings.conf
|
||||
|
||||
if [ "$SABNZBD_START" = "true" ]; then
|
||||
|
||||
mkdir -p $HOME/.sabnzbd
|
||||
mkdir -p $HOME/downloads
|
||||
mkdir -p $HOME/downloads/incoming
|
||||
mkdir -p $HOME/downloads/watch
|
||||
|
||||
wait_for_network
|
||||
|
||||
progress "Starting SABnzbd Newsgroup downloader daemon"
|
||||
python /usr/lib/SABnzbd/SABnzbd.py -d -f $HOME/.sabnzbd/sabnzbd.conf -l 0 > /dev/null 2>&1
|
||||
fi
|
||||
fi
|
||||
)&
|
82
packages/addons/downloadmanager/SABnzbd/source/bin/ini_tool
Executable file
82
packages/addons/downloadmanager/SABnzbd/source/bin/ini_tool
Executable file
@ -0,0 +1,82 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
from configobj import ConfigObj
|
||||
import sys
|
||||
import os
|
||||
|
||||
python_major = sys.version_info[0]
|
||||
python_minor = sys.version_info[1]
|
||||
|
||||
prog="ini_tool"
|
||||
description="""Read/Write config files.
|
||||
|
||||
Examples:
|
||||
%(prog)s --file config.ini --action read --section "general" --option username
|
||||
%(prog)s --file config.ini --action write --section "general" --option username --value foo""" % {'prog':prog}
|
||||
|
||||
def option_required_error(option):
|
||||
parser.print_usage()
|
||||
print prog + ": error: " + option + " is required"
|
||||
exit(2)
|
||||
|
||||
if python_major > 2 or (python_major == 2 and python_minor >= 7):
|
||||
import argparse
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
prog=prog,
|
||||
description=description,
|
||||
formatter_class=argparse.RawDescriptionHelpFormatter,
|
||||
)
|
||||
|
||||
parser.add_argument('--file', help='file to read/write to/from', required=True)
|
||||
parser.add_argument('--action', help='read|write', required=True)
|
||||
parser.add_argument('--section', help='the config section', required=True)
|
||||
parser.add_argument('--option', help='the option key', required=True)
|
||||
parser.add_argument('--value', help='value to store in the given option (only for write action)')
|
||||
|
||||
options = parser.parse_args()
|
||||
|
||||
else:
|
||||
import optparse
|
||||
|
||||
parser = optparse.OptionParser(
|
||||
prog=prog,
|
||||
description=description,
|
||||
)
|
||||
|
||||
parser.add_option('--file', help='file to read/write to/from')
|
||||
parser.add_option('--action', help='read|write')
|
||||
parser.add_option('--section', help='the config section')
|
||||
parser.add_option('--option', help='the option key')
|
||||
parser.add_option('--value', help='value to store in the given option (only for write action)')
|
||||
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
if not options.file:
|
||||
option_required_error("--file")
|
||||
if not options.action:
|
||||
option_required_error("--action")
|
||||
if not options.section:
|
||||
option_required_error("--section")
|
||||
if not options.option:
|
||||
option_required_error("--option")
|
||||
|
||||
|
||||
if options.action != "read" and options.action != "write":
|
||||
print "'" + options.action + "' is not a valid action"
|
||||
parser.print_help()
|
||||
exit(2)
|
||||
|
||||
if options.action == "read" and not os.path.isfile(options.file):
|
||||
print "'" + options.file + "' is not a file"
|
||||
exit(2)
|
||||
|
||||
config = ConfigObj(options.file)
|
||||
|
||||
if options.action == 'read':
|
||||
print config[options.section][options.option]
|
||||
elif options.action == 'write':
|
||||
config[options.section][options.option] = options.value
|
||||
config.write()
|
||||
else:
|
||||
exit(1)
|
@ -4,7 +4,6 @@
|
||||
<!-- SABnzbd -->
|
||||
<string id="1000">SABnzbd</string>
|
||||
<string id="1010">Gebruikers instellingen</string>
|
||||
<string id="1021">Gebruik verificatie</string>
|
||||
<string id="1022">Gebruikersnaam</string>
|
||||
<string id="1023">Wachtwoord</string>
|
||||
<string id="2010">Netwerk instellingen</string>
|
||||
|
@ -4,7 +4,6 @@
|
||||
<!-- SABnzbd -->
|
||||
<string id="1000">SABnzbd</string>
|
||||
<string id="1010">User Settings</string>
|
||||
<string id="1021">Use authentification</string>
|
||||
<string id="1022">Username</string>
|
||||
<string id="1023">Password</string>
|
||||
<string id="2010">Network Settings</string>
|
||||
|
@ -4,7 +4,6 @@
|
||||
<!-- SABnzbd -->
|
||||
<string id="1000">SABnzbd</string>
|
||||
<string id="1010">Préférences utilisateur</string>
|
||||
<string id="1021">Utiliser une authentification</string>
|
||||
<string id="1022">Nom d'utilisateur</string>
|
||||
<string id="1023">Mot de passe</string>
|
||||
<string id="2010">Préférences réseau</string>
|
||||
|
@ -4,7 +4,6 @@
|
||||
<!-- SABnzbd -->
|
||||
<string id="1000">SABnzbd</string>
|
||||
<string id="1010">Benutzer Einstellungen</string>
|
||||
<string id="1021">Authentifizierung verwenden</string>
|
||||
<string id="1022">Benutzername</string>
|
||||
<string id="1023">Passwort</string>
|
||||
<string id="2010">Netzwerk Einstellungen</string>
|
||||
|
@ -4,7 +4,6 @@
|
||||
<!-- SABnzbd -->
|
||||
<string id="1000">SABnzbd</string>
|
||||
<string id="1010">Bruker Instillinger</string>
|
||||
<string id="1021">Bruk inlogging</string>
|
||||
<string id="1022">Brukernavn</string>
|
||||
<string id="1023">Passord</string>
|
||||
<string id="2010">Nettverksinstillinger</string>
|
||||
|
@ -5,7 +5,6 @@
|
||||
<category label="1000">
|
||||
<setting label="1010" type="lsep"/>
|
||||
<setting type="sep" />
|
||||
<setting id="SABNZBD_AUTH" type="bool" label="1021" default="false" />
|
||||
<setting id="SABNZBD_USER" type="text" label="1022" default="openelec" enable="eq(-1,true)"/>
|
||||
<setting id="SABNZBD_PWD" type="text" label="1023" default="openelec" enable="eq(-2,true)"/>
|
||||
|
||||
|
@ -26,40 +26,51 @@ export PYTHONPATH="$PYTHONPATH:./pylib"
|
||||
SABNZBD_HOME="$HOME/.xbmc/userdata/addon_data/addon.downloadmanager.SABnzbd"
|
||||
SABNZBD_SETTINGS="$SABNZBD_HOME/settings.xml"
|
||||
|
||||
mkdir -p $SABNZBD_HOME
|
||||
SABNZBD_DISABLEAPIKEY="0"
|
||||
SABNZBD_HTTPPORT="8081"
|
||||
SABNZBD_HTTPSPORT="9081"
|
||||
SABNZBD_SKIN="Plush"
|
||||
SABNZBD_SKIN2="Plush"
|
||||
SABNZBD_WEBCOLOR="gold"
|
||||
SABNZBD_WEBCOLOR2="gold"
|
||||
|
||||
# if [ ! -f "$SABNZBD_SETTINGS" ]; then
|
||||
# cp settings.xml $SABNZBD_SETTINGS
|
||||
# fi
|
||||
write_ini() {
|
||||
python bin/ini_tool --action=write \
|
||||
--file=$SABNZBD_HOME/sabnzbd.ini \
|
||||
--section="$1" \
|
||||
--option="$2" \
|
||||
--value="$3"
|
||||
}
|
||||
|
||||
mkdir -p $SABNZBD_HOME
|
||||
chmod +x ./bin/*
|
||||
|
||||
if [ ! -f "$SABNZBD_SETTINGS" ]; then
|
||||
cp settings-default.xml $SABNZBD_SETTINGS
|
||||
fi
|
||||
|
||||
mkdir -p /storage/downloads
|
||||
mkdir -p /storage/downloads/incoming
|
||||
mkdir -p /storage/downloads/watch
|
||||
|
||||
# TRANSMISSION_START=`grep TRANSMISSION_START $OPENELEC_SETTINGS | awk '{print $3 }' | sed -e "s,value=,," -e "s,\",,g"`
|
||||
# TRANSMISSION_AUTH=`grep TRANSMISSION_AUTH $OPENELEC_SETTINGS | awk '{print $3 }' | sed -e "s,value=,," -e "s,\",,g"`
|
||||
# TRANSMISSION_USER=`grep TRANSMISSION_USER $OPENELEC_SETTINGS | awk '{print $3 }' | sed -e "s,value=,," -e "s,\",,g"`
|
||||
# TRANSMISSION_PWD=`grep TRANSMISSION_PWD $OPENELEC_SETTINGS | awk '{print $3 }' | sed -e "s,value=,," -e "s,\",,g"`
|
||||
# TRANSMISSION_IP=`grep TRANSMISSION_IP $OPENELEC_SETTINGS | awk '{print $3 }' | sed -e "s,value=,," -e "s,\",,g"`
|
||||
# use settings from xbmc setup dialog
|
||||
SABNZBD_USER=`grep SABNZBD_USER $SABNZBD_SETTINGS | awk '{print $3 }' | sed -e "s,value=,," -e "s,\",,g"`
|
||||
SABNZBD_PWD=`grep SABNZBD_PWD $SABNZBD_SETTINGS | awk '{print $3 }' | sed -e "s,value=,," -e "s,\",,g"`
|
||||
SABNZBD_IP=`grep SABNZBD_IP $SABNZBD_SETTINGS | awk '{print $3 }' | sed -e "s,value=,," -e "s,\",,g"`
|
||||
|
||||
# if [ -z "$TRANSMISSION_IP" ]; then
|
||||
# TRANSMISSION_IP="*.*.*.*"
|
||||
# fi
|
||||
if [ -z "$SABNZBD_IP" ]; then
|
||||
SABNZBD_IP="0.0.0.0"
|
||||
fi
|
||||
|
||||
# TRANSMISSION_ARG="$TRANSMISSION_ARG -w /storage/downloads"
|
||||
# TRANSMISSION_ARG="$TRANSMISSION_ARG --incomplete-dir /storage/downloads/incoming"
|
||||
# TRANSMISSION_ARG="$TRANSMISSION_ARG --watch-dir /storage/downloads/watch"
|
||||
# TRANSMISSION_ARG="$TRANSMISSION_ARG -e /var/log/transmission.log"
|
||||
# TRANSMISSION_ARG="$TRANSMISSION_ARG -g /storage/.cache/transmission"
|
||||
# TRANSMISSION_ARG="$TRANSMISSION_ARG -a $TRANSMISSION_IP"
|
||||
write_ini misc disable_api_key $SABNZBD_DISABLEAPIKEY
|
||||
write_ini misc username $SABNZBD_USER
|
||||
write_ini misc password $SABNZBD_PWD
|
||||
write_ini misc port $SABNZBD_HTTPPORT
|
||||
write_ini misc https_port $SABNZBD_HTTPSPORT
|
||||
write_ini misc host $SABNZBD_IP
|
||||
write_ini misc web_dir $SABNZBD_SKIN
|
||||
write_ini misc web_dir2 $SABNZBD_SKIN2
|
||||
write_ini misc web_color $SABNZBD_WEBCOLOR
|
||||
write_ini misc web_color2 $SABNZBD_WEBCOLOR2
|
||||
|
||||
# if [ "$TRANSMISSION_AUTH" = "true" ]; then
|
||||
# TRANSMISSION_ARG="$TRANSMISSION_ARG -t"
|
||||
# TRANSMISSION_ARG="$TRANSMISSION_ARG -u $TRANSMISSION_USER"
|
||||
# TRANSMISSION_ARG="$TRANSMISSION_ARG -v $TRANSMISSION_PWD"
|
||||
# else
|
||||
# TRANSMISSION_ARG="$TRANSMISSION_ARG -T"
|
||||
# fi
|
||||
|
||||
chmod +x ./bin/*
|
||||
python ./SABnzbd/SABnzbd.py -d -f $SABNZBD_HOME/sabnzbd.conf -l 0 > /dev/null 2>&1
|
||||
python ./SABnzbd/SABnzbd.py -d -f $SABNZBD_HOME/sabnzbd.ini -l 0 > /dev/null 2>&1
|
||||
|
Loading…
x
Reference in New Issue
Block a user