get_library_songs: add support for limit=None (closes #275)
add tests for get_library_subscriptions and get_library_artists with limit=None
This commit is contained in:
parent
ec771fc976
commit
98c4661fce
2 changed files with 11 additions and 14 deletions
|
|
@ -67,6 +67,9 @@ class LibraryMixin:
|
|||
request_func = lambda additionalParams: self._send_request(endpoint, body)
|
||||
parse_func = lambda raw_response: parse_library_songs(raw_response)
|
||||
|
||||
if validate_responses and limit is None:
|
||||
raise Exception("Validation is not supported without a limit parameter.")
|
||||
|
||||
if validate_responses:
|
||||
validate_func = lambda parsed: validate_response(parsed, per_page, limit, 0)
|
||||
response = resend_request_until_parsed_response_is_valid(request_func, None,
|
||||
|
|
@ -89,8 +92,9 @@ class LibraryMixin:
|
|||
request_continuations_func,
|
||||
parse_continuations_func))
|
||||
else:
|
||||
remaining_limit = None if limit is None else (limit - len(songs))
|
||||
songs.extend(
|
||||
get_continuations(results, 'musicShelfContinuation', limit - len(songs),
|
||||
get_continuations(results, 'musicShelfContinuation', remaining_limit,
|
||||
request_continuations_func, parse_continuations_func))
|
||||
|
||||
return songs
|
||||
|
|
|
|||
Loading…
Reference in a new issue