mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-20 05:13:16 -07:00
Added in a comparison check for last edited release incase we don't have enough information gathered to perform a proper status check.
This commit is contained in:
parent
88fd7f64ed
commit
66b8549914
2 changed files with 30 additions and 58 deletions
|
@ -9,7 +9,7 @@ from nzbtomedia import logger
|
||||||
|
|
||||||
|
|
||||||
class autoProcessMovie:
|
class autoProcessMovie:
|
||||||
def get_releases(self, baseURL, imdbid=None, download_id=None):
|
def get_release(self, baseURL, imdbid=None, download_id=None, release_status='snatched'):
|
||||||
results = {}
|
results = {}
|
||||||
params = {}
|
params = {}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ class autoProcessMovie:
|
||||||
continue
|
continue
|
||||||
releases = movie['releases']
|
releases = movie['releases']
|
||||||
for release in releases:
|
for release in releases:
|
||||||
if release['status'] not in ['snatched', 'done']:
|
if release['status'] not in release_status:
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
if download_id:
|
if download_id:
|
||||||
|
@ -51,6 +51,16 @@ class autoProcessMovie:
|
||||||
except:
|
except:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# Narrow results by removing old releases by comparing there last_edit field
|
||||||
|
if len(results) > 1:
|
||||||
|
for id1, x1 in results.items():
|
||||||
|
for id2, x2 in results.items():
|
||||||
|
try:
|
||||||
|
if x2["last_edit"] > x1["last_edit"]:
|
||||||
|
results.pop(id1)
|
||||||
|
except:
|
||||||
|
continue
|
||||||
|
|
||||||
# Search downloads on clients for a match to try and narrow our results down to 1
|
# Search downloads on clients for a match to try and narrow our results down to 1
|
||||||
if len(results) > 1:
|
if len(results) > 1:
|
||||||
for id, x in results.items():
|
for id, x in results.items():
|
||||||
|
@ -62,16 +72,6 @@ class autoProcessMovie:
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
|
||||||
def releases_diff(self, dict_a, dict_b):
|
|
||||||
return dict([
|
|
||||||
(key, dict_b.get(key, dict_a.get(key)))
|
|
||||||
for key in set(dict_a.keys() + dict_b.keys())
|
|
||||||
if (
|
|
||||||
(key in dict_a and (not key in dict_b or dict_a[key] != dict_b[key])) or
|
|
||||||
(key in dict_b and (not key in dict_a or dict_a[key] != dict_b[key]))
|
|
||||||
)
|
|
||||||
])
|
|
||||||
|
|
||||||
def process(self, dirName, nzbName=None, status=0, clientAgent="manual", download_id="", inputCategory=None):
|
def process(self, dirName, nzbName=None, status=0, clientAgent="manual", download_id="", inputCategory=None):
|
||||||
# auto-detect correct section
|
# auto-detect correct section
|
||||||
section = nzbtomedia.CFG.findsection(inputCategory)
|
section = nzbtomedia.CFG.findsection(inputCategory)
|
||||||
|
@ -110,18 +110,20 @@ class autoProcessMovie:
|
||||||
baseURL = "%s%s:%s%s/api/%s" % (protocol, host, port, web_root, apikey)
|
baseURL = "%s%s:%s%s/api/%s" % (protocol, host, port, web_root, apikey)
|
||||||
|
|
||||||
imdbid = find_imdbid(dirName, nzbName)
|
imdbid = find_imdbid(dirName, nzbName)
|
||||||
releases = self.get_releases(baseURL, imdbid, download_id)
|
release = self.get_release(baseURL, imdbid, download_id)
|
||||||
|
|
||||||
# pull info from release found if available
|
# pull info from release found if available
|
||||||
release_id = None
|
release_id = None
|
||||||
media_id = None
|
media_id = None
|
||||||
downloader = None
|
downloader = None
|
||||||
if len(releases) == 1:
|
release_status = None
|
||||||
|
if len(release) == 1:
|
||||||
try:
|
try:
|
||||||
release_id = releases.keys()[0]
|
release_id = release.keys()[0]
|
||||||
media_id = releases[release_id]['media_id']
|
media_id = release[release_id]['media_id']
|
||||||
download_id = releases[release_id]['download_info']['id']
|
download_id = release[release_id]['download_info']['id']
|
||||||
downloader = releases[release_id]['download_info']['downloader']
|
downloader = release[release_id]['download_info']['downloader']
|
||||||
|
release_status = release[release_id]['status']
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -223,13 +225,12 @@ class autoProcessMovie:
|
||||||
# we will now check to see if CPS has finished renaming before returning to TorrentToMedia and unpausing.
|
# we will now check to see if CPS has finished renaming before returning to TorrentToMedia and unpausing.
|
||||||
timeout = time.time() + 60 * wait_for
|
timeout = time.time() + 60 * wait_for
|
||||||
while (time.time() < timeout): # only wait 2 (default) minutes, then return.
|
while (time.time() < timeout): # only wait 2 (default) minutes, then return.
|
||||||
releases_current = self.get_releases(baseURL, imdbid, download_id)
|
release = self.get_release(baseURL, imdbid, download_id, 'downloaded,done')
|
||||||
logger.postprocess("Checking for status change, please stand by ...", section)
|
logger.postprocess("Checking for status change, please stand by ...", section)
|
||||||
if len(releases) != len(releases_current): # Something has changed. CPS must have processed this movie.
|
if release:
|
||||||
try:
|
try:
|
||||||
release_status = releases_current['status']
|
|
||||||
logger.postprocess("SUCCESS: Release %s has now been marked with a status of [%s]" % (
|
logger.postprocess("SUCCESS: Release %s has now been marked with a status of [%s]" % (
|
||||||
nzbName, str(release_status).upper()), section)
|
nzbName, str(release['status']).upper()), section)
|
||||||
return 0 # success
|
return 0 # success
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -1,41 +1,12 @@
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import nzbtomedia
|
|
||||||
import TorrentToMedia
|
import TorrentToMedia
|
||||||
from nzbtomedia.nzbToMediaUtil import find_download, isMediaFile
|
import nzbToMedia
|
||||||
|
|
||||||
nzbtomedia.initialize()
|
os.environ['TR_TORRENT_DIR']="z:/downloads/complete/movie/The.Lego.Movie.2014.R5.x264.English.XviD-vTg.nfo_0166_-_The.Lego.Movie.2014.R5.x264.English.XviD-vTg.nfo_yEn.cp(tt1490017)"
|
||||||
|
os.environ['TR_TORRENT_NAME']="The.Lego.Movie.2014.R5.x264.English.XviD-vTg.nfo_0166_-_The.Lego.Movie.2014.R5.x264.English.XviD-vTg.nfo_yEn.cp(tt1490017)"
|
||||||
|
os.environ['TR_TORRENT_ID']="7855bb5c20189a73ea45aaf80c2541dfcf897f9d"
|
||||||
|
os.environ['TR_TORRENT_HASH']="7855bb5c20189a73ea45aaf80c2541dfcf897f9d"
|
||||||
|
|
||||||
test = isMediaFile('test.mp4')
|
# Initialize the config
|
||||||
download_id = 'SABnzbd_nzo_qhoQ7m'
|
nzbToMedia.main(sys.argv)
|
||||||
if find_download('sabnzbd', download_id):
|
|
||||||
print 'found'
|
|
||||||
else:
|
|
||||||
print 'no luck'
|
|
||||||
|
|
||||||
print nzbtomedia.CFG['SickBear','NzbDrone']['tv'].isenabled()
|
|
||||||
print nzbtomedia.CFG['SickBeard','NzbDrone']['tv'].isenabled()
|
|
||||||
|
|
||||||
if nzbtomedia.CFG['SickBeard', 'NzbDrone', 'CouchPotato']['tv']:
|
|
||||||
print True
|
|
||||||
else:
|
|
||||||
print False
|
|
||||||
|
|
||||||
if nzbtomedia.CFG['SickBeard']['tv']:
|
|
||||||
print True
|
|
||||||
else:
|
|
||||||
print False
|
|
||||||
|
|
||||||
print
|
|
||||||
print nzbtomedia.SUBSECTIONS["SickBeard"]
|
|
||||||
print
|
|
||||||
print nzbtomedia.CFG.findsection('tv')
|
|
||||||
print
|
|
||||||
print nzbtomedia.CFG.sections
|
|
||||||
print
|
|
||||||
sections = ("CouchPotato", "SickBeard", "NzbDrone", "HeadPhones", "Mylar", "Gamez")
|
|
||||||
print nzbtomedia.CFG[sections].sections
|
|
||||||
print nzbtomedia.CFG['SickBeard'].sections
|
|
||||||
print
|
|
||||||
print nzbtomedia.CFG['SickBeard','NzbDrone']
|
|
||||||
print nzbtomedia.CFG['SickBeard']
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue