- q = SearchQuery('track', order='ratingweek_desc')
- a = q.execute()
- if not a:
- raise JamendoAPIException(str(q))
- _update_cache(_tracks, a)
- return a
+ with _APILOCK:
+ q = SearchQuery('track', order='ratingweek_desc')
+ a = q.execute()
+ if not a:
+ raise JamendoAPIException(str(q))
+ _update_cache(_tracks, a)
+ return a
+
+def top_artists(order='rating_desc', count=20):
+ """Returns: [Artist]"""
+ with _APILOCK:
+ q = SearchQuery('artist', order=order, count=count)
+ a = q.execute()
+ if not a:
+ raise JamendoAPIException(str(q))
+ _update_cache(_artists, a)
+ return a
+
+def top_albums(order='rating_desc', count=20):
+ """Returns: [Album]"""
+ with _APILOCK:
+ q = SearchQuery('album', order=order, count=count)
+ a = q.execute()
+ if not a:
+ raise JamendoAPIException(str(q))
+ _update_cache(_albums, a)
+ return a
+
+def top_tracks(order='rating_desc', count=20):
+ """Returns: [Track]"""
+ with _APILOCK:
+ q = SearchQuery('track', order=order, count=count)
+ a = q.execute()
+ if not a:
+ raise JamendoAPIException(str(q))
+ _update_cache(_tracks, a)
+ return a