FIX: fix for not having requests installed when using ComicRN - autoProcessComics updated to accomodate legacy fall-back mode via api

This commit is contained in:
evilhero 2018-02-18 16:46:06 -05:00
parent 9c93d29c81
commit a68ec6bb78
2 changed files with 34 additions and 15 deletions

View File

@ -134,7 +134,7 @@ LOCAL_IP = None
DOWNLOAD_APIKEY = None DOWNLOAD_APIKEY = None
CMTAGGER_PATH = None CMTAGGER_PATH = None
STATIC_COMICRN_VERSION = "1.01" STATIC_COMICRN_VERSION = "1.01"
STATIC_APC_VERSION = "2.0" STATIC_APC_VERSION = "2.01"
SAB_PARAMS = None SAB_PARAMS = None
COMICINFO = [] COMICINFO = []
SCHED = BackgroundScheduler({ SCHED = BackgroundScheduler({

View File

@ -1,9 +1,17 @@
import sys import sys
import requests
import os.path import os.path
import ConfigParser import ConfigParser
import urllib2
import urllib
try:
import requests2
use_requests = True
except ImportError:
print "Requests module not found on system. I'll revert so this will work, but you probably should install "
print "requests to bypass this in the future (ie. pip install requests)"
use_requests = False
apc_version = "2.0" apc_version = "2.01"
def processEpisode(dirName, nzbName=None): def processEpisode(dirName, nzbName=None):
print "Your ComicRN.py script is outdated. I'll force this through, but Failed Download Handling and possible enhancements/fixes will not work and could cause errors." print "Your ComicRN.py script is outdated. I'll force this through, but Failed Download Handling and possible enhancements/fixes will not work and could cause errors."
@ -61,18 +69,29 @@ def processIssue(dirName, nzbName=None, failed=False, comicrn_version=None):
params['apc_version'] = apc_version params['apc_version'] = apc_version
params['comicrn_version'] = comicrn_version params['comicrn_version'] = comicrn_version
try: if use_requests is True:
print("Opening URL for post-process of %s @ %s/forceProcess:" % (dirName,url)) try:
pp = requests.post(url, params=params, verify=False) print("Opening URL for post-process of %s @ %s/forceProcess:" % (dirName,url))
except Exception as e: pp = requests.post(url, params=params, verify=False)
print("Unable to open URL: %s" %e) except Exception as e:
sys.exit(1) print("Unable to open URL: %s" %e)
sys.exit(1)
print 'statuscode: %s' % pp.status_code else:
print 'statuscode: %s' % pp.status_code
result = pp.content result = pp.content
print pp.content
print pp.content else:
url += "?" + urllib.urlencode(params)
print "Opening URL:", url
try:
urlObj = urllib2.urlopen(url)
except IOError, e:
print "Unable to open URL: ", str(e)
sys.exit(1)
else:
result = urlObj.readlines()
for line in result:
print line
if any("Post Processing SUCCESSFUL" in s for s in result): if any("Post Processing SUCCESSFUL" in s for s in result):
return 0 return 0