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

Last.fm API no longer returning now playing track for user.getRecentTracks #78

Open
rikkit opened this issue Sep 1, 2015 · 8 comments

Comments

@rikkit
Copy link
Member

rikkit commented Sep 1, 2015

Integration test TrackUpdateNowPlayingCommandTests.UpdatesNowPlaying is failing.

API takes a parameter called page. Behaviour of API used to be that when page=1, the response would be the same as page=0 prepended with the "now playing" track.

For page=0, the API now responds with:

{"error":6,"message":"page param out of bounds (1-1000000)","links":[]}

And page=1 does not contain the "now playing" track.

@rikkit
Copy link
Member Author

rikkit commented Sep 1, 2015

Need to investigate alternatives for this

rikkit added a commit that referenced this issue Sep 1, 2015
API seems to have changed behaviour
- page=1 no longer contains "now playing" track as its first item
- page=0 no longer returns same as page=1 but without the "now playing" track
See #78
rikkit added a commit that referenced this issue Sep 1, 2015
API seems to have changed behaviour
- page=1 no longer contains "now playing" track as its first item
- page=0 no longer returns same as page=1 but without the "now playing" track
See #78
@klinge
Copy link
Contributor

klinge commented Dec 30, 2018

According to last.fm api pages "now playing" is now showed by passing a parameter in the call to GetRecentTracks.

Get a list of the recent tracks listened to by this user. Also includes the currently playing track with the nowplaying="true" attribute if the user is currently listening.

I'll add support for this.

@klinge
Copy link
Contributor

klinge commented Jan 7, 2019

I did some testing of the Last.fm api for this. It seems that the "now playing" track is always returned regardless of if you send the nowplaying="true" parameter to the api or not. Example on return dataset from calling the User.getRecentTracks without adding the nowplaying parameter:

{
    "recenttracks": {
        "track": [
            {
                "artist": {
                    "#text": "NRBQ",
                    "mbid": "4777dc1b-2533-4189-9062-c1b2b477d5c5"
                },
                "name": "Magnet",
                "streamable": "0",
                "mbid": "343153c0-a37f-4e67-a37e-2d342ddb8f1c",
                "album": {
                    "#text": "Scraps",
                    "mbid": "bc2537dd-af30-31d5-a28b-59ed0fc24fb5"
                },
                "url": "https://www.last.fm/music/NRBQ/_/Magnet",
                "image": [
                    {
                        "#text": "https://lastfm-img2.akamaized.net/i/u/34s/20712fa872a14e87af90d46269593d34.png",
                        "size": "small"
                    },
                    {
                        "#text": "https://lastfm-img2.akamaized.net/i/u/64s/20712fa872a14e87af90d46269593d34.png",
                        "size": "medium"
                    },
                    {
                        "#text": "https://lastfm-img2.akamaized.net/i/u/174s/20712fa872a14e87af90d46269593d34.png",
                        "size": "large"
                    },
                    {
                        "#text": "https://lastfm-img2.akamaized.net/i/u/300x300/20712fa872a14e87af90d46269593d34.png",
                        "size": "extralarge"
                    }
                ],
                "@attr": {
                    "nowplaying": "true"
                }
            },

So the "now playing" track is returned. There is a value in the @attr for marking that it is the now playing song.

I made a unit test to check that the existing code handles this response correctly. It does. Will make a PR with the unit test. With the current behaviour of the last.fm api I think this issue can be closed.

@rikkit
Copy link
Member Author

rikkit commented Jan 7, 2019

Thanks for looking into this @klinge - I think this behaviour has changed a bit over the last few months, so it might be worth adding an integration test? One that'll fail if the API behaviour changes.

@klinge
Copy link
Contributor

klinge commented Jan 7, 2019

Integration testing would sort of require that you had a user that you knew always had a song playing. Otherwise you will not get the "nowplaying" attribute. The "RJ" user does not have that. If you can think of a good way to do an integration test I'd be happy to implement it :)

@rikkit
Copy link
Member Author

rikkit commented Jan 7, 2019

I just realised that the integration test for track.updateNowPlaying (what this issue is about) is exactly the same test as I'm suggesting you write - so no extra test needed :)

For future ref though, the base class for the integration tests authenticates with the user inflatabledemo - you can use that account to test stuff like this.

@klinge
Copy link
Contributor

klinge commented Jan 7, 2019

Never used or looked at the scrobble functions in the library. Will have to do that sometime.. :) Should I still make a PR for the added unit test I made for the "nowplaying" attribute in the user.getrecenttracks command? (it's just one added test and a json resource file.. )

@fuuman
Copy link

fuuman commented Feb 22, 2021

I can reproduce the response from the original post.

I want to receive the currently playing song. But recent tracks doesn't deliver that, Page 0 is out of bounds. Page 1 doesn't contain it.

Is there any endpoint that provides me the currently played track?

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

No branches or pull requests

3 participants