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,7 +45,14 @@ def get_movie_info(baseURL, imdbid, download_id):
if not imdbid and not download_id:
return ""
url = baseURL + "movie.list/?status=active"
movie_id = ""
releaselist = []
movieid = []
library = []
offset = int(0)
while True:
url = baseURL + "movie.list/?status=active" + "&limit_offset=50," + str(offset)
Logger.debug("Opening URL: %s", url)
@ -53,17 +60,23 @@ def get_movie_info(baseURL, imdbid, download_id):
urlObj = urllib.urlopen(url)
except:
Logger.exception("Unable to open URL")
return ""
break
movie_id = ""
releaselist = []
movieid2 = []
library2 = []
try:
result = json.load(urlObj)
movieid = [item["id"] for item in result["movies"]]
library = [item["library"]["identifier"] for item in result["movies"]]
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")
return ""
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: