Skip to content

Commit

Permalink
Merge pull request #30 from Daanoz/feature/support-shared-albums
Browse files Browse the repository at this point in the history
feat: shared albums
  • Loading branch information
Daanoz authored Jun 19, 2023
2 parents cafa0c8 + 9a9521d commit 69dee13
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion custom_components/google_photos/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,16 @@ def get_albums() -> List[Album]:
album_list = []
while request is not None:
result = request.execute()
album_list = album_list + result["albums"]
album_list = album_list + result.get("albums", [])
request = albums.list_next(request, result)

sharedAlbums = service.sharedAlbums() # pylint: disable=no-member
fields = "sharedAlbums(id,title,mediaItemsCount),nextPageToken"
request = sharedAlbums.list(pageSize=50, fields=fields)
while request is not None:
result = request.execute()
album_list = album_list + result.get("sharedAlbums", [])
request = sharedAlbums.list_next(request, result)
return list(filter(lambda a: ("id" in a and "title" in a), album_list))

albums = await self.hass.async_add_executor_job(get_albums)
Expand Down

0 comments on commit 69dee13

Please sign in to comment.