only parse movie list 50 at a time. Fixes #206

This commit is contained in:
clinton-hall 2013-11-25 10:18:12 +10:30
parent 6473b3ac65
commit 9dae7979e4

View file

@ -45,27 +45,40 @@ def get_movie_info(baseURL, imdbid, download_id):
if not imdbid and not download_id: if not imdbid and not download_id:
return "" return ""
url = baseURL + "movie.list/?status=active"
Logger.debug("Opening URL: %s", url)
try:
urlObj = urllib.urlopen(url)
except:
Logger.exception("Unable to open URL")
return ""
movie_id = "" movie_id = ""
releaselist = [] releaselist = []
try: movieid = []
result = json.load(urlObj) library = []
movieid = [item["id"] for item in result["movies"]] offset = int(0)
library = [item["library"]["identifier"] for item in result["movies"]] while True:
except: url = baseURL + "movie.list/?status=active" + "&limit_offset=50," + str(offset)
Logger.exception("Unable to parse json data for movies")
return ""
for index in range(len(movieid)): Logger.debug("Opening URL: %s", url)
try:
urlObj = urllib.urlopen(url)
except:
Logger.exception("Unable to open URL")
break
movieid2 = []
library2 = []
try:
result = json.load(urlObj)
movieid2 = [item["id"] for item in result["movies"]]
library2 = [item["library"]["identifier"] for item in result["movies"]]
except:
Logger.exception("Unable to parse json data for movies")
break
movieid.append(movieid2)
library.append(library2)
if len(movieid2) < int(50): # finished parsing list of movies. Time to break.
break
offset = offset + 50
for index in range(len(movieid)):
if not imdbid: if not imdbid:
url = baseURL + "movie.get/?id=" + str(movieid[index]) url = baseURL + "movie.get/?id=" + str(movieid[index])
Logger.debug("Opening URL: %s", url) Logger.debug("Opening URL: %s", url)