]> kaliko git repositories - mpd-sima.git/blobdiff - sima/lib/simafm.py
Improved ETag support, add some stats
[mpd-sima.git] / sima / lib / simafm.py
index 5dafd2ce007890d576160b5fd7af63cdd600787c..cc70cf7bcac4d0989dbb992425be4c6c37ccc1f2 100644 (file)
@@ -25,7 +25,7 @@ __version__ = '0.5.1'
 __author__ = 'Jack Kaliko'
 
 
-from datetime import datetime, timedelta
+from datetime import timedelta
 
 from requests import Session, Request, Timeout, ConnectionError
 
@@ -120,7 +120,9 @@ class SimaFM:
         payload.update(results=100)
         if method == 'track':
             payload.update(track=track)
-        return payload
+        # > hashing the URL into a cache key
+        # return a sorted list of 2-tuple to have consistent cache
+        return sorted(payload.items(), key=lambda param: param[0])
 
     def get_similar(self, artist=None):
         """Fetch similar artists