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

PlayHistory returns FullTrack despite Spotify documentation #139

Merged
merged 2 commits into from
Oct 17, 2020

Conversation

aramperes
Copy link
Contributor

Despite what the Spotify documentation specifies, the play history object has a FullTrack track field. This can be seen by using the endpoint and noticing that all fields are returned in the track object (notice the album, popularity, and other fields):

{
  "items": [
    {
      "track": {
        "album": {
          "album_type": "album",
          "artists": [
            {
              "external_urls": {
                "spotify": "https://open.spotify.com/artist/0DtXHIvJ8NWBg5pGvsgWnR"
              },
              "href": "https://api.spotify.com/v1/artists/0DtXHIvJ8NWBg5pGvsgWnR",
              "id": "0DtXHIvJ8NWBg5pGvsgWnR",
              "name": "Leikeli47",
              "type": "artist",
              "uri": "spotify:artist:0DtXHIvJ8NWBg5pGvsgWnR"
            }
          ],
          "available_markets": [
            "..."
          ],
          "external_urls": {
            "spotify": "https://open.spotify.com/album/1VAZdFNZ1t5BYugJ3NfaZh"
          },
          "href": "https://api.spotify.com/v1/albums/1VAZdFNZ1t5BYugJ3NfaZh",
          "id": "1VAZdFNZ1t5BYugJ3NfaZh",
          "images": [
            {
              "height": 640,
              "url": "https://i.scdn.co/image/ab67616d0000b273ba578345104c3175c5b97625",
              "width": 640
            },
            {
              "height": 300,
              "url": "https://i.scdn.co/image/ab67616d00001e02ba578345104c3175c5b97625",
              "width": 300
            },
            {
              "height": 64,
              "url": "https://i.scdn.co/image/ab67616d00004851ba578345104c3175c5b97625",
              "width": 64
            }
          ],
          "name": "Wash & Set",
          "release_date": "2017-09-08",
          "release_date_precision": "day",
          "total_tracks": 14,
          "type": "album",
          "uri": "spotify:album:1VAZdFNZ1t5BYugJ3NfaZh"
        },
        "artists": [
          {
            "external_urls": {
              "spotify": "https://open.spotify.com/artist/0DtXHIvJ8NWBg5pGvsgWnR"
            },
            "href": "https://api.spotify.com/v1/artists/0DtXHIvJ8NWBg5pGvsgWnR",
            "id": "0DtXHIvJ8NWBg5pGvsgWnR",
            "name": "Leikeli47",
            "type": "artist",
            "uri": "spotify:artist:0DtXHIvJ8NWBg5pGvsgWnR"
          }
        ],
        "available_markets": [
          "..."
        ],
        "disc_number": 1,
        "duration_ms": 218040,
        "explicit": true,
        "external_ids": {
          "isrc": "USRC11701108"
        },
        "external_urls": {
          "spotify": "https://open.spotify.com/track/6r60QMPjupH9mfPRBw1jva"
        },
        "href": "https://api.spotify.com/v1/tracks/6r60QMPjupH9mfPRBw1jva",
        "id": "6r60QMPjupH9mfPRBw1jva",
        "is_local": false,
        "name": "O.M.C.",
        "popularity": 30,
        "preview_url": "https://p.scdn.co/mp3-preview/434b7014f009a3a53fdb16daf9ca047d2d853df5?cid=774b29d4f13844c495f206cafdad9c86",
        "track_number": 5,
        "type": "track",
        "uri": "spotify:track:6r60QMPjupH9mfPRBw1jva"
      },
      "played_at": "2020-10-15T21:15:04.622Z",
      "context": null
    }
  ],
  "next": "https://api.spotify.com/v1/me/player/recently-played?before=1602796504622&limit=1",
  "cursors": {
    "after": "1602796504622",
    "before": "1602796504622"
  },
  "limit": 1,
  "href": "https://api.spotify.com/v1/me/player/recently-played?limit=1"
}

@ramsayleung
Copy link
Owner

Yep, thanks for your heads-up, it's a good job to correct the wrong type.

Have you test the endpoint current_user_recently_played after replacing SimplifiedTrack with FullTrack, which should run correctly.

Perhaps we should open an issue for Spotify Web API to notify them that the Spotify documentation is a little bit misleading.

@aramperes
Copy link
Contributor Author

aramperes commented Oct 17, 2020

Yup I tested the change by pointing rspotify to my branch and printing the output of the current_user_recently_played. The PlayHistory model isn't used anywhere else too.

It's a bit hard to contact Spotify these days since they archived the web-api GitHub, and they aren't super responsive on the new forums. Worth a try nonetheless.

I figure they use the full track object here because album is generally already available in endpoints where they use the simplified track (e.g. getting a list of tracks for an album). In current_user_recently_played and current_user_playing_track, it makes sense for it to be a full track.

@ramsayleung
Copy link
Owner

Would you like to update the CHANGELOG.md file, this PR actually is a breaking change.

@ramsayleung
Copy link
Owner

ramsayleung commented Oct 17, 2020

Merged :)

@ramsayleung ramsayleung merged commit edcf26e into ramsayleung:master Oct 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants