Remove ppdir option for sabnzbd
This commit is contained in:
1 parent
2010c41ef7
commit
16e4ed6c5d
2 files changed
-72
No files matched your search
@@ -33,12 +33,6 @@ config = [{
|
|||||||
'label': 'Category',
|
'label': 'Category',
|
||||||
'description': 'The category CP places the nzb in. Like <strong>movies</strong> or <strong>couchpotato</strong>',
|
'description': 'The category CP places the nzb in. Like <strong>movies</strong> or <strong>couchpotato</strong>',
|
||||||
},
|
},
|
||||||
{
|
|
||||||
'advanced': True,
|
|
||||||
'name': 'pp_directory',
|
|
||||||
'type': 'directory',
|
|
||||||
'description': 'Your Post-Processing Script directory, set in Sabnzbd > Config > Directories.',
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
'name': 'manual',
|
'name': 'manual',
|
||||||
'default': 0,
|
'default': 0,
|
||||||
|
|||||||
@@ -2,11 +2,6 @@ from couchpotato.core.downloaders.base import Downloader
|
|||||||
from couchpotato.core.helpers.encoding import tryUrlencode
|
from couchpotato.core.helpers.encoding import tryUrlencode
|
||||||
from couchpotato.core.helpers.variable import cleanHost
|
from couchpotato.core.helpers.variable import cleanHost
|
||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
from inspect import ismethod, isfunction
|
|
||||||
from tempfile import mkstemp
|
|
||||||
import base64
|
|
||||||
import os
|
|
||||||
import re
|
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
log = CPLog(__name__)
|
log = CPLog(__name__)
|
||||||
@@ -22,19 +17,6 @@ class Sabnzbd(Downloader):
|
|||||||
|
|
||||||
log.info("Sending '%s' to SABnzbd." % data.get('name'))
|
log.info("Sending '%s' to SABnzbd." % data.get('name'))
|
||||||
|
|
||||||
if self.conf('ppDir') and data.get('imdb_id'):
|
|
||||||
try:
|
|
||||||
pp_script_fn = self.buildPp(data.get('imdb_id'))
|
|
||||||
except:
|
|
||||||
log.info("Failed to create post-processing script.")
|
|
||||||
pp_script_fn = False
|
|
||||||
if not pp_script_fn:
|
|
||||||
pp = False
|
|
||||||
else:
|
|
||||||
pp = True
|
|
||||||
else:
|
|
||||||
pp = False
|
|
||||||
|
|
||||||
params = {
|
params = {
|
||||||
'apikey': self.conf('api_key'),
|
'apikey': self.conf('api_key'),
|
||||||
'cat': self.conf('category'),
|
'cat': self.conf('category'),
|
||||||
@@ -53,9 +35,6 @@ class Sabnzbd(Downloader):
|
|||||||
else:
|
else:
|
||||||
params['name'] = data.get('url')
|
params['name'] = data.get('url')
|
||||||
|
|
||||||
if pp:
|
|
||||||
params['script'] = pp_script_fn
|
|
||||||
|
|
||||||
url = cleanHost(self.conf('host')) + "api?" + tryUrlencode(params)
|
url = cleanHost(self.conf('host')) + "api?" + tryUrlencode(params)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -82,48 +61,3 @@ class Sabnzbd(Downloader):
|
|||||||
else:
|
else:
|
||||||
log.error("Unknown error: " + result[:40])
|
log.error("Unknown error: " + result[:40])
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def buildPp(self, imdb_id):
|
|
||||||
|
|
||||||
pp_script_path = self.getPpFile()
|
|
||||||
|
|
||||||
scriptB64 = '''IyEvdXNyL2Jpbi9weXRob24KaW1wb3J0IG9zCmltcG9ydCBzeXMKcHJpbnQgIkNyZWF0aW5nIGNwLmNw
|
|
||||||
bmZvIGZvciAlcyIgJSBzeXMuYXJndlsxXQppbWRiSWQgPSB7W0lNREJJREhFUkVdfQpwYXRoID0gb3Mu
|
|
||||||
cGF0aC5qb2luKHN5cy5hcmd2WzFdLCAiY3AuY3BuZm8iKQp0cnk6CiBmID0gb3BlbihwYXRoLCAndycp
|
|
||||||
CmV4Y2VwdCBJT0Vycm9yOgogcHJpbnQgIlVuYWJsZSB0byBvcGVuICVzIGZvciB3cml0aW5nIiAlIHBh
|
|
||||||
dGgKIHN5cy5leGl0KDEpCnRyeToKIGYud3JpdGUob3MucGF0aC5iYXNlbmFtZShzeXMuYXJndlswXSkr
|
|
||||||
IlxuIitpbWRiSWQpCmV4Y2VwdDoKIHByaW50ICJVbmFibGUgdG8gd3JpdGUgdG8gZmlsZTogJXMiICUg
|
|
||||||
cGF0aAogc3lzLmV4aXQoMikKZi5jbG9zZSgpCnByaW50ICJXcm90ZSBpbWRiIGlkLCAlcywgdG8gZmls
|
|
||||||
ZTogJXMiICUgKGltZGJJZCwgcGF0aCkK'''
|
|
||||||
|
|
||||||
script = re.sub(r"\{\[IMDBIDHERE\]\}", "'%s'" % imdb_id, base64.b64decode(scriptB64))
|
|
||||||
|
|
||||||
try:
|
|
||||||
f = open(pp_script_path, 'wb')
|
|
||||||
except:
|
|
||||||
log.info("Unable to open post-processing script for writing. Check permissions: %s" % pp_script_path)
|
|
||||||
return False
|
|
||||||
|
|
||||||
try:
|
|
||||||
f.write(script)
|
|
||||||
f.close()
|
|
||||||
except:
|
|
||||||
log.info("Unable to write to post-processing script. Check permissions: %s" % pp_script_path)
|
|
||||||
return False
|
|
||||||
|
|
||||||
log.info("Wrote post-processing script to: %s" % pp_script_path)
|
|
||||||
|
|
||||||
return os.path.basename(pp_script_path)
|
|
||||||
|
|
||||||
def getPpFile(self):
|
|
||||||
|
|
||||||
pp_script_handle, pp_script_path = mkstemp(suffix = '.py', dir = self.conf('ppDir'))
|
|
||||||
pp_sh = os.fdopen(pp_script_handle)
|
|
||||||
pp_sh.close()
|
|
||||||
|
|
||||||
try:
|
|
||||||
os.chmod(pp_script_path, int('777', 8))
|
|
||||||
except:
|
|
||||||
log.info("Unable to set post-processing script permissions to 777 (may still work correctly): %s" % pp_script_path)
|
|
||||||
|
|
||||||
return pp_script_path
|
|
||||||
Reference in new issue
Block a user