psst icon indicating copy to clipboard operation
psst copied to clipboard

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

Open jacksongoode opened this issue 3 years ago • 6 comments

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
  1. MusicBrainz artist social links:
  • Takes MusicBrainz ID
  • Returns social links (ie. Wikidata, YouTube, SoundCloud, Facebook, Discogs, official pages, etc.)
  1. Wikidata to Wikipedia page:
  • Takes Wikidata ID
  • Returns Wikipedia pages by language
  1. 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.

jacksongoode avatar Jan 20 '22 22:01 jacksongoode

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

kingosticks avatar Jan 21 '22 19:01 kingosticks

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

jacksongoode avatar Jan 21 '22 19:01 jacksongoode

Excellent, thank you!

kingosticks avatar Jan 21 '22 20:01 kingosticks

That sounds great @jacksongoode!

jpochyla avatar Jan 22 '22 14:01 jpochyla

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 :)

jacksongoode avatar Feb 14 '22 08:02 jacksongoode

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

AmyMagdalena avatar Apr 13 '22 14:04 AmyMagdalena