Skip to content

Commit

Permalink
[ 1.0.2 ] * Updated underlying spotifywebapiPython package requirem…
Browse files Browse the repository at this point in the history
…ent to version 1.0.31.
  • Loading branch information
thlucas1 committed Feb 28, 2024
1 parent 07fccaa commit 6c17522
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 22 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ config/*

# GIT support files to ignore.
/Git*.cmd
/Git*.txt

# Local project files to ignore.
/custom_components/spotifyplus/zzz_Publish.cmd
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ Change are listed in reverse chronological order (newest to oldest).

<span class="changelog">

###### [ 1.0.2 ] - 2024/02/28

* Updated underlying `spotifywebapiPython` package requirement to version 1.0.31.

###### [ 1.0.1 ] - 2024/02/25

* Version 1 initial release.
Expand Down
43 changes: 23 additions & 20 deletions custom_components/spotifyplus/browse_media.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ class BrowsableMedia(StrEnum):
BrowsableMedia.SPOTIFY_CATEGORY_PLAYLISTS_MADEFORYOU.value: {
"title": "Made For You",
"title_node": "Spotify Playlists Made For You",
"image": f"/local/images/{DOMAIN}_medialib_spotify_category_playlists_madeforyou.png",
"image": f"/local/images/{DOMAIN}_medialib_spotify_category_playlists_made_for_you.png",
"parent": MediaClass.DIRECTORY,
"children": MediaClass.PLAYLIST,
},
Expand Down Expand Up @@ -218,6 +218,9 @@ class BrowsableMedia(StrEnum):
BROWSE_LIMIT = 50
""" Max number of items to return from a Spotify Web API query. """

SPOTIFY_BROWSE_LIMIT_TOTAL = 100
""" Max number of items to return from a SpotifyPlus integration request that supports paging. """

CATEGORY_BASE64:str = "category_base64::"
""" Eye-catcher used to denote a serialized ContentItem. """

Expand Down Expand Up @@ -460,53 +463,53 @@ def browse_media_node(hass:HomeAssistant,
# - image: the image (if any) to display in the media browser (can be none).
if media_content_type == BrowsableMedia.SPOTIFY_USER_PLAYLISTS:
_logsi.LogVerbose("'%s': querying spotify for Playlist Favorites" % playerName)
media:PlaylistPageSimplified = client.GetPlaylistFavorites(limit=BROWSE_LIMIT)
media:PlaylistPageSimplified = client.GetPlaylistFavorites(limitTotal=BROWSE_LIMIT)
items = media.Items

elif media_content_type == BrowsableMedia.SPOTIFY_USER_FOLLOWED_ARTISTS:
_logsi.LogVerbose("'%s': querying spotify for Artists Followed" % playerName)
media:ArtistPage = client.GetArtistsFollowed(limit=BROWSE_LIMIT)
media:ArtistPage = client.GetArtistsFollowed(limitTotal=BROWSE_LIMIT)
items = media.Items

elif media_content_type == BrowsableMedia.SPOTIFY_USER_SAVED_ALBUMS:
_logsi.LogVerbose("Getting Spotify user Album favorites")
media:AlbumPageSaved = client.GetAlbumFavorites(limit=BROWSE_LIMIT)
media:AlbumPageSaved = client.GetAlbumFavorites(limitTotal=BROWSE_LIMIT)
items = media.GetAlbums()

elif media_content_type == BrowsableMedia.SPOTIFY_USER_SAVED_TRACKS:
_logsi.LogVerbose("Getting Spotify user Track favorites")
media:TrackPageSaved = client.GetTrackFavorites(limit=BROWSE_LIMIT)
media:TrackPageSaved = client.GetTrackFavorites(limitTotal=BROWSE_LIMIT)
items = media.GetTracks()

elif media_content_type == BrowsableMedia.SPOTIFY_USER_SAVED_SHOWS:
_logsi.LogVerbose("Getting Spotify user Show favorites")
media:ShowPageSaved = client.GetShowFavorites(limit=BROWSE_LIMIT)
media:ShowPageSaved = client.GetShowFavorites(limitTotal=BROWSE_LIMIT)
items = media.GetShows()

elif media_content_type == BrowsableMedia.SPOTIFY_USER_RECENTLY_PLAYED:
_logsi.LogVerbose("Getting Spotify user Recently Played Tracks")
media:PlayHistoryPage = client.GetPlayerRecentTracks(limit=BROWSE_LIMIT)
media:PlayHistoryPage = client.GetPlayerRecentTracks(limitTotal=BROWSE_LIMIT)
items = media.GetTracks()

elif media_content_type == BrowsableMedia.SPOTIFY_USER_TOP_ARTISTS:
_logsi.LogVerbose("Getting Spotify user Top Artists")
media:ArtistPage = client.GetUsersTopArtists(limit=BROWSE_LIMIT)
media:ArtistPage = client.GetUsersTopArtists(limitTotal=BROWSE_LIMIT)
items = media.Items

elif media_content_type == BrowsableMedia.SPOTIFY_USER_TOP_TRACKS:
_logsi.LogVerbose("Getting Spotify user Top Tracks")
media:TrackPage = client.GetUsersTopTracks(limit=BROWSE_LIMIT)
media:TrackPage = client.GetUsersTopTracks(limitTotal=BROWSE_LIMIT)
items = media.Items

elif media_content_type == BrowsableMedia.SPOTIFY_FEATURED_PLAYLISTS:
_logsi.LogVerbose("Getting Spotify Featured Playlists for country (%s)" % client.UserProfile.Country)
_logsi.LogVerbose("Getting Spotify Featured Playlists")
media:PlaylistPageSimplified
media, message = client.GetFeaturedPlaylists(limit=BROWSE_LIMIT, country=client.UserProfile.Country)
media, message = client.GetFeaturedPlaylists(limitTotal=BROWSE_LIMIT)
items = media.Items

elif media_content_type == BrowsableMedia.SPOTIFY_CATEGORYS:
_logsi.LogVerbose("Getting Spotify Categories for country (%s)" % client.UserProfile.Country)
media:list[Category] = client.GetBrowseCategorysList(country=client.UserProfile.Country, refresh=False)
_logsi.LogVerbose("Getting Spotify Categories")
media:list[Category] = client.GetBrowseCategorysList(refresh=False)
items = media

# add a "Uri" attribute to each category in the cached category list.
Expand All @@ -521,7 +524,7 @@ def browse_media_node(hass:HomeAssistant,
_logsi.LogVerbose("Category Uri set: Name='%s', Id='%s', Uri='%s'" % (category.Name, category.Id, category.Uri))

elif media_content_type == BrowsableMedia.SPOTIFY_CATEGORY_PLAYLISTS:
_logsi.LogVerbose("Getting Spotify Category Playlist for country (%s)" % client.UserProfile.Country)
_logsi.LogVerbose("Getting Spotify Category Playlist")

# was a base64 encoded category object supplied? if not, then it's a problem!
if not media_content_id.startswith(CATEGORY_BASE64):
Expand All @@ -536,20 +539,20 @@ def browse_media_node(hass:HomeAssistant,

# get the playlists for the category id.
media:PlaylistPageSimplified
media, message = client.GetCategoryPlaylists(media_content_id, limit=BROWSE_LIMIT, country=client.UserProfile.Country)
media, message = client.GetCategoryPlaylists(media_content_id, limitTotal=BROWSE_LIMIT)
items = media.Items
title = category.Name
image = category.ImageUrl

elif media_content_type == BrowsableMedia.SPOTIFY_CATEGORY_PLAYLISTS_MADEFORYOU:
_logsi.LogVerbose("Getting Spotify 'Made For You' Category Playlist for country (%s)" % client.UserProfile.Country)
_logsi.LogVerbose("Getting Spotify 'Made For You' Category Playlist")
media_content_id = '0JQ5DAt0tbjZptfcdMSKl3' # special hidden category "Made For You"
media, message = client.GetCategoryPlaylists(media_content_id, limit=BROWSE_LIMIT, country=client.UserProfile.Country)
media, message = client.GetCategoryPlaylists(media_content_id, limitTotal=BROWSE_LIMIT)
items = media.Items

elif media_content_type == BrowsableMedia.SPOTIFY_NEW_RELEASES:
_logsi.LogVerbose("Getting Spotify Album New Releases for country (%s)" % client.UserProfile.Country)
media:AlbumPageSimplified = client.GetAlbumNewReleases(limit=BROWSE_LIMIT, country=client.UserProfile.Country)
_logsi.LogVerbose("Getting Spotify Album New Releases")
media:AlbumPageSimplified = client.GetAlbumNewReleases(limitTotal=BROWSE_LIMIT)
items = media.Items

# elif media_content_type == BrowsableMedia.SPOTIFY_USER_DAILY_MIXES:
Expand All @@ -569,7 +572,7 @@ def browse_media_node(hass:HomeAssistant,
_logsi.LogVerbose("Getting Spotify Artist Albums")
spotifyId:str = SpotifyClient.GetIdFromUri(media_content_id)
artist:Artist = client.GetArtist(spotifyId) # for cover image
media:AlbumPageSimplified = client.GetArtistAlbums(spotifyId, include_groups='album', limit=BROWSE_LIMIT)
media:AlbumPageSimplified = client.GetArtistAlbums(spotifyId, include_groups='album', limitTotal=BROWSE_LIMIT)
items = media.Items
title = artist.Name
image = artist.ImageUrl
Expand Down
2 changes: 1 addition & 1 deletion custom_components/spotifyplus/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"issue_tracker": "https://github.com/thlucas1/homeassistantcomponent_spotifyplus/issues",
"requirements": [
"smartinspectPython==3.0.33",
"spotifywebapiPython==1.0.30",
"spotifywebapiPython==1.0.31",
"urllib3>=1.21.1,<1.27"
],
"version": "1.0.1",
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ colorlog==6.7.0
homeassistant==2023.10.5
ruff==0.1.3
smartinspectPython>=3.0.33
spotifywebapiPython==1.0.30
spotifywebapiPython==1.0.31

0 comments on commit 6c17522

Please sign in to comment.