From a68ec6bb78290fb881ded88a6174c7975cd433aa Mon Sep 17 00:00:00 2001 From: evilhero Date: Sun, 18 Feb 2018 16:46:06 -0500 Subject: [PATCH] FIX: fix for not having requests installed when using ComicRN - autoProcessComics updated to accomodate legacy fall-back mode via api --- mylar/__init__.py | 2 +- post-processing/autoProcessComics.py | 47 +++++++++++++++++++--------- 2 files changed, 34 insertions(+), 15 deletions(-) diff --git a/mylar/__init__.py b/mylar/__init__.py index 07f9e23a..5e5e10dc 100644 --- a/mylar/__init__.py +++ b/mylar/__init__.py @@ -134,7 +134,7 @@ LOCAL_IP = None DOWNLOAD_APIKEY = None CMTAGGER_PATH = None STATIC_COMICRN_VERSION = "1.01" -STATIC_APC_VERSION = "2.0" +STATIC_APC_VERSION = "2.01" SAB_PARAMS = None COMICINFO = [] SCHED = BackgroundScheduler({ diff --git a/post-processing/autoProcessComics.py b/post-processing/autoProcessComics.py index ac3319ae..cc5a268b 100644 --- a/post-processing/autoProcessComics.py +++ b/post-processing/autoProcessComics.py @@ -1,9 +1,17 @@ import sys -import requests import os.path 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): 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['comicrn_version'] = comicrn_version - try: - print("Opening URL for post-process of %s @ %s/forceProcess:" % (dirName,url)) - pp = requests.post(url, params=params, verify=False) - except Exception as e: - print("Unable to open URL: %s" %e) - sys.exit(1) - - print 'statuscode: %s' % pp.status_code - - result = pp.content - - print pp.content + if use_requests is True: + try: + print("Opening URL for post-process of %s @ %s/forceProcess:" % (dirName,url)) + pp = requests.post(url, params=params, verify=False) + except Exception as e: + print("Unable to open URL: %s" %e) + sys.exit(1) + else: + print 'statuscode: %s' % pp.status_code + result = 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): return 0