Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support lookups for 'your' URIs #313

Merged
merged 1 commit into from
Jan 26, 2022
Merged

Support lookups for 'your' URIs #313

merged 1 commit into from
Jan 26, 2022

Conversation

djmattyg007
Copy link
Contributor

This adds the ability to utilise the "spotify:your:tracks" and
"spotify:your:albums" URIs through library lookups.

@djmattyg007
Copy link
Contributor Author

I believe this should resolve #297

@djmattyg007 djmattyg007 mentioned this pull request Aug 9, 2021
@marnunez
Copy link

It does! Thanks!

@kosciej16
Copy link

@djmattyg007 Is there a chance to merge it? Possibility of playing liked songs would be awesome!

Comment on lines 119 to 122
web_album = item.get("album", item)
if not translator.valid_web_data(web_album, "album"):
continue
sp_link = session.get_link(web_album.get("uri"))
Copy link
Member

@kingosticks kingosticks Jan 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
web_album = item.get("album", item)
if not translator.valid_web_data(web_album, "album"):
continue
sp_link = session.get_link(web_album.get("uri"))
album_ref = translator.web_to_album_ref(web_album)
if album_ref is None:
continue
sp_link = session.get_link(album_ref.uri)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you be able to explain what the meaningful difference is between the two versions of this code?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the existing function hides the internal Web API structure and does some error checking for you. I appreciate you still need to know how the response is structured later on but this is one less place. I also have so far preferred not to called valid_web_data outside of the translator (although maybe we do this already, I can't remember and I've not checked)

@kingosticks kingosticks added A-webapi Area: Spotify Web API C-enhancement Category: A PR with an enhancement or an issue with an enhancement proposal labels Jan 13, 2022
@kingosticks kingosticks added this to the Next feature release milestone Jan 13, 2022
This adds the ability to utilise the "spotify:your:tracks" and
"spotify:your:albums" URIs through library lookups.
@djmattyg007
Copy link
Contributor Author

I've updated this PR. It should be good to go 👍

@kingosticks
Copy link
Member

Cool, so as a resulf of this we can now do:

  • core.library.lookup(uris=["spotify:your:tracks"])
  • core.library.search(query={"uris": ["spotify:your:tracks"]})

e.g.

curl -d '{"jsonrpc": "2.0", "id": 1, "method": "core.library.lookup", "params": {"uris": ["spotify:your:tracks"]}}' -H 'Content-Type: application/json' http://localhost:6680/mopidy/rpc

curl -d '{"jsonrpc": "2.0", "id": 1, "method": "core.library.search", "params": {"query": {"uri": ["spotify:your:tracks"]}}}' -H 'Content-Type: application/json' http://localhost:6680/mopidy/rpc

Perhaps we can use this functionality when we fix #328 (in a later PR).

@kingosticks kingosticks merged commit 6a9a510 into master Jan 26, 2022
@kingosticks kingosticks deleted the lookup_your branch January 26, 2022 16:24
kingosticks pushed a commit to kingosticks/mopidy-spotify that referenced this pull request Dec 20, 2023
This adds the ability to utilise the "spotify:your:tracks" and
"spotify:your:albums" URIs through library lookups.

Fixes mopidy#297
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-webapi Area: Spotify Web API C-enhancement Category: A PR with an enhancement or an issue with an enhancement proposal
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants