1
0
mirror of https://github.com/spl0k/supysonic.git synced 2024-12-22 17:06:17 +00:00

Fix random with no tracks

Closes #10
This commit is contained in:
spl0k 2014-02-26 22:41:59 +01:00
parent 692f7d86e3
commit dba2a9b662

View File

@ -60,6 +60,10 @@ def album_list():
if ltype == 'random':
albums = []
count = query.count()
if not count:
return request.formatter({ 'albumList': {} })
for _ in xrange(size):
x = random.choice(xrange(count))
albums.append(query.offset(x).limit(1).one())
@ -106,6 +110,10 @@ def album_list_id3():
if ltype == 'random':
albums = []
count = query.count()
if not count:
return request.formatter({ 'albumList2': {} })
for _ in xrange(size):
x = random.choice(xrange(count))
albums.append(query.offset(x).limit(1).one())