X-Git-Url: http://git.maemo.org/git/?p=jamaendo;a=blobdiff_plain;f=jamaendo%2Fapi.py;h=74c96f79037bc56e097b7034d568218fbdf62c3b;hp=d0267708fff2aa1a51c0605462965b89e72e0d51;hb=44b759cfcfb80d94ddac5ea11302a6f94cb307b4;hpb=d2b935f99c20e44a06663f0bf2c696b2ff911582 diff --git a/jamaendo/api.py b/jamaendo/api.py index d026770..74c96f7 100644 --- a/jamaendo/api.py +++ b/jamaendo/api.py @@ -35,7 +35,7 @@ _COVERDIR = None _GET2 = '''http://api.jamendo.com/get2/''' _MP3URL = _GET2+'stream/track/redirect/?id=%d&streamencoding=mp31' _OGGURL = _GET2+'stream/track/redirect/?id=%d&streamencoding=ogg2' - +_TORRENTURL = _GET2+'bittorrent/file/redirect/?album_id=%d&type=archive&class=mp32' def set_cache_dir(cachedir): global _CACHEDIR @@ -137,6 +137,10 @@ class Album(LazyQuery): if json: self.set_from_json(json) + def torrent_url(self): + return _TORRENTURL%(self.ID) + + def _needs_load(self): return self._needs_load_impl('name', 'image', 'artist_name', 'artist_id', 'license_url', 'tracks') @@ -261,9 +265,12 @@ class CoverFetcher(threading.Thread): self.cond.wait() self.cond.release() + multi = len(work) > 1 for albumid, size, cb in work: cover = self._fetch_cover(albumid, size) cb(albumid, size, cover) + if multi: + time.sleep(1.0) class CoverCache(object): """ @@ -303,16 +310,16 @@ class CoverCache(object): def get_async(self, albumid, size, cb): cover = self._covers.get((albumid, size), None) if cover: - cb(cover) + cb(albumid, size, cover) else: self._fetcher.request_cover(albumid, size, cb) _cover_cache = CoverCache() -def get_album_cover(albumid, size=200): +def get_album_cover(albumid, size=100): return _cover_cache.get_cover(albumid, size) -def get_album_cover_async(cb, albumid, size=200): +def get_album_cover_async(cb, albumid, size=100): _cover_cache.get_async(albumid, size, cb) class CustomQuery(Query):