mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-19 12:59:36 -07:00
several styling and check status fixes. #376
This commit is contained in:
parent
d9465de4d8
commit
60787842ce
8 changed files with 96 additions and 17 deletions
|
@ -158,6 +158,8 @@
|
||||||
apikey =
|
apikey =
|
||||||
host = localhost
|
host = localhost
|
||||||
port = 8085
|
port = 8085
|
||||||
|
######
|
||||||
|
library = Set to path where you want the processed games to be moved to.
|
||||||
###### ADVANCED USE - ONLY EDIT IF YOU KNOW WHAT YOU'RE DOING ######
|
###### ADVANCED USE - ONLY EDIT IF YOU KNOW WHAT YOU'RE DOING ######
|
||||||
ssl = 0
|
ssl = 0
|
||||||
web_root =
|
web_root =
|
||||||
|
|
|
@ -41,6 +41,11 @@
|
||||||
# Set to 1 if using ssl, else set to 0.
|
# Set to 1 if using ssl, else set to 0.
|
||||||
#gzssl=0
|
#gzssl=0
|
||||||
|
|
||||||
|
# Gamez library
|
||||||
|
#
|
||||||
|
# move downloaded games here.
|
||||||
|
#gzlibrary
|
||||||
|
|
||||||
# Gamez web_root
|
# Gamez web_root
|
||||||
#
|
#
|
||||||
# set this if using a reverse proxy.
|
# set this if using a reverse proxy.
|
||||||
|
|
|
@ -221,6 +221,11 @@
|
||||||
# Set to 1 if using ssl, else set to 0.
|
# Set to 1 if using ssl, else set to 0.
|
||||||
#gzssl=0
|
#gzssl=0
|
||||||
|
|
||||||
|
# Gamez library
|
||||||
|
#
|
||||||
|
# move downloaded games here.
|
||||||
|
#gzlibrary
|
||||||
|
|
||||||
# Gamez web_root
|
# Gamez web_root
|
||||||
#
|
#
|
||||||
# set this if using a reverse proxy.
|
# set this if using a reverse proxy.
|
||||||
|
|
|
@ -2,26 +2,54 @@ import os
|
||||||
import time
|
import time
|
||||||
import nzbtomedia
|
import nzbtomedia
|
||||||
import requests
|
import requests
|
||||||
|
import time
|
||||||
from nzbtomedia.nzbToMediaUtil import convert_to_ascii, replaceExtensions
|
from nzbtomedia.nzbToMediaUtil import convert_to_ascii, replaceExtensions
|
||||||
from nzbtomedia import logger
|
from nzbtomedia import logger
|
||||||
|
|
||||||
class autoProcessComics:
|
class autoProcessComics:
|
||||||
|
def get_status(self, url, apikey, dirName):
|
||||||
|
logger.debug("Attempting to get current status for release:%s" % (os.path.basename(dirName)),section)
|
||||||
|
|
||||||
|
params = {}
|
||||||
|
params['apikey'] = apikey
|
||||||
|
params['cmd'] = "getHistory"
|
||||||
|
|
||||||
|
logger.debug("Opening URL: %s with PARAMS: %s" % (url, params))
|
||||||
|
|
||||||
|
try:
|
||||||
|
r = requests.get(url, params=params, verify=False)
|
||||||
|
except Exception, e:
|
||||||
|
logger.error("Unable to open URL")
|
||||||
|
return None
|
||||||
|
|
||||||
|
try:
|
||||||
|
result = r.json()
|
||||||
|
for issue in result:
|
||||||
|
if os.path.basename(dirName) == issue['FolderName']:
|
||||||
|
return issue["Status"].lower()
|
||||||
|
except:
|
||||||
|
return None
|
||||||
|
|
||||||
def processEpisode(self, section, dirName, inputName=None, status=0, clientAgent='manual', inputCategory=None):
|
def processEpisode(self, section, dirName, inputName=None, status=0, clientAgent='manual', inputCategory=None):
|
||||||
|
if status != 0:
|
||||||
|
logger.warning("FAILED DOWNLOAD DETECTED, nothing to process.",section)
|
||||||
|
return 0
|
||||||
|
|
||||||
host = nzbtomedia.CFG[section][inputCategory]["host"]
|
host = nzbtomedia.CFG[section][inputCategory]["host"]
|
||||||
port = nzbtomedia.CFG[section][inputCategory]["port"]
|
port = nzbtomedia.CFG[section][inputCategory]["port"]
|
||||||
username = nzbtomedia.CFG[section][inputCategory]["username"]
|
apikey = nzbtomedia.CFG[section][inputCategory]["apikey"]
|
||||||
password = nzbtomedia.CFG[section][inputCategory]["password"]
|
try:
|
||||||
|
wait_for = int(nzbtomedia.CFG[section][inputCategory]["wait_for"])
|
||||||
|
except:
|
||||||
|
wait_for = 1
|
||||||
try:
|
try:
|
||||||
ssl = int(nzbtomedia.CFG[section][inputCategory]["ssl"])
|
ssl = int(nzbtomedia.CFG[section][inputCategory]["ssl"])
|
||||||
except:
|
except:
|
||||||
ssl = 0
|
ssl = 0
|
||||||
|
|
||||||
try:
|
try:
|
||||||
web_root = nzbtomedia.CFG[section][inputCategory]["web_root"]
|
web_root = nzbtomedia.CFG[section][inputCategory]["web_root"]
|
||||||
except:
|
except:
|
||||||
web_root = ""
|
web_root = ""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
remote_path = nzbtomedia.CFG[section][inputCategory]["remote_path"]
|
remote_path = nzbtomedia.CFG[section][inputCategory]["remote_path"]
|
||||||
except:
|
except:
|
||||||
|
@ -32,9 +60,12 @@ class autoProcessComics:
|
||||||
replaceExtensions(dirName)
|
replaceExtensions(dirName)
|
||||||
|
|
||||||
params = {}
|
params = {}
|
||||||
params['nzb_folder'] = dirName
|
params['apikey'] = apikey
|
||||||
|
params['cmd'] = "forceProcess"
|
||||||
if remote_path:
|
if remote_path:
|
||||||
params['nzb_folder'] = os.path.join(remote_path, os.path.basename(dirName))
|
params['nzb_folder'] = os.path.join(remote_path, os.path.basename(dirName))
|
||||||
|
else:
|
||||||
|
params['nzb_folder'] = dirName
|
||||||
|
|
||||||
if inputName != None:
|
if inputName != None:
|
||||||
params['nzb_name'] = inputName
|
params['nzb_name'] = inputName
|
||||||
|
@ -44,11 +75,17 @@ class autoProcessComics:
|
||||||
else:
|
else:
|
||||||
protocol = "http://"
|
protocol = "http://"
|
||||||
|
|
||||||
url = "%s%s:%s%s/post_process" % (protocol, host, port, web_root)
|
url = "%s%s:%s%s/api" % (protocol, host, port, web_root)
|
||||||
|
|
||||||
|
release_status = self.get_status(url, apikey, dirName)
|
||||||
|
if not release_status:
|
||||||
|
logger.error("Could not find a status for %s, is it in the wanted list ?" % (inputName),section)
|
||||||
|
return 1
|
||||||
|
|
||||||
logger.debug("Opening URL: %s" % (url), section)
|
logger.debug("Opening URL: %s" % (url), section)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
r = requests.get(url, params=params, auth=(username, password), stream=True, verify=False)
|
r = requests.get(url, params=params, stream=True, verify=False)
|
||||||
except requests.ConnectionError:
|
except requests.ConnectionError:
|
||||||
logger.error("Unable to open URL", section)
|
logger.error("Unable to open URL", section)
|
||||||
return 1 # failure
|
return 1 # failure
|
||||||
|
@ -60,4 +97,18 @@ class autoProcessComics:
|
||||||
logger.error("Server returned status %s" % (str(r.status_code)), section)
|
logger.error("Server returned status %s" % (str(r.status_code)), section)
|
||||||
return 1
|
return 1
|
||||||
else:
|
else:
|
||||||
return 0
|
logger.postprocess("Post-Processing started for %s in folder %s ..." % (inputName, dirName),section)
|
||||||
|
|
||||||
|
# we will now wait 1 minutes for this album to be processed before returning to TorrentToMedia and unpausing.
|
||||||
|
timeout = time.time() + 60 * wait_for
|
||||||
|
while (time.time() < timeout): # only wait 1 (default) minutes, then return.
|
||||||
|
current_status = self.get_status(url, apikey, dirName)
|
||||||
|
if current_status is not None and current_status != release_status: # Something has changed. Mylar must have processed this issue.
|
||||||
|
logger.postprocess("SUCCESS: This issue is now marked as status [%s]" % (current_status),section)
|
||||||
|
return 0
|
||||||
|
|
||||||
|
time.sleep(10 * wait_for)
|
||||||
|
|
||||||
|
# The status hasn't changed. we have waited 2 minutes which is more than enough. uTorrent can resume seeding now.
|
||||||
|
logger.warning("The issue does not appear to have changed status after %s minutes. Please check your Logs" % (wait_for),section)
|
||||||
|
return 1 # failure
|
|
@ -1,5 +1,6 @@
|
||||||
import nzbtomedia
|
import nzbtomedia
|
||||||
import requests
|
import requests
|
||||||
|
import shutil
|
||||||
from nzbtomedia.nzbToMediaUtil import convert_to_ascii
|
from nzbtomedia.nzbToMediaUtil import convert_to_ascii
|
||||||
from nzbtomedia import logger
|
from nzbtomedia import logger
|
||||||
|
|
||||||
|
@ -10,12 +11,14 @@ class autoProcessGames:
|
||||||
host = nzbtomedia.CFG[section][inputCategory]["host"]
|
host = nzbtomedia.CFG[section][inputCategory]["host"]
|
||||||
port = nzbtomedia.CFG[section][inputCategory]["port"]
|
port = nzbtomedia.CFG[section][inputCategory]["port"]
|
||||||
apikey = nzbtomedia.CFG[section][inputCategory]["apikey"]
|
apikey = nzbtomedia.CFG[section][inputCategory]["apikey"]
|
||||||
|
try:
|
||||||
|
library = nzbtomedia.CFG[section][inputCategory]["library"]
|
||||||
|
except:
|
||||||
|
library = None
|
||||||
try:
|
try:
|
||||||
ssl = int(nzbtomedia.CFG[section][inputCategory]["ssl"])
|
ssl = int(nzbtomedia.CFG[section][inputCategory]["ssl"])
|
||||||
except:
|
except:
|
||||||
ssl = 0
|
ssl = 0
|
||||||
|
|
||||||
try:
|
try:
|
||||||
web_root = nzbtomedia.CFG[section][inputCategory]["web_root"]
|
web_root = nzbtomedia.CFG[section][inputCategory]["web_root"]
|
||||||
except:
|
except:
|
||||||
|
@ -54,6 +57,16 @@ class autoProcessGames:
|
||||||
|
|
||||||
result = r.json()
|
result = r.json()
|
||||||
logger.postprocess("%s" % (result),section)
|
logger.postprocess("%s" % (result),section)
|
||||||
|
if library:
|
||||||
|
logger.postprocess("moving files to library: %s" % (library),section)
|
||||||
|
try:
|
||||||
|
shutil.move(dirName, os.path.join(library, inputName))
|
||||||
|
except:
|
||||||
|
logger.error("Unable to move %s to %s" % (dirName, os.path.join(library, inputName)), section)
|
||||||
|
return 1
|
||||||
|
else:
|
||||||
|
logger.error("No library specified to move files to. Please edit your configuration.", section)
|
||||||
|
return 1
|
||||||
|
|
||||||
if not r.status_code in [requests.codes.ok, requests.codes.created, requests.codes.accepted]:
|
if not r.status_code in [requests.codes.ok, requests.codes.created, requests.codes.accepted]:
|
||||||
logger.error("Server returned status %s" % (str(r.status_code)), section)
|
logger.error("Server returned status %s" % (str(r.status_code)), section)
|
||||||
|
|
|
@ -109,5 +109,5 @@ class autoProcessMusic:
|
||||||
time.sleep(10 * wait_for)
|
time.sleep(10 * wait_for)
|
||||||
|
|
||||||
# The status hasn't changed. we have waited 2 minutes which is more than enough. uTorrent can resule seeding now.
|
# The status hasn't changed. we have waited 2 minutes which is more than enough. uTorrent can resule seeding now.
|
||||||
logger.warning("The music album does not appear to have changed status after %s minutes. Please check your Logs" % (wait_for))
|
logger.warning("The music album does not appear to have changed status after %s minutes. Please check your Logs" % (wait_for),section)
|
||||||
return 1 # failure
|
return 1 # failure
|
||||||
|
|
|
@ -42,9 +42,12 @@ class autoProcessTV:
|
||||||
|
|
||||||
host = nzbtomedia.CFG[section][inputCategory]["host"]
|
host = nzbtomedia.CFG[section][inputCategory]["host"]
|
||||||
port = nzbtomedia.CFG[section][inputCategory]["port"]
|
port = nzbtomedia.CFG[section][inputCategory]["port"]
|
||||||
username = nzbtomedia.CFG[section][inputCategory]["username"]
|
try:
|
||||||
password = nzbtomedia.CFG[section][inputCategory]["password"]
|
username = nzbtomedia.CFG[section][inputCategory]["username"]
|
||||||
|
password = nzbtomedia.CFG[section][inputCategory]["password"]
|
||||||
|
except:
|
||||||
|
username = ""
|
||||||
|
password = ""
|
||||||
try:
|
try:
|
||||||
apikey = nzbtomedia.CFG[section][inputCategory]["apikey"]
|
apikey = nzbtomedia.CFG[section][inputCategory]["apikey"]
|
||||||
except:
|
except:
|
||||||
|
|
|
@ -300,8 +300,8 @@ class ConfigObj(configobj.ConfigObj, Section):
|
||||||
|
|
||||||
section = "Gamez"
|
section = "Gamez"
|
||||||
envCatKey = 'NZBPO_GZCATEGORY'
|
envCatKey = 'NZBPO_GZCATEGORY'
|
||||||
envKeys = ['ENABLED', 'APIKEY', 'HOST', 'PORT', 'SSL', 'WEB_ROOT', 'WATCH_DIR']
|
envKeys = ['ENABLED', 'APIKEY', 'HOST', 'PORT', 'SSL', 'WEB_ROOT', 'WATCH_DIR', 'LIBRARY']
|
||||||
cfgKeys = ['enabled', 'apikey', 'host', 'port', 'ssl', 'web_root', 'watch_dir']
|
cfgKeys = ['enabled', 'apikey', 'host', 'port', 'ssl', 'web_root', 'watch_dir', 'library']
|
||||||
if os.environ.has_key(envCatKey):
|
if os.environ.has_key(envCatKey):
|
||||||
for index in range(len(envKeys)):
|
for index in range(len(envKeys)):
|
||||||
key = 'NZBPO_GZ' + envKeys[index]
|
key = 'NZBPO_GZ' + envKeys[index]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue