Hexxeh / spotify-websocket-api

Spotify Websocket API is a fully open source Spotify library based on the WebSocket API used in the Spotify Web beta
395 stars 67 forks source link

Track error (again) #48

Open ivars777 opened 10 years ago

ivars777 commented 10 years ago

When trying to get track url, "Track error" is returned (search etc. functions work). Track is playable in browser and desktop client. What is the reason (may be it is connected with depreciation of API v0.x on December 17, see http://devnews.spotify.com/2013/12/17/deprecation-of-spotify-apps-api-0-x/)?

Python 2.7 (32), Windows 8 (64), last version of module from git. Test script:

from spotify_web.spotify import SpotifyAPI, SpotifyUtil, Logging
import sys

Logging.log_level=3
sp = SpotifyAPI()
sp.connect(sys.argv[1], sys.argv[2])
uri = "spotify:track:0dEIca2nhcxDUV8C5QkPYb"
track = sp.metadata_request(uri)
print track.artist[0].name + " - " + track.name

url = sp.track_uri(track)
print url

Result:

[NOTICE] Connecting to wss://lon2-linkap-a2.ap.spotify.com/
[NOTICE] Logging in
[DEBUG] sent {"args":["201","ba30f56ee228847cf4c5be0b5b489aabbb1e1826","{\"ip\":\"212.93.100.58\",\"timestamp\":1388449746,\"ttl\":900,\"useragent\":\"node-spotify-web in python (Chrome\\/13.37 compatible-ish)\",\"version\":62300110,\"token\":\"NApfCkcKDVNwb3RpZnktdXNlcnMSCGl2YXJzNzc3GgOYAQElVhPCUjIiCgikFh6yf9gj8hIW3y6eKvqboXhSjzYpgMCX9NgnsgJ1txIUVKzwgXZEGWrUTWAkuHxEHk6mJJ4\"}"],"name":"connect","id":"0"}
[DEBUG] recv {"id":0,"result":"ok"}
[DEBUG] sent {"args":[],"name":"sp/user_info","id":"1"}
[DEBUG] recv {"message":["do_work","var t2=5; try{ for(var i=0; i<720094129..toString(32<<0).length;i++) t2 = t2+29627..toString(32<<0).length;}catch(_) {}; this.reply('' + t2);"]}
[DEBUG] Got do_work message, payload: var t2=5; try{ for(var i=0; i<720094129..toString(32<<0).length;i++) t2 = t2+29627..toString(32<<0).length;}catch(_) {}; this.reply('' + t2);
[DEBUG] sent {"args":["v1"],"name":"sp/work_done","id":"2"}
[DEBUG] recv {"message":["login_complete"]}
[DEBUG] recv {"id":1,"result":{"ab_collection_union":"0","ab_test_group":"698","ads":"0","app_developer":"0","catalogue":"premium","country":"LV","head_files":"0","head_files_url":"http://heads.spotify.com/head/{file_id}","lastfm_session":"","license_agreements":"0.8.8-LV","link_tutorial_completed":"1","post_open_graph":"-2","preferred_locale":"en","product":"premium","public_toplist":"3","publish_activity":"0","publish_playlist":"0","user":"ivars777","wanted_licenses":"0.8.8-LV"}}
[DEBUG] sent {"args":"h","name":"sp/echo","id":"3"}
[DEBUG] recv {"id":2,"result":"ok"}
[DEBUG] Got ack for message reply
[DEBUG] sent {"args":[0,"CjRobTovL21ldGFkYXRhL3RyYWNrLzA3M2NjMjE2MjY4ZjQxOWZhMjEzNjE0NGQyMGJiMGRmGgNH\nRVQ=\n"],"name":"sp/hm_b64","id":"4"}
[DEBUG] recv {"id":3,"result":""}
[DEBUG] No callback was requested for command 3, ignoring
[DEBUG] recv {"id":4,"result":["CjRobTovL21ldGFkYXRhL3RyYWNrLzA3M2NjMjE2MjY4ZjQxOWZhMjEzNjE0NGQyMGJiMGRmEhp2bmQuc3BvdGlmeS9tZXRhZGF0YS10cmFjayCQAzIYCgpNRC1WZXJzaW9uEgoxMzg4MzUzMTk4Mg8KBk1DLVRUTBIFNjY1ODcyGQoPTUMtQ2FjaGUtUG9saWN5EgZwdWJsaWMyDwoHTUMtRVRhZxIExF0lQA==","ChAHPMIWJo9Bn6ITYUTSC7DfEhdHaXZlIExpZmUgQmFjayB0byBNdXNpYxqfAgoQjxrCACoPTuSuiYHnX3cs6hIWUmFuZG9tIEFjY2VzcyBNZW1vcmllcxodChCTUmFuG2pKX76HZKFki1GsEglEYWZ0IFB1bmsqCENvbHVtYmlhMgcIuh8QChgiSh4KFFC6YywiG60XMHHeajB/ciPbl4EFEAAY2AQg1ARKHgoUFTf5Oro5W50bz1F9TqqseWbk4eQQARiAASCAAUoeChRsQYbruwuG8JiVTmUYEj/AWo7t3xACGIAKIPgJigFgCh4KFFC6YywiG60XMHHeajB/ciPbl4EFEAAY2AQg1AQKHgoUFTf5Oro5W50bz1F9TqqseWbk4eQQARiAASCAAQoeChRsQYbruwuG8JiVTmUYEj/AWo7t3xACGIAKIPgJIh0KEJNSYW4bakpfvodkoWSLUawSCURhZnQgUHVuaygCMAI45NMhQJQBUhQKBGlzcmMSDFVTUVg5MTMwMDEwMVoyCAAIAQgDGipBU0FXQVhCTEJRQlZDQ0NXQ1hHR0dTSE1JTUpFSlBNRk5GU0pTWFVNVkliGAoUK3PU0rPre5z0Q7IoBu2oHdv2cnAQAmIYChSBRb0UBOC7Z0qwJJA+/0jHaNVvNhABYhgKFE+yAn9k87zujolJ1suqpHohmImuEABiGAoU2evuTZHKZZzTUgCOdUzOjuyz+YEQBGICEAV6GAoUW9YsDJiw8BSQx9VC8ssQ1NM4llgQBg=="]}
Daft Punk - Give Life Back to Music
[NOTICE] spotify:track:dEIca2nhcxDUV8C5QkPYb is available!
[DEBUG] sent {"args":["mp3160","073cc216268f419fa2136144d20bb0df"],"name":"sp/track_uri","id":"5"}
[DEBUG] recv {"error":[12,0,""],"id":5}
[ERROR] Track error
[DEBUG] sent {"args":["mp3160","073cc216268f419fa2136144d20bb0df"],"name":"sp/track_uri","id":"6"}
[DEBUG] recv {"error":[12,0,""],"id":6}
[ERROR] Track error
[DEBUG] sent {"args":"h","name":"sp/echo","id":"7"}
[DEBUG] recv {"id":7,"result":""}
[DEBUG] No callback was requested for command 7, ignoring
[DEBUG] sent {"args":["mp3160","073cc216268f419fa2136144d20bb0df"],"name":"sp/track_uri","id":"8"}
[DEBUG] recv {"error":[12,0,""],"id":8}
[ERROR] Track error
False
richard-ive commented 10 years ago

Same issue with the higher level functions in the friendly Spotify object too.

I don't think it has anything to do with the API deprecation. This lib used the Websocket connection used by the web player.

The last fix for this issue can be found here: https://github.com/Hexxeh/spotify-websocket-api/commit/08ee32679cd874047686b211af71fee977c6a98a#diff-684a7972973ebd32bb65015e557286a2R201

I'm having a hunt, but very little luck at the moment.

richard-ive commented 10 years ago

Spotify appear to be blocking the User-Agent. About to push an update.

richard-ive commented 10 years ago

Added pull https://github.com/Hexxeh/spotify-websocket-api/pull/49