jpochyla / psst

Fast and multi-platform Spotify client with native GUI
MIT License
8.48k stars 216 forks source link

[WIP] Spotify artist URI to social pages, Wiki summary #268

Closed jacksongoode closed 5 days ago

jacksongoode commented 2 years ago

Since seeing this feature on the roadmap, I thought I'd get the initial architecture in place to make sure this might be the best/most effective string of API calls to make.

Right now it takes two calls to reach social links, four to reach a Wiki summary:

  1. MusicBrainz url lookup:

    • Takes Spotify artist URL
    • Returns MusicBrains ID
  2. MusicBrainz artist social links:

    • Takes MusicBrainz ID
    • Returns social links (ie. Wikidata, YouTube, SoundCloud, Facebook, Discogs, official pages, etc.)
  3. Wikidata to Wikipedia page:

    • Takes Wikidata ID
    • Returns Wikipedia pages by language
  4. Fetch summary:

    • Takes Wikipedia page
    • Returns summary of artist page

I feel like it should be possible to reach the MusicBrainz social links with one call, but their API docs are a bit of a mess. The total call time with reqwests is around 3-4s.

kingosticks commented 2 years ago

How are you getting the musicbrainz ID from a Spotify URL? Is there some API to do that that I've missed?

jacksongoode commented 2 years ago

How are you getting the musicbrainz ID from a Spotify URL? Is there some API to do that that I've missed?

The MusicBrainz ID is retrieved by looking up which artist has the Spotify URL in their metadata on MusicBrainz.

For example: https://beta.musicbrainz.org/ws/2/url/?query=url:https://open.spotify.com/artist/1WZarnZpWEv7dDtjAETt4X

kingosticks commented 2 years ago

Excellent, thank you!

jpochyla commented 2 years ago

That sounds great @jacksongoode!

jacksongoode commented 2 years ago

A proof of concept using ureq can be checked out here. First time working with Rust so it might take me a while to integrate :)

AmyMagdalena commented 2 years ago

For example: https://beta.musicbrainz.org/ws/2/url/?query=url:https://open.spotify.com/artist/1WZarnZpWEv7dDtjAETt4X

Not sure if important but the URI without the subdomain of beta. produces the same XML data

https://musicbrainz.org/ws/2/url/?query=url:https://open.spotify.com/artist/1WZarnZpWEv7dDtjAETt4X

non-beta URI I feel is potentially more future stable

SO9010 commented 2 weeks ago

Heya, spotify does this and I am probably able to use the same API request format as I did with getting the lyrics for the songs as it's the same background api provider.

Screenshot_20241002-131956.png

jacksongoode commented 5 days ago

Closed with #537