mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-19 12:59:36 -07:00
autoProcessMovie now returns newest snatched download if it fails to have a download_id to use or a imdbid, this ensures a release is always returned now even for manual runs.
This commit is contained in:
parent
d65448db87
commit
a24c37ce6b
3 changed files with 25 additions and 6 deletions
|
@ -319,7 +319,7 @@ def process(nzbDir, inputName=None, status=0, clientAgent='manual', download_id=
|
||||||
result = autoProcessGames().process(nzbDir, inputName, status, clientAgent, inputCategory)
|
result = autoProcessGames().process(nzbDir, inputName, status, clientAgent, inputCategory)
|
||||||
else:
|
else:
|
||||||
logger.postprocess("We could not find a section with the download category of %s in your autoProcessMedia.cfg. Exiting.", inputCategory)
|
logger.postprocess("We could not find a section with the download category of %s in your autoProcessMedia.cfg. Exiting.", inputCategory)
|
||||||
return -1
|
result = -1
|
||||||
|
|
||||||
if result == 0:
|
if result == 0:
|
||||||
# Clean up any leftover files
|
# Clean up any leftover files
|
||||||
|
|
|
@ -15,7 +15,7 @@ from nzbtomedia import logger
|
||||||
from nzbtomedia.transmissionrpc.client import Client as TransmissionClient
|
from nzbtomedia.transmissionrpc.client import Client as TransmissionClient
|
||||||
|
|
||||||
class autoProcessMovie:
|
class autoProcessMovie:
|
||||||
def find_release_info(self, baseURL, download_id, dirName, nzbName):
|
def find_release_info(self, baseURL, download_id, dirName, nzbName, clientAgent):
|
||||||
imdbid = None
|
imdbid = None
|
||||||
release_id = None
|
release_id = None
|
||||||
media_id = None
|
media_id = None
|
||||||
|
@ -54,21 +54,35 @@ class autoProcessMovie:
|
||||||
|
|
||||||
results = r.json()
|
results = r.json()
|
||||||
|
|
||||||
def search_results(results):
|
def search_results(results, clientAgent):
|
||||||
|
last_edit = {}
|
||||||
for movie in results['movies']:
|
for movie in results['movies']:
|
||||||
if imdbid:
|
if imdbid:
|
||||||
if imdbid != movie['identifiers']['imdb']:
|
if imdbid != movie['identifiers']['imdb']:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
for release in movie['releases']:
|
for i, release in enumerate(movie['releases']):
|
||||||
if release['status'] != 'snatched':
|
if release['status'] != 'snatched':
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if clientAgent != 'manual':
|
||||||
|
if release['download_info']['download'] == clientAgent:
|
||||||
|
return release
|
||||||
|
else:
|
||||||
|
date = datetime.datetime.fromtimestamp(release['last_edit'])
|
||||||
|
last_edit[date] = {}
|
||||||
|
last_edit[date].update(release)
|
||||||
|
|
||||||
if download_id:
|
if download_id:
|
||||||
if release['download_info']['id'] == download_id:
|
if release['download_info']['id'] == download_id:
|
||||||
return release
|
return release
|
||||||
|
|
||||||
matched_release = search_results(results)
|
if last_edit:
|
||||||
|
last_edit = sorted(last_edit.items())
|
||||||
|
release = last_edit[0][1]
|
||||||
|
return release
|
||||||
|
|
||||||
|
matched_release = search_results(results, clientAgent)
|
||||||
|
|
||||||
if matched_release:
|
if matched_release:
|
||||||
try:
|
try:
|
||||||
|
@ -150,7 +164,7 @@ class autoProcessMovie:
|
||||||
|
|
||||||
baseURL = protocol + host + ":" + port + web_root + "/api/" + apikey
|
baseURL = protocol + host + ":" + port + web_root + "/api/" + apikey
|
||||||
|
|
||||||
media_id, download_id, release_id, release_status = self.find_release_info(baseURL, download_id, dirName, nzbName)
|
media_id, download_id, release_id, release_status = self.find_release_info(baseURL, download_id, dirName, nzbName, clientAgent)
|
||||||
|
|
||||||
if release_status:
|
if release_status:
|
||||||
if release_status != "snatched":
|
if release_status != "snatched":
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue