I am not sure why Flickr service returns multiple empty pages inside next() with the following code.
w = flickr_api.Walker(flickr_api.Photo.search, text="sydney night", license="8,9,10", media="photos")
for i, photo in enumerate(w):
<download the photo>
It crashed due to accessing empty list at around photo 728
Here is my fix:
def next(self):
if self._curr_index == len(self._curr_list):
if self._page < self._info.pages:
while self._page < self._info.pages:
self._page += 1
self.kwargs["page"] = self._page
self._curr_list = self.method(*self.args, **self.kwargs)
self._info = self._curr_list.info
self._curr_index = 0
if len(self._curr_list) == 0:
continue # here
break
if len(self._curr_list) == 0:
raise StopIteration()
else:
raise StopIteration()
curr = self._curr_list[self._curr_index]
self._curr_index += 1
return curr
I am not sure why Flickr service returns multiple empty pages inside next() with the following code.
It crashed due to accessing empty list at around photo 728 Here is my fix: