studionow / pybrightcove

Python Implementation of the Brightcove Backend Integration API
http://help.brightcove.com/developer/docs/mediaapi/media-API.cfm
MIT License
29 stars 28 forks source link

Unexpected behavior with list-based calls and specifying pages #36

Open unbracketed opened 13 years ago

unbracketed commented 13 years ago

I was using Video.find_all to retrieve a set of videos and when I specified a page number and page size I was expecting to just get that set of results back but the logic of the iterator will continue through ALL pages of data. Does it not make sense to provide a way to retrieve a specified slice of the search results?

For example, I was hoping to get back the top 5 results with a call similar to:

Video.find_all(page_number=0, page_size=5)

But the iterator will keep requesting more pages once the first page of data is exhausted. https://github.com/studionow/pybrightcove/blob/master/pybrightcove/connection.py#L303 This is not ideal if you have thousands of records (or in any situation really where you don't want unnecessary data returned)

I worked around this by wrapping the result from Video.find_all in itertools.islice()