mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-07-14 01:02:55 -07:00
parent
a3db8fb4b6
commit
aee3b151c0
8 changed files with 263 additions and 5 deletions
|
@ -13,7 +13,7 @@ import sys
|
||||||
|
|
||||||
import core
|
import core
|
||||||
from core import logger, main_db
|
from core import logger, main_db
|
||||||
from core.auto_process import comics, games, movies, music, tv
|
from core.auto_process import comics, games, movies, music, tv, books
|
||||||
from core.auto_process.common import ProcessResult
|
from core.auto_process.common import ProcessResult
|
||||||
from core.plugins.plex import plex_update
|
from core.plugins.plex import plex_update
|
||||||
from core.user_scripts import external_script
|
from core.user_scripts import external_script
|
||||||
|
@ -256,6 +256,9 @@ def process_torrent(input_directory, input_name, input_category, input_hash, inp
|
||||||
result = comics.process(section_name, output_destination, input_name, status, client_agent, input_category)
|
result = comics.process(section_name, output_destination, input_name, status, client_agent, input_category)
|
||||||
elif section_name == 'Gamez':
|
elif section_name == 'Gamez':
|
||||||
result = games.process(section_name, output_destination, input_name, status, client_agent, input_category)
|
result = games.process(section_name, output_destination, input_name, status, client_agent, input_category)
|
||||||
|
elif section_name == 'LazyLibrarian':
|
||||||
|
result = books.process(section_name, output_destination, input_name, status, client_agent, input_category)
|
||||||
|
|
||||||
|
|
||||||
plex_update(input_category)
|
plex_update(input_category)
|
||||||
|
|
||||||
|
|
|
@ -282,6 +282,31 @@
|
||||||
##### Set to path where download client places completed downloads locally for this category
|
##### Set to path where download client places completed downloads locally for this category
|
||||||
watch_dir =
|
watch_dir =
|
||||||
|
|
||||||
|
[LazyLibrarian]
|
||||||
|
#### autoProcessing for Games
|
||||||
|
#### games - category that gets called for post-processing with Gamez
|
||||||
|
[[books]]
|
||||||
|
enabled = 0
|
||||||
|
apikey =
|
||||||
|
host = localhost
|
||||||
|
port = 5299
|
||||||
|
###### ADVANCED USE - ONLY EDIT IF YOU KNOW WHAT YOU'RE DOING ######
|
||||||
|
ssl = 0
|
||||||
|
web_root =
|
||||||
|
# Enable/Disable linking for Torrents
|
||||||
|
Torrent_NoLink = 0
|
||||||
|
keep_archive = 1
|
||||||
|
extract = 1
|
||||||
|
# Set this to minimum required size to consider a media file valid (in MB)
|
||||||
|
minSize = 0
|
||||||
|
# Enable/Disable deleting ignored files (samples and invalid media files)
|
||||||
|
delete_ignored = 0
|
||||||
|
##### Enable if LazyLibrarian is on a remote server for this category
|
||||||
|
remote_path = 0
|
||||||
|
##### Set to path where download client places completed downloads locally for this category
|
||||||
|
watch_dir =
|
||||||
|
|
||||||
|
|
||||||
[Network]
|
[Network]
|
||||||
# Enter Mount points as LocalPath,RemotePath and separate each pair with '|'
|
# Enter Mount points as LocalPath,RemotePath and separate each pair with '|'
|
||||||
# e.g. MountPoints = /volume1/Public/,E:\|/volume2/share/,\\NAS\
|
# e.g. MountPoints = /volume1/Public/,E:\|/volume2/share/,\\NAS\
|
||||||
|
|
75
core/auto_process/books.py
Normal file
75
core/auto_process/books.py
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
# coding=utf-8
|
||||||
|
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
|
||||||
|
import requests
|
||||||
|
|
||||||
|
import core
|
||||||
|
from core import logger
|
||||||
|
from core.auto_process.common import ProcessResult
|
||||||
|
from core.utils import convert_to_ascii, server_responding
|
||||||
|
|
||||||
|
requests.packages.urllib3.disable_warnings()
|
||||||
|
|
||||||
|
|
||||||
|
def process(section, dir_name, input_name=None, status=0, client_agent='manual', input_category=None):
|
||||||
|
status = int(status)
|
||||||
|
|
||||||
|
cfg = dict(core.CFG[section][input_category])
|
||||||
|
|
||||||
|
host = cfg['host']
|
||||||
|
port = cfg['port']
|
||||||
|
apikey = cfg['apikey']
|
||||||
|
ssl = int(cfg.get('ssl', 0))
|
||||||
|
web_root = cfg.get('web_root', '')
|
||||||
|
protocol = 'https://' if ssl else 'http://'
|
||||||
|
|
||||||
|
url = '{0}{1}:{2}{3}/api'.format(protocol, host, port, web_root)
|
||||||
|
if not server_responding(url):
|
||||||
|
logger.error('Server did not respond. Exiting', section)
|
||||||
|
return ProcessResult(
|
||||||
|
message='{0}: Failed to post-process - {0} did not respond.'.format(section),
|
||||||
|
status_code=1,
|
||||||
|
)
|
||||||
|
|
||||||
|
input_name, dir_name = convert_to_ascii(input_name, dir_name)
|
||||||
|
|
||||||
|
params = {
|
||||||
|
'api_key': apikey,
|
||||||
|
'cmd': 'forceProcess',
|
||||||
|
'dir': dir_name,
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.debug('Opening URL: {0}'.format(url), section)
|
||||||
|
|
||||||
|
try:
|
||||||
|
r = requests.get(url, params=params, verify=False, timeout=(30, 300))
|
||||||
|
except requests.ConnectionError:
|
||||||
|
logger.error('Unable to open URL')
|
||||||
|
return ProcessResult(
|
||||||
|
message='{0}: Failed to post-process - Unable to connect to {1}'.format(section, section),
|
||||||
|
status_code=1,
|
||||||
|
)
|
||||||
|
|
||||||
|
result = r.json()
|
||||||
|
logger.postprocess('{0}'.format(result), section)
|
||||||
|
|
||||||
|
if r.status_code not in [requests.codes.ok, requests.codes.created, requests.codes.accepted]:
|
||||||
|
logger.error('Server returned status {0}'.format(r.status_code), section)
|
||||||
|
return ProcessResult(
|
||||||
|
message='{0}: Failed to post-process - Server returned status {1}'.format(section, r.status_code),
|
||||||
|
status_code=1,
|
||||||
|
)
|
||||||
|
elif result['success']:
|
||||||
|
logger.postprocess('SUCCESS: ForceProcess for {0} has been started in LazyLibrarian'.format(dir_name), section)
|
||||||
|
return ProcessResult(
|
||||||
|
message='{0}: Successfully post-processed {1}'.format(section, input_name),
|
||||||
|
status_code=0,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
logger.error('FAILED: ForceProcess of {0} has Failed in LazyLibrarian'.format(dir_name), section)
|
||||||
|
return ProcessResult(
|
||||||
|
message='{0}: Failed to post-process - Returned log from {0} was not as expected.'.format(section),
|
||||||
|
status_code=1,
|
||||||
|
)
|
|
@ -383,6 +383,21 @@ class ConfigObj(configobj.ConfigObj, Section):
|
||||||
cfg_new[section][os.environ[env_cat_key]][option] = value
|
cfg_new[section][os.environ[env_cat_key]][option] = value
|
||||||
cfg_new[section][os.environ[env_cat_key]]['enabled'] = 1
|
cfg_new[section][os.environ[env_cat_key]]['enabled'] = 1
|
||||||
|
|
||||||
|
section = 'LazyLibrarian'
|
||||||
|
env_cat_key = 'NZBPO_LLCATEGORY'
|
||||||
|
env_keys = ['ENABLED', 'APIKEY', 'HOST', 'PORT', 'SSL', 'WEB_ROOT', 'WATCH_DIR', 'REMOTE_PATH']
|
||||||
|
cfg_keys = ['enabled', 'apikey', 'host', 'port', 'ssl', 'web_root', 'watch_dir', 'remote_path']
|
||||||
|
if env_cat_key in os.environ:
|
||||||
|
for index in range(len(env_keys)):
|
||||||
|
key = 'NZBPO_LL{index}'.format(index=env_keys[index])
|
||||||
|
if key in os.environ:
|
||||||
|
option = cfg_keys[index]
|
||||||
|
value = os.environ[key]
|
||||||
|
if os.environ[env_cat_key] not in cfg_new[section].sections:
|
||||||
|
cfg_new[section][os.environ[env_cat_key]] = {}
|
||||||
|
cfg_new[section][os.environ[env_cat_key]][option] = value
|
||||||
|
cfg_new[section][os.environ[env_cat_key]]['enabled'] = 1
|
||||||
|
|
||||||
section = 'NzbDrone'
|
section = 'NzbDrone'
|
||||||
env_cat_key = 'NZBPO_NDCATEGORY'
|
env_cat_key = 'NZBPO_NDCATEGORY'
|
||||||
env_keys = ['ENABLED', 'HOST', 'APIKEY', 'PORT', 'SSL', 'WEB_ROOT', 'WATCH_DIR', 'FORK', 'DELETE_FAILED',
|
env_keys = ['ENABLED', 'HOST', 'APIKEY', 'PORT', 'SSL', 'WEB_ROOT', 'WATCH_DIR', 'FORK', 'DELETE_FAILED',
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
##############################################################################
|
##############################################################################
|
||||||
### NZBGET POST-PROCESSING SCRIPT ###
|
### NZBGET POST-PROCESSING SCRIPT ###
|
||||||
|
|
||||||
# Post-Process to CouchPotato, SickBeard, NzbDrone, Mylar, Gamez, HeadPhones.
|
# Post-Process to CouchPotato.
|
||||||
#
|
#
|
||||||
# This script sends the download to your automated media management servers.
|
# This script sends the download to your automated media management servers.
|
||||||
#
|
#
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
##############################################################################
|
##############################################################################
|
||||||
### NZBGET POST-PROCESSING SCRIPT ###
|
### NZBGET POST-PROCESSING SCRIPT ###
|
||||||
|
|
||||||
# Post-Process to CouchPotato, SickBeard, NzbDrone, Mylar, Gamez, HeadPhones.
|
# Post-Process to Gamez.
|
||||||
#
|
#
|
||||||
# This script sends the download to your automated media management servers.
|
# This script sends the download to your automated media management servers.
|
||||||
#
|
#
|
||||||
|
|
104
nzbToLazyLibrarian.py
Executable file
104
nzbToLazyLibrarian.py
Executable file
|
@ -0,0 +1,104 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
# coding=utf-8
|
||||||
|
#
|
||||||
|
##############################################################################
|
||||||
|
### NZBGET POST-PROCESSING SCRIPT ###
|
||||||
|
|
||||||
|
# Post-Process to LazyLibrarian.
|
||||||
|
#
|
||||||
|
# This script sends the download to your automated media management servers.
|
||||||
|
#
|
||||||
|
# NOTE: This script requires Python to be installed on your system.
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
#
|
||||||
|
### OPTIONS ###
|
||||||
|
|
||||||
|
## General
|
||||||
|
|
||||||
|
# Auto Update nzbToMedia (0, 1).
|
||||||
|
#
|
||||||
|
# Set to 1 if you want nzbToMedia to automatically check for and update to the latest version
|
||||||
|
#auto_update=0
|
||||||
|
|
||||||
|
# Safe Mode protection of DestDir (0, 1).
|
||||||
|
#
|
||||||
|
# Enable/Disable a safety check to ensure we don't process all downloads in the default_downloadDirectory by mistake.
|
||||||
|
#safe_mode=1
|
||||||
|
|
||||||
|
## LazyLibrarian
|
||||||
|
|
||||||
|
# LazyLibrarian script category.
|
||||||
|
#
|
||||||
|
# category that gets called for post-processing with LazyLibrarian.
|
||||||
|
#llCategory=games
|
||||||
|
|
||||||
|
# LazyLibrarian api key.
|
||||||
|
#llapikey=
|
||||||
|
|
||||||
|
# LazyLibrarian host.
|
||||||
|
#
|
||||||
|
# The ipaddress for your LazyLibrarian server. e.g For the Same system use localhost or 127.0.0.1
|
||||||
|
#llhost=localhost
|
||||||
|
|
||||||
|
# LazyLibrarian port.
|
||||||
|
#llport=5299
|
||||||
|
|
||||||
|
# LazyLibrarian uses ssl (0, 1).
|
||||||
|
#
|
||||||
|
# Set to 1 if using ssl, else set to 0.
|
||||||
|
#llssl=0
|
||||||
|
|
||||||
|
# LazyLibrarian web_root
|
||||||
|
#
|
||||||
|
# set this if using a reverse proxy.
|
||||||
|
#llweb_root=
|
||||||
|
|
||||||
|
# LazyLibrarian watch directory.
|
||||||
|
#
|
||||||
|
# set this to where your LazyLibrarian completed downloads are.
|
||||||
|
#llwatch_dir=
|
||||||
|
|
||||||
|
## Posix
|
||||||
|
|
||||||
|
# Niceness for external tasks Extractor and Transcoder.
|
||||||
|
#
|
||||||
|
# Set the Niceness value for the nice command. These range from -20 (most favorable to the process) to 19 (least favorable to the process).
|
||||||
|
#niceness=10
|
||||||
|
|
||||||
|
# ionice scheduling class (0, 1, 2, 3).
|
||||||
|
#
|
||||||
|
# Set the ionice scheduling class. 0 for none, 1 for real time, 2 for best-effort, 3 for idle.
|
||||||
|
#ionice_class=2
|
||||||
|
|
||||||
|
# ionice scheduling class data.
|
||||||
|
#
|
||||||
|
# Set the ionice scheduling class data. This defines the class data, if the class accepts an argument. For real time and best-effort, 0-7 is valid data.
|
||||||
|
#ionice_classdata=4
|
||||||
|
|
||||||
|
## WakeOnLan
|
||||||
|
|
||||||
|
# use WOL (0, 1).
|
||||||
|
#
|
||||||
|
# set to 1 to send WOL broadcast to the mac and test the server (e.g. xbmc) on the host and port specified.
|
||||||
|
#wolwake=0
|
||||||
|
|
||||||
|
# WOL MAC
|
||||||
|
#
|
||||||
|
# enter the mac address of the system to be woken.
|
||||||
|
#wolmac=00:01:2e:2D:64:e1
|
||||||
|
|
||||||
|
# Set the Host and Port of a server to verify system has woken.
|
||||||
|
#wolhost=192.168.1.37
|
||||||
|
#wolport=80
|
||||||
|
|
||||||
|
### NZBGET POST-PROCESSING SCRIPT ###
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
|
import nzbToMedia
|
||||||
|
|
||||||
|
section = 'LazyLibrarian'
|
||||||
|
result = nzbToMedia.main(sys.argv, section)
|
||||||
|
sys.exit(result)
|
|
@ -4,7 +4,8 @@
|
||||||
##############################################################################
|
##############################################################################
|
||||||
### NZBGET POST-PROCESSING SCRIPT ###
|
### NZBGET POST-PROCESSING SCRIPT ###
|
||||||
|
|
||||||
# Post-Process to CouchPotato, SickBeard, NzbDrone, Mylar, Gamez, HeadPhones.
|
# Post-Process to CouchPotato, SickBeard, Sonarr, Mylar, Gamez, HeadPhones,
|
||||||
|
# LazyLibrarian, Radarr, Lidarr
|
||||||
#
|
#
|
||||||
# This script sends the download to your automated media management servers.
|
# This script sends the download to your automated media management servers.
|
||||||
#
|
#
|
||||||
|
@ -410,6 +411,39 @@
|
||||||
# Enable to replace local path with the path as per the mountPoints below.
|
# Enable to replace local path with the path as per the mountPoints below.
|
||||||
#gzremote_path=0
|
#gzremote_path=0
|
||||||
|
|
||||||
|
## LazyLibrarian
|
||||||
|
|
||||||
|
# LazyLibrarian script category.
|
||||||
|
#
|
||||||
|
# category that gets called for post-processing with LazyLibrarian.
|
||||||
|
#llCategory=games
|
||||||
|
|
||||||
|
# LazyLibrarian api key.
|
||||||
|
#llapikey=
|
||||||
|
|
||||||
|
# LazyLibrarian host.
|
||||||
|
#
|
||||||
|
# The ipaddress for your LazyLibrarian server. e.g For the Same system use localhost or 127.0.0.1
|
||||||
|
#llhost=localhost
|
||||||
|
|
||||||
|
# LazyLibrarian port.
|
||||||
|
#llport=5299
|
||||||
|
|
||||||
|
# LazyLibrarian uses ssl (0, 1).
|
||||||
|
#
|
||||||
|
# Set to 1 if using ssl, else set to 0.
|
||||||
|
#llssl=0
|
||||||
|
|
||||||
|
# LazyLibrarian web_root
|
||||||
|
#
|
||||||
|
# set this if using a reverse proxy.
|
||||||
|
#llweb_root=
|
||||||
|
|
||||||
|
# LazyLibrarian watch directory.
|
||||||
|
#
|
||||||
|
# set this to where your LazyLibrarian completed downloads are.
|
||||||
|
#llwatch_dir=
|
||||||
|
|
||||||
## Network
|
## Network
|
||||||
|
|
||||||
# Network Mount Points (Needed for remote path above)
|
# Network Mount Points (Needed for remote path above)
|
||||||
|
@ -635,7 +669,7 @@ import sys
|
||||||
|
|
||||||
import core
|
import core
|
||||||
from core import logger, main_db
|
from core import logger, main_db
|
||||||
from core.auto_process import comics, games, movies, music, tv
|
from core.auto_process import comics, games, movies, music, tv, books
|
||||||
from core.auto_process.common import ProcessResult
|
from core.auto_process.common import ProcessResult
|
||||||
from core.plugins.downloaders.nzb.utils import get_nzoid
|
from core.plugins.downloaders.nzb.utils import get_nzoid
|
||||||
from core.plugins.plex import plex_update
|
from core.plugins.plex import plex_update
|
||||||
|
@ -763,6 +797,8 @@ def process(input_directory, input_name=None, status=0, client_agent='manual', d
|
||||||
result = comics.process(section_name, input_directory, input_name, status, client_agent, input_category)
|
result = comics.process(section_name, input_directory, input_name, status, client_agent, input_category)
|
||||||
elif section_name == 'Gamez':
|
elif section_name == 'Gamez':
|
||||||
result = games.process(section_name, input_directory, input_name, status, client_agent, input_category)
|
result = games.process(section_name, input_directory, input_name, status, client_agent, input_category)
|
||||||
|
elif section_name == 'LazyLibrarian':
|
||||||
|
result = books.process(section_name, input_directory, input_name, status, client_agent, input_category)
|
||||||
elif section_name == 'UserScript':
|
elif section_name == 'UserScript':
|
||||||
result = external_script(input_directory, input_name, input_category, section[usercat])
|
result = external_script(input_directory, input_name, input_category, section[usercat])
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue