get imdb from db. minor fixes

This commit is contained in:
clinton-hall 2013-04-04 10:01:11 +10:30
parent 83f95f1f4f
commit b85289dda0
3 changed files with 15 additions and 5 deletions

View file

@ -54,9 +54,9 @@ def get_imdb(nzbName, dirName):
Logger.info("Postprocessing will continue, but the movie may not be identified correctly by CouchPotato") Logger.info("Postprocessing will continue, but the movie may not be identified correctly by CouchPotato")
return "" return ""
def get_movie_info(myOpener, baseURL, imdbid): def get_movie_info(myOpener, baseURL, imdbid, download_id):
if not imdbid: if not imdbid and not download_id:
return "" return ""
url = baseURL + "movie.list/?status=active" url = baseURL + "movie.list/?status=active"
@ -70,6 +70,16 @@ def get_movie_info(myOpener, baseURL, imdbid):
movie_id = "" movie_id = ""
result = json.load(urlObj) result = json.load(urlObj)
if not imdbid:
released = [item for item in result["movies"] if len(item["releases"]) > 0 and len(item["releases"]["info"]) > 0 and len(item["releases"]["info"]["download_id") > 0] # doing it in this order should stop exceeding list dimensions?
imdbid_list = [item["library"]["identifier"] for item in released if item["releases"]["info"]["download_id"] == download_id]
unique_imdbid_list = list(set(imdbid_list)) # convert this to a unique list to be sure we only have one imdbid
if len(unique_imdbid_list) == 1: # we found it.
imdbid = unique_imdbid_list[0]
Logger.info("Found movie id %s in database via download_id %s", imdbid, download_id)
else:
return ""
movieid = [item["id"] for item in result["movies"]] movieid = [item["id"] for item in result["movies"]]
library = [item["library"]["identifier"] for item in result["movies"]] library = [item["library"]["identifier"] for item in result["movies"]]
for index in range(len(movieid)): for index in range(len(movieid)):
@ -210,7 +220,7 @@ def process(dirName, nzbName=None, status=0, clientAgent = "manual", download_id
baseURL = protocol + host + ":" + port + web_root + "/api/" + apikey + "/" baseURL = protocol + host + ":" + port + web_root + "/api/" + apikey + "/"
movie_id = get_movie_info(myOpener, baseURL, imdbid) # get the CPS database movie id this movie. movie_id = get_movie_info(myOpener, baseURL, imdbid, download_id) # get the CPS database movie id this movie.
initial_status, clientAgent, download_id, initial_release_status = get_status(myOpener, baseURL, movie_id, clientAgent, download_id) initial_status, clientAgent, download_id, initial_release_status = get_status(myOpener, baseURL, movie_id, clientAgent, download_id)

View file

@ -162,5 +162,5 @@ def processEpisode(dirName, nzbName=None, failed=False):
result = urlObj.readlines() result = urlObj.readlines()
for line in result: for line in result:
Logger.info("%s", line) Logger.info("%s", line.rstrip())
return 0 # Success return 0 # Success

View file

@ -230,7 +230,7 @@ def parse_utorrent(args):
except: except:
inputID = '' inputID = ''
return inputDirectory, inputName, inputCategory, inputHash, inputID] return inputDirectory, inputName, inputCategory, inputHash, inputID
def parse_deluge(args): def parse_deluge(args):