Skip to content
This repository has been archived by the owner on May 3, 2019. It is now read-only.

Loading Album information in the Spotify plugin #273

Open
mariusor opened this issue Aug 20, 2018 · 4 comments
Open

Loading Album information in the Spotify plugin #273

mariusor opened this issue Aug 20, 2018 · 4 comments
Labels

Comments

@mariusor
Copy link

Description:

A followup to #272.

Unfortunately I haven't found any simple way of extracting the album information from the player web-page.

Is it possible to reuse the web-player authenticated session to actually execute an API request?

For example the hyperlink of the anchor representing the title of the song contains the album id. Which we could use to execute an API request1 GET https://api.spotify.com/v1/albums/{id}

Basically my questions are:

  1. Does the plugin support a mechanism for creating an XHR request ?
  2. Does the plugin support triggering this request without interfering with the rest of the functionality?
  3. Does the plugin support reusing the authenticated user session of the player?

Additional Information:

  • Version: MellowPlayer 3.4.0.0
  • Affected streaming services (if any): Spotify
  • Operating System: *(if using GNU/Linux): Archlinux, native package compiled from aur, with QtWebEngine Widevine

[1] https://developer.spotify.com/documentation/web-api/reference/albums/get-album/

@mariusor
Copy link
Author

OK, so I managed to solve the first two questions.

The only problem is to extract a valid Authorization: Bearer XXX header from the other requests. Does anyone have any advice?

@mariusor
Copy link
Author

mariusor commented Aug 24, 2018

Update.

I have a working version of the Spotify plugin which loads the data from the API, but the only missing part is the Authorization header which needs to be intercepted from the other requests.

Since there isn't any way to intercept them at DOM level, I was thinking that maybe it's possible to use QWebEngineUrlRequestInterceptor from the Qt code to extract this header and then make it available it in the spotify plugin script.

@CDuquesnoy is this a feasable option? (I'm asking because my Qt is very rusty, and the new QWebView APIs are completely foreign to me)

@ColinDuquesnoy
Copy link
Owner

Everything is possible, but I don't like the idea to add c++ code specifically for a plugin. I'd prefer if plugin specific code would remain in the plugin itself.

I've never done that but wouldn't it be possible to simply redefine the prototype of HttpRequest.open? This blog post might help you get started: https://dmitripavlutin.com/catch-the-xmlhttp-request-in-plain-javascript/

@ColinDuquesnoy
Copy link
Owner

This issue has been moved to our new gitlab issue tracker.

The github repository will be archived soon and this issue will become read-only. We suggest you continue the discussion and follow the progress on this issue at gitlab.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants