mirror of
https://github.com/pkkid/python-plexapi
synced 2024-11-22 03:33:08 +00:00
* Fix: stop maxresults from overwriting previous results * Added test for use of maxresults in fetchItems #1393 * Removed the need for last_container_size #1393 * Renamed collections to better represen what is being tested * Renamed collections to better represent what is being tested #1393 * Update tests/test_library.py with cleaner test Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com> --------- Co-authored-by: Graham Thompson <graham.c.thompson@gmail.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>
This commit is contained in:
parent
bf925c60e1
commit
3e752d5f27
2 changed files with 15 additions and 5 deletions
|
@ -283,6 +283,11 @@ class PlexObject:
|
|||
|
||||
results.extend(subresults)
|
||||
|
||||
container_start += container_size
|
||||
|
||||
if container_start > total_size:
|
||||
break
|
||||
|
||||
wanted_number_of_items = total_size - offset
|
||||
if maxresults is not None:
|
||||
wanted_number_of_items = min(maxresults, wanted_number_of_items)
|
||||
|
@ -291,11 +296,6 @@ class PlexObject:
|
|||
if wanted_number_of_items <= len(results):
|
||||
break
|
||||
|
||||
container_start += container_size
|
||||
|
||||
if container_start > total_size:
|
||||
break
|
||||
|
||||
return results
|
||||
|
||||
def fetchItem(self, ekey, cls=None, **kwargs):
|
||||
|
|
|
@ -120,6 +120,16 @@ def test_library_fetchItem(plex, movie):
|
|||
assert item1 == item2 == movie
|
||||
|
||||
|
||||
def test_library_fetchItems_with_maxresults(plex, tvshows):
|
||||
items = tvshows.searchEpisodes()
|
||||
assert len(items) > 5
|
||||
size = len(items) - 5
|
||||
ratingKeys = [item.ratingKey for item in items]
|
||||
items1 = plex.fetchItems(ekey=ratingKeys, container_size=size)
|
||||
items2 = plex.fetchItems(ekey=ratingKeys, container_size=size, maxresults=len(items))
|
||||
assert items1 == items2 == items
|
||||
|
||||
|
||||
def test_library_onDeck(plex, movie):
|
||||
movie.updateProgress(movie.duration // 4) # set progress to 25%
|
||||
assert movie in plex.library.onDeck()
|
||||
|
|
Loading…
Reference in a new issue