Skip to content

Commit

Permalink
Merge branch 'fondberg:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
fcusson authored Nov 3, 2021
2 parents ef9dcad + 49c85c5 commit 8080409
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__VERSION__ = "3.6.18"
__VERSION__ = "3.6.19"

bump:
bump2version --allow-dirty --current-version $(__VERSION__) patch Makefile custom_components/spotcast/manifest.json
Expand Down
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,13 +287,22 @@ friendly_name: Chromecast Devices
## Websocket API

The components websocket api.

Method: `spotcast/playlist` supporting different `playlist_type`s.

* `user`, or `default` for user chosen saved playlists
* `featured` for spotify "featured" playlists (not personalized)
* `discover-weekly` for personalized "Made for _____" (includes daily mixes)
* `recently-played` for "Recently Played"
* ... any other `view id` as found in the API at https://api.spotify.com/v1/views/personalized-recommendations

Example usage:

```python
// Retrieve playlists
const res = await this.props.hass.callWS({
type: 'spotcast/playlists',
playlist_type: 'featured', // one of 'user', 'discover-weekly' and 'featured'
playlist_type: 'featured', // 'user' for saved playlists, 'featured' for spotify featured, or personalized view id
country_code: 'SV', // Optional country code used by featured playlists
limit: 20, // Optional limit, default is 10
account: 'ming' // optional account name
Expand Down
2 changes: 1 addition & 1 deletion custom_components/spotcast/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"requirements": [
"spotify_token==1.0.0"
],
"version": "v3.6.18",
"version": "v3.6.19",
"dependencies": [
"spotify"
],
Expand Down
25 changes: 14 additions & 11 deletions custom_components/spotcast/spotcast_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,16 +276,10 @@ def get_playlists(self, account, playlist_type, country_code, locale, limit):
resp = {}

if playlist_type == "discover-weekly":
resp = client._get(
"views/made-for-x",
content_limit=limit,
locale=locale,
platform="web",
types="album,playlist,artist,show,station",
limit=limit,
offset=0,
)
resp = resp.get("content")
playlist_type = "made-for-x"

if playlist_type == "user" or playlist_type == "default" or playlist_type == "":
resp = client.current_user_playlists(limit=limit)
elif playlist_type == "featured":
resp = client.featured_playlists(
locale=locale,
Expand All @@ -296,6 +290,15 @@ def get_playlists(self, account, playlist_type, country_code, locale, limit):
)
resp = resp.get("playlists")
else:
resp = client.current_user_playlists(limit=limit)
resp = client._get(
"views/" + playlist_type,
content_limit=limit,
locale=locale,
platform="web",
types="album,playlist,artist,show,station",
limit=limit,
offset=0,
)
resp = resp.get("content")

return resp
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 3.6.18
current_version = 3.6.19

[flake8]
exclude = .venv,.git,.tox,docs,venv,bin,lib,deps,build
Expand Down

0 comments on commit 8080409

Please sign in to comment.