Mastermindzh/tidal-hifi

Last.fm integration

guraltsev opened this issue ยท 13 comments

Last.fm integration doesn't seem to work. I click on the button in "settings". A new window opens. I log into last.fm and authorize the music player and the window changes to all white with the message

This window may now be closed.

But then, once I close the window, if I go back into settings last.fm still seems disconnected.

Signing into last.fm through chrome or firefox works fine.

Please let me know if I can provide any more info. Thank you very much for the app!

Just writing in to let you know I've received this and I will start investigating it next week.

Sorry, been incredibly busy :)

I confirmed the bug, I don't have a clue how to fix it yet.

If anyone has an idea I'd love to hear about it.

I ran thorough testing on this, and I'm positive it's due to Electron lack of support for window.opener.
The last.fm popup window tries to send its token to Tidal's callback, but it can't access it due to said limitations.

โžœ env ELECTRON_ENABLE_LOGGING=1 npm start

tidal-hifi@1.0.1 start /home/markkuit/dev/tidal-hifi
electron .

[1822651:0428/150228.794579:INFO:CONSOLE(24)] "Uncaught TypeError: window.opener.receiveLastFMLoginMessage is not a function", source: https://listen.tidal.com/lastfmcallback.html?path=/settings&token=[...] (24)

I managed to get it working by enabling experimental support via the sandbox option, which makes so that renderers must delegate certain tasks to the main process via IPC for security and isolation purposes, having Chromium render the content and incidentally working around the lack of support for window.opener. This still poses some limitations (see this and this), however none of those should matter, mainly because we don't care for Node.js in this scenario.

An alternative solution might have been using the nativeWindowOpen option (as suggested here), which however caused me some headaches due to CSP/CORS policies and I ended up discarding it.

For the sake of tracking, I'll open a pull request for this. I didn't up the package version, that's up to you.

I'll take the occasion to thank you for this much appreciated project.

No problem mate, high fidelity music should be listened to on every platform.
Until Tidal decides to build and maintain a solution for all platforms I'll keep working on this project :)

The readme now has a workaround to "fix" this :)
Enjoy!

@Mastermindzh, what do you actually use as the Rescrobbled player-whitelist value to target Tidal-hifi? Using playerctl --list-all I get something like chromium.instance2168528 for Tidal-hifi, but the numbers change every time it's restarted, so it's not a long term solution.

Of course it works if I leave the player-whitelist empty, but then Rescrobbled would scrobble media from every possible player it recognizes, which is not good.

@Tuuuukka , I don't use last.fm, I'm pretty much relying entirely on others here, sorry ๐Ÿ˜„

If you know/have any idea how one would change the name of that 'chromium.instance' (even for general linux apps) I might be able to figure something out.

If you know/have any idea how one would change the name of that 'chromium.instance' (even for general linux apps) I might be able to figure something out.

Sorry, I don't know how that could be done (or if it's possible at all anyway ๐Ÿ˜„). That would of course be the clearest way to target Tidal-hifi in Rescrobbled.

I'll have a look next time I work on this (probably the weekend)

@Mastermindzh, what do you actually use as the Rescrobbled player-whitelist value to target Tidal-hifi? Using playerctl --list-all I get something like chromium.instance2168528 for Tidal-hifi, but the numbers change every time it's restarted, so it's not a long term solution.

In case anyone else stumbles across this and is looking for an answer, you can use this to whitelist tidal-hifi in Rescrobbled:

player-whitelist = [ "chromium" ]

It will pick up other chromium apps if you're using any. But it's good enough for me :)

I came across this issue and just wanted to report that I was able to connect to Last.fm. The external window maybe did not render correctly (maybe wayland issue?), but I run the application with tidal-hifi --no-sandbox for the first time to log in and since then the scobbling works just fine. If others will confirm this, maybe we can update the readme.

Can confirm! Running it once with --no-sandbox to log in also solved this issue for me. The external window rendered correctly for me on Xorg.

I was also just able to set it up with --no-sandbox. This is great, because the MPRIS integration sometimes did not refresh the song that was currently playing, and rescrobbled ended up with multiple scrobbles of the previous song.