mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-19 21:03:14 -07:00
add watcher3 integration (#1665)
This commit is contained in:
parent
80ef0d094e
commit
1814bd5ae1
5 changed files with 92 additions and 22 deletions
|
@ -213,7 +213,7 @@ def process_torrent(input_directory, input_name, input_category, input_hash, inp
|
||||||
core.flatten(output_destination)
|
core.flatten(output_destination)
|
||||||
|
|
||||||
# Now check if video files exist in destination:
|
# Now check if video files exist in destination:
|
||||||
if section_name in ['SickBeard', 'NzbDrone', 'Sonarr', 'CouchPotato', 'Radarr']:
|
if section_name in ['SickBeard', 'NzbDrone', 'Sonarr', 'CouchPotato', 'Radarr', 'Watcher3']:
|
||||||
num_videos = len(
|
num_videos = len(
|
||||||
core.list_media_files(output_destination, media=True, audio=False, meta=False, archives=False))
|
core.list_media_files(output_destination, media=True, audio=False, meta=False, archives=False))
|
||||||
if num_videos > 0:
|
if num_videos > 0:
|
||||||
|
@ -227,7 +227,7 @@ def process_torrent(input_directory, input_name, input_category, input_hash, inp
|
||||||
|
|
||||||
# Only these sections can handling failed downloads
|
# Only these sections can handling failed downloads
|
||||||
# so make sure everything else gets through without the check for failed
|
# so make sure everything else gets through without the check for failed
|
||||||
if section_name not in ['CouchPotato', 'Radarr', 'SickBeard', 'NzbDrone', 'Sonarr']:
|
if section_name not in ['CouchPotato', 'Radarr', 'SickBeard', 'NzbDrone', 'Sonarr', 'Watcher3']:
|
||||||
status = 0
|
status = 0
|
||||||
|
|
||||||
logger.info('Calling {0}:{1} to post-process:{2}'.format(section_name, usercat, input_name))
|
logger.info('Calling {0}:{1} to post-process:{2}'.format(section_name, usercat, input_name))
|
||||||
|
@ -241,7 +241,7 @@ def process_torrent(input_directory, input_name, input_category, input_hash, inp
|
||||||
)
|
)
|
||||||
if section_name == 'UserScript':
|
if section_name == 'UserScript':
|
||||||
result = external_script(output_destination, input_name, input_category, section)
|
result = external_script(output_destination, input_name, input_category, section)
|
||||||
elif section_name in ['CouchPotato', 'Radarr']:
|
elif section_name in ['CouchPotato', 'Radarr', 'Watcher3']:
|
||||||
result = movies.process(section_name, output_destination, input_name, status, client_agent, input_hash, input_category)
|
result = movies.process(section_name, output_destination, input_name, status, client_agent, input_hash, input_category)
|
||||||
elif section_name in ['SickBeard', 'NzbDrone', 'Sonarr']:
|
elif section_name in ['SickBeard', 'NzbDrone', 'Sonarr']:
|
||||||
if input_hash:
|
if input_hash:
|
||||||
|
|
1
_config.yml
Normal file
1
_config.yml
Normal file
|
@ -0,0 +1 @@
|
||||||
|
theme: jekyll-theme-cayman
|
|
@ -111,6 +111,36 @@
|
||||||
##### Set to define import behavior Move or Copy
|
##### Set to define import behavior Move or Copy
|
||||||
importMode = Copy
|
importMode = Copy
|
||||||
|
|
||||||
|
[Watcher3]
|
||||||
|
#### autoProcessing for Movies
|
||||||
|
#### movie - category that gets called for post-processing with CPS
|
||||||
|
[[movie]]
|
||||||
|
enabled = 0
|
||||||
|
apikey =
|
||||||
|
host = localhost
|
||||||
|
port = 9090
|
||||||
|
###### ADVANCED USE - ONLY EDIT IF YOU KNOW WHAT YOU'RE DOING ######
|
||||||
|
ssl = 0
|
||||||
|
web_root =
|
||||||
|
# api key for www.omdbapi.com (used as alternative to imdb)
|
||||||
|
omdbapikey =
|
||||||
|
# Enable/Disable linking for Torrents
|
||||||
|
Torrent_NoLink = 0
|
||||||
|
keep_archive = 1
|
||||||
|
delete_failed = 0
|
||||||
|
wait_for = 0
|
||||||
|
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 Watcher3 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 =
|
||||||
|
##### Set the recursive directory permissions to the following (0 to disable)
|
||||||
|
chmodDirectory = 0
|
||||||
|
|
||||||
[SickBeard]
|
[SickBeard]
|
||||||
#### autoProcessing for TV Series
|
#### autoProcessing for TV Series
|
||||||
#### tv - category that gets called for post-processing with SB
|
#### tv - category that gets called for post-processing with SB
|
||||||
|
|
|
@ -72,6 +72,8 @@ def process(section, dir_name, input_name=None, status=0, client_agent='manual',
|
||||||
base_url = '{0}{1}:{2}{3}/api/command'.format(protocol, host, port, web_root)
|
base_url = '{0}{1}:{2}{3}/api/command'.format(protocol, host, port, web_root)
|
||||||
url2 = '{0}{1}:{2}{3}/api/config/downloadClient'.format(protocol, host, port, web_root)
|
url2 = '{0}{1}:{2}{3}/api/config/downloadClient'.format(protocol, host, port, web_root)
|
||||||
headers = {'X-Api-Key': apikey}
|
headers = {'X-Api-Key': apikey}
|
||||||
|
if section == 'Watcher3':
|
||||||
|
base_url = '{0}{1}:{2}{3}/postprocessing'.format(protocol, host, port, web_root)
|
||||||
if not apikey:
|
if not apikey:
|
||||||
logger.info('No CouchPotato or Radarr apikey entered. Performing transcoder functions only')
|
logger.info('No CouchPotato or Radarr apikey entered. Performing transcoder functions only')
|
||||||
release = None
|
release = None
|
||||||
|
@ -178,7 +180,7 @@ def process(section, dir_name, input_name=None, status=0, client_agent='manual',
|
||||||
os.rename(video, video2)
|
os.rename(video, video2)
|
||||||
|
|
||||||
if not apikey: # If only using Transcoder functions, exit here.
|
if not apikey: # If only using Transcoder functions, exit here.
|
||||||
logger.info('No CouchPotato or Radarr apikey entered. Processing completed.')
|
logger.info('No CouchPotato or Radarr or Watcher3 apikey entered. Processing completed.')
|
||||||
return ProcessResult(
|
return ProcessResult(
|
||||||
message='{0}: Successfully post-processed {1}'.format(section, input_name),
|
message='{0}: Successfully post-processed {1}'.format(section, input_name),
|
||||||
status_code=0,
|
status_code=0,
|
||||||
|
@ -210,9 +212,20 @@ def process(section, dir_name, input_name=None, status=0, client_agent='manual',
|
||||||
logger.debug('Opening URL: {0} with PARAMS: {1}'.format(base_url, payload), section)
|
logger.debug('Opening URL: {0} with PARAMS: {1}'.format(base_url, payload), section)
|
||||||
logger.postprocess('Starting DownloadedMoviesScan scan for {0}'.format(input_name), section)
|
logger.postprocess('Starting DownloadedMoviesScan scan for {0}'.format(input_name), section)
|
||||||
|
|
||||||
|
if section == 'Watcher3':
|
||||||
|
if input_name and os.path.isfile(os.path.join(dir_name, input_name)):
|
||||||
|
params['media_folder'] = os.path.join(params['media_folder'], input_name)
|
||||||
|
payload = {'apikey': apikey, 'path': params['media_folder'], 'guid': download_id, 'mode': 'complete'}
|
||||||
|
if not download_id:
|
||||||
|
payload.pop('guid')
|
||||||
|
logger.debug('Opening URL: {0} with PARAMS: {1}'.format(base_url, payload), section)
|
||||||
|
logger.postprocess('Starting postprocessing scan for {0}'.format(input_name), section)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if section == 'CouchPotato':
|
if section == 'CouchPotato':
|
||||||
r = requests.get(url, params=params, verify=False, timeout=(30, 1800))
|
r = requests.get(url, params=params, verify=False, timeout=(30, 1800))
|
||||||
|
elif section == 'Watcher3':
|
||||||
|
r = requests.post(base_url, data=payload, verify=False, timeout=(30, 1800))
|
||||||
else:
|
else:
|
||||||
r = requests.post(base_url, data=json.dumps(payload), headers=headers, stream=True, verify=False, timeout=(30, 1800))
|
r = requests.post(base_url, data=json.dumps(payload), headers=headers, stream=True, verify=False, timeout=(30, 1800))
|
||||||
except requests.ConnectionError:
|
except requests.ConnectionError:
|
||||||
|
@ -245,6 +258,18 @@ def process(section, dir_name, input_name=None, status=0, client_agent='manual',
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning('No scan id was returned due to: {0}'.format(e), section)
|
logger.warning('No scan id was returned due to: {0}'.format(e), section)
|
||||||
scan_id = None
|
scan_id = None
|
||||||
|
elif section == 'Watcher3' and result['status'] == 'finished':
|
||||||
|
logger.postprocess('Watcher3 updated status to {0}'.format(result['tasks']['update_movie_status']))
|
||||||
|
if result['tasks']['update_movie_status'] == 'Finished':
|
||||||
|
return ProcessResult(
|
||||||
|
message='{0}: Successfully post-processed {1}'.format(section, input_name),
|
||||||
|
status_code=status,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
return ProcessResult(
|
||||||
|
message='{0}: Failed to post-process - changed status to {1}'.format(section, result['tasks']['update_movie_status']),
|
||||||
|
status_code=1,
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
logger.error('FAILED: {0} scan was unable to finish for folder {1}. exiting!'.format(method, dir_name),
|
logger.error('FAILED: {0} scan was unable to finish for folder {1}. exiting!'.format(method, dir_name),
|
||||||
section)
|
section)
|
||||||
|
@ -264,6 +289,20 @@ def process(section, dir_name, input_name=None, status=0, client_agent='manual',
|
||||||
message='{0}: Sending failed download back to {0}'.format(section),
|
message='{0}: Sending failed download back to {0}'.format(section),
|
||||||
status_code=1, # Return as failed to flag this in the downloader.
|
status_code=1, # Return as failed to flag this in the downloader.
|
||||||
) # Return failed flag, but log the event as successful.
|
) # Return failed flag, but log the event as successful.
|
||||||
|
elif section == 'Watcher3':
|
||||||
|
logger.postprocess('Sending failed download to {0} for CDH processing'.format(section), section)
|
||||||
|
path = remote_dir(dir_name) if remote_path else dir_name
|
||||||
|
if input_name and os.path.isfile(os.path.join(dir_name, input_name)):
|
||||||
|
path = os.path.join(path, input_name)
|
||||||
|
payload = {'apikey': apikey, 'path': path, 'guid': download_id, 'mode': 'failed'}
|
||||||
|
r = requests.post(base_url, data=payload, verify=False, timeout=(30, 1800))
|
||||||
|
result = r.json()
|
||||||
|
logger.postprocess('Watcher3 response: {0}'.format(result))
|
||||||
|
if result['status'] == 'finished':
|
||||||
|
return ProcessResult(
|
||||||
|
message='{0}: Sending failed download back to {0}'.format(section),
|
||||||
|
status_code=1, # Return as failed to flag this in the downloader.
|
||||||
|
) # Return failed flag, but log the event as successful.
|
||||||
|
|
||||||
if delete_failed and os.path.isdir(dir_name) and not os.path.dirname(dir_name) == dir_name:
|
if delete_failed and os.path.isdir(dir_name) and not os.path.dirname(dir_name) == dir_name:
|
||||||
logger.postprocess('Deleting failed files and folder {0}'.format(dir_name), section)
|
logger.postprocess('Deleting failed files and folder {0}'.format(dir_name), section)
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
### NZBGET POST-PROCESSING SCRIPT ###
|
### NZBGET POST-PROCESSING SCRIPT ###
|
||||||
|
|
||||||
# Post-Process to CouchPotato, SickBeard, Sonarr, Mylar, Gamez, HeadPhones,
|
# Post-Process to CouchPotato, SickBeard, Sonarr, Mylar, Gamez, HeadPhones,
|
||||||
# LazyLibrarian, Radarr, Lidarr
|
# LazyLibrarian, Radarr, Lidarr, Watcher3
|
||||||
#
|
#
|
||||||
# This script sends the download to your automated media management servers.
|
# This script sends the download to your automated media management servers.
|
||||||
#
|
#
|
||||||
|
@ -799,7 +799,7 @@ def process(input_directory, input_name=None, status=0, client_agent='manual', d
|
||||||
|
|
||||||
logger.info('Calling {0}:{1} to post-process:{2}'.format(section_name, input_category, input_name))
|
logger.info('Calling {0}:{1} to post-process:{2}'.format(section_name, input_category, input_name))
|
||||||
|
|
||||||
if section_name in ['CouchPotato', 'Radarr']:
|
if section_name in ['CouchPotato', 'Radarr', 'Watcher3']:
|
||||||
result = movies.process(section_name, input_directory, input_name, status, client_agent, download_id, input_category, failure_link)
|
result = movies.process(section_name, input_directory, input_name, status, client_agent, download_id, input_category, failure_link)
|
||||||
elif section_name in ['SickBeard', 'NzbDrone', 'Sonarr']:
|
elif section_name in ['SickBeard', 'NzbDrone', 'Sonarr']:
|
||||||
result = tv.process(section_name, input_directory, input_name, status, client_agent, download_id, input_category, failure_link)
|
result = tv.process(section_name, input_directory, input_name, status, client_agent, download_id, input_category, failure_link)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue