Skip to content
This repository has been archived by the owner on Jun 15, 2022. It is now read-only.

TypeError: int() not supported on cdata 'sp_track *' #128

Closed
dojohnso opened this issue Apr 24, 2014 · 12 comments
Closed

TypeError: int() not supported on cdata 'sp_track *' #128

dojohnso opened this issue Apr 24, 2014 · 12 comments
Assignees
Labels
Milestone

Comments

@dojohnso
Copy link

When I do

track = spotify.Track(spotify_uri)
playlist.remove_tracks(track)

I get the mentioned error in the title. I've verified that track is a valid Track object

Full trace:

Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/flask/app.py", line 1518, in __call__
    return self.wsgi_app(environ, start_response)
  File "/Library/Python/2.7/site-packages/flask/app.py", line 1506, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "/Library/Python/2.7/site-packages/flask/app.py", line 1504, in wsgi_app
    response = self.full_dispatch_request()
  File "/Library/Python/2.7/site-packages/flask/app.py", line 1264, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/Library/Python/2.7/site-packages/flask/app.py", line 1262, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Library/Python/2.7/site-packages/flask/app.py", line 1248, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/Users/dojohnso/dougsvn/internal-tools/trunk/web/sonos/index.py", line 76, in remove_track
    removed = playlist.remove_tracks(track)
  File "/Library/Python/2.7/site-packages/spotify/playlist.py", line 251, in remove_tracks
    self._sp_playlist, [t._sp_track for t in tracks], len(tracks)))
  File "/Library/Python/2.7/site-packages/spotify/__init__.py", line 44, in wrapper
    return f(*args, **kwargs)
TypeError: int() not supported on cdata 'sp_track *'
@jodal jodal added 2.x labels Apr 24, 2014
@jodal jodal self-assigned this Apr 24, 2014
@jodal jodal added this to the v2.0.0b2 milestone Apr 24, 2014
@jodal
Copy link
Owner

jodal commented Apr 24, 2014

Do you get the same error if you upgrade to pyspotify 2.0.0b1 released yesterday? There's some API changes, but porting from 2.0.0a1 to 2.0.0b1 should be quick.

@jodal
Copy link
Owner

jodal commented Apr 24, 2014

Yes, it is... working on a fix.

@jodal jodal closed this as completed in ee9a43d Apr 24, 2014
@jodal
Copy link
Owner

jodal commented Apr 24, 2014

Fix committed. I'll release this to PyPI in a couple of days, in case more bugs are discovered now right after the 2.0.0b1 release.

@dojohnso
Copy link
Author

thanks! so can I use track.index for the position?

@jodal
Copy link
Owner

jodal commented Apr 24, 2014

Ah, no, track.index is the track's index in the album it belongs to. You're looking for the track's position in the playlist you're removing it from.

If you want to find the first instance of a track in the playlist, you can use playlist.index(track), just like with any other Python list. Note that if you have the same track repeatedly in the same playlist, this will just return the position of the first one.

@dojohnso
Copy link
Author

Ah makes sense. That is great, thank you!

@dojohnso
Copy link
Author

Ok, maybe... let me know if there is somewhere else you'd like me to ask this:

When I do playlist.tracks, I get the list, like this:

>>> playlist.tracks
_Tracks([Track(u'spotify:track:4HcgoL4KNExj5LgmmFCj0D'),
Track(u'spotify:track:1595LW73XBxkRk2ciQOHfr'),
Track(u'spotify:track:7ueP5u2qkdZbIPN2YA6LR0'),
Track(u'spotify:track:4j4pPKE3xAblPIbhxScC1j'),
Track(u'spotify:track:6MdqqkQ8sSC0WB4i8PyRuQ'),
Track(u'spotify:track:6u47WBqEuowycc48t2Wekx'),
Track(u'spotify:track:2raJLzvNRvipP8cJuchk6U'),
.....
Track(u'spotify:track:3zniSx8DVtUSuJ0WAToZUy'),
Track(u'spotify:track:0k1xMUwn9sb7bZiqdT9ygx'),
Track(u'spotify:track:2v8X6L6j0kbUPXDZwtXvXU')])

with my loaded track
>>> track
Track(u'spotify:track:2raJLzvNRvipP8cJuchk6U')

when I playlist.index(track) I get AttributeError: 'Playlist' object has no attribute 'index'. If I try playlist.tracks.index(track), I get the following:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/_abcoll.py", line 604, in index
    raise ValueError
ValueError

But if i visually search for the track object in the list, it is there in my output.

Thoughts?

@jodal
Copy link
Owner

jodal commented Apr 24, 2014

I know what the problem is. Will fix tomorrow :-)

Stein Magnus Jodal
On Apr 24, 2014 9:53 PM, "Doug" notifications@github.com wrote:

Ok, maybe... let me know if there is somewhere else you'd like me to ask
this:

When I do playlist.tracks, I get the list, like this:

playlist.tracks
_Tracks([Track(u'spotify:track:4HcgoL4KNExj5LgmmFCj0D'),
Track(u'spotify:track:1595LW73XBxkRk2ciQOHfr'),
Track(u'spotify:track:7ueP5u2qkdZbIPN2YA6LR0'),
Track(u'spotify:track:4j4pPKE3xAblPIbhxScC1j'),
Track(u'spotify:track:6MdqqkQ8sSC0WB4i8PyRuQ'),
Track(u'spotify:track:6u47WBqEuowycc48t2Wekx'),
Track(u'spotify:track:2raJLzvNRvipP8cJuchk6U'),
.....
Track(u'spotify:track:3zniSx8DVtUSuJ0WAToZUy'),
Track(u'spotify:track:0k1xMUwn9sb7bZiqdT9ygx'),
Track(u'spotify:track:2v8X6L6j0kbUPXDZwtXvXU')])

with my loaded track

track
Track(u'spotify:track:2raJLzvNRvipP8cJuchk6U')

when I playlist.index(track) I get AttributeError: 'Playlist' object has
no attribute 'index'. If I try playlist.tracks.index(track), I get the
following:

Traceback (most recent call last):
File "", line 1, in
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/_abcoll.py", line 604, in index
raise ValueError
ValueError

But if i visually search for the track object in the list, it is there in
my output.

Thoughts?


Reply to this email directly or view it on GitHubhttps://github.com//issues/128#issuecomment-41324161
.

@jodal jodal reopened this Apr 25, 2014
@jodal jodal closed this as completed in d98dcf5 Apr 25, 2014
@dojohnso
Copy link
Author

Hi @jodal, just had a chance to try this again. I am seeing the same results. Any ideas on what exactly I should do to get the track's position?

@jodal
Copy link
Owner

jodal commented Apr 29, 2014

Are you sure you updated your git clone first? It seems to work for me:

>>> pl = session.playlist_container[0]
>>> pl
Playlist(u'spotify:user:jodal:playlist:6Z6kOmdDygGJLaxcQyc4LA')
>>> pl.tracks
_Tracks([Track(u'spotify:track:4irirDseOIr6JChffMsqKr'),
 Track(u'spotify:track:4DPCc9KmNCOVFigrMoCYxe'),
 Track(u'spotify:track:3G9RHExOlulJtarVW2SilB'),
 Track(u'spotify:track:5qleAb28e763MhBSblRHEj'),
 Track(u'spotify:track:2PgnmyrMz2R35ePgyHjlJy'),
 Track(u'spotify:track:1HvC7KoIL7nrNzu8AMRMua'),
 Track(u'spotify:track:6IdWcwCmPlNVEMoSN7G3EZ'),
 Track(u'spotify:track:4AZAeQMDv7yoELcGaRGaIc'),
 Track(u'spotify:track:3XEShzCXKzS0J5zjCG3Gyf'),
 Track(u'spotify:track:11nPqPZKAJ3meQI7jsWleL'),
 Track(u'spotify:track:6lLLu3470SsUcrqt3Ryp5y'),
 Track(u'spotify:track:4tSoKbLjO7rdy4bdPUxbop')])
>>> t = pl.tracks[7]
>>> pl.tracks.index(t)
7

@dojohnso
Copy link
Author

ah dur, yeah I accidentally reverted to the pip installed version. getting the track position works now! thanks!

@jodal
Copy link
Owner

jodal commented Apr 29, 2014

Great! I'll roll a new release tonight, I hope :-)

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

No branches or pull requests

2 participants