zmb3 / spotify

A Go wrapper for the Spotify Web API
Apache License 2.0
1.38k stars 291 forks source link

Timestamp parsing of analysis meta fails #124

Closed qnten closed 4 years ago

qnten commented 4 years ago

The type of the Timestamp value in the audio-analysis endpoint reponse changed from int to string. Thereby the json parsing in the following line is failing with the error message json: cannot unmarshal string into Go struct field AnalysisMeta.meta.timestamp of type int64. https://github.com/zmb3/spotify/blob/5fe5f9535a2c486f0e57ddd88bb703e297329edb/audio_analysis.go#L34

Response from https://api.spotify.com/v1/audio-analysis/{id}:

{
  "meta": {
    "analyzer_version": "4.0.0",
    "platform": "Linux",
    "detailed_status": "OK",
    "status_code": 0,
    "timestamp": "1456010389",
    "analysis_time": 9.1394,
    "input_process": "libvorbisfile L+R 44100->22050"
  },

Because this change is nowhere documented im unsure if this will be reverted. Should the library support both cases?

zmb3 commented 4 years ago

Might make sense to file an issue with Spotify to see if this is intentional and something we should support.

qnten commented 4 years ago

There is an issue that reports problems with the audio analysis endpoint in general: https://github.com/spotify/web-api/issues/1555. Other libaries are also reporting the same deserialization problems: https://github.com/ramsayleung/rspotify/pull/94. But no reponse from Spotify yet.

zmb3 commented 4 years ago

@qnten looks like the issue upstream has been resolved. Is this still a problem or are the timestamps numbers again?

qnten commented 4 years ago

Yes, it was a bug and the issue has been resolved!