crustymonkey / py-sonic

A python library to wrap the Subsonic REST API
http://stuffivelearned.org/doku.php?id=programming:python:py-sonic
GNU General Public License v3.0
56 stars 26 forks source link

'size' arguments doesn't work in getAlbumList2() #18

Closed gordielachance closed 8 years ago

gordielachance commented 8 years ago

I, my server has Subsonic 5.3 (build 4568); and I use your library (v.0.5.1) through an addon for Kodi that I forked.

It seems that the argument 'size' in the function getAlbumList2 doesn't limit the list size :

        q = self._getQueryDict({'type': ltype, 'size': size,
            'offset': offset, 'fromYear': fromYear, 'toYear': toYear,
            'genre': genre})

Even if I hardcode it, the list returns ALL my albums; which makes my addon quite slow.

q = self._getQueryDict({'type': ltype, 'size': 5})

Do you know what may cause this and is there a way to fix it ?

Thanks !

crustymonkey commented 8 years ago

I've got some other work to do on the library. I'm hoping to tackle a lot of this (including this one) this weekend. Thanks for the bug report!

crustymonkey commented 8 years ago

I had some time and took a look at this tonight. I can't reproduce the behavior. I'm running subsonic 6.0, but I also don't see anything in the changelog about a bug fix for this version and the size spec.

This is with the latest from master, but I haven't made any changes to this code path between 0.5.1 and 0.6.0. If you want to set me up with a limited account on your subsonic server (provided there is access from the internet), I could try and repro against your server. Then I could step through and at least see what is going on.

In [2]: c.getAlbumList2('newest', 1)
Out[2]: 
{u'albumList2': {u'album': [{u'artist': u'Rob Zombie',
    u'artistId': u'11640',
    u'coverArt': u'al-28485',
    u'created': u'2016-09-21T21:57:58.000Z',
    u'duration': 1883,
    u'genre': u'Hard Rock',
    u'id': u'28485',
    u'name': u'The Electric Warlock Acid Witch Satanic Orgy Celebration Dispenser',
    u'playCount': 0,
    u'songCount': 12,
    u'year': 2016}]},
 u'status': u'ok',
 u'version': u'1.14.0'}

In [3]: c.getAlbumList2('newest', 2)
Out[3]: 
{u'albumList2': {u'album': [{u'artist': u'Rob Zombie',
    u'artistId': u'11640',
    u'coverArt': u'al-28485',
    u'created': u'2016-09-21T21:57:58.000Z',
    u'duration': 1883,
    u'genre': u'Hard Rock',
    u'id': u'28485',
    u'name': u'The Electric Warlock Acid Witch Satanic Orgy Celebration Dispenser',
    u'playCount': 0,
    u'songCount': 12,
    u'year': 2016},
   {u'artist': u'Beck',
    u'artistId': u'9524',
    u'coverArt': u'al-28484',
    u'created': u'2016-09-21T21:56:40.000Z',
    u'duration': 2813,
    u'genre': u'Alternative Rock',
    u'id': u'28484',
    u'name': u'Mellow Gold [Explicit]',
    u'playCount': 0,
    u'songCount': 13,
    u'year': 2004}]},
 u'status': u'ok',
 u'version': u'1.14.0'}
gordielachance commented 8 years ago

This is weird.
Actually, I cannot give you access to the Subsonic as it does not belong to me so i'm not able to create accounts. :/ I don't understand what's going on. They say that getAlbumList2() is supported since REST API version 1.8.0 (Subsonic 4.7); so I guess I should not have problems with it in Subsonic 5.3... In case you want to have a look, here's my code : plugin.audio.subsonic.

crustymonkey commented 8 years ago

Hmm, I can't repro this at all. However, in the walk_albums() code you are are returning an iterator that will walk the entire library, not just return the individual size subset. If you are calling walk_albums() and expecting only a subset to be returned, that's not going to happen as the only loop breaking condition there is an empty response (hitting the end of the list of albums).

gordielachance commented 8 years ago

Hi crustymonkey ! Of course you were right... I remove the loop and it's working now ! Thanks a LOT for your help.