# HG changeset patch # User fabien # Date 1076127280 18000 # Node ID 76768c12aa046030d9b16e644d7c914620d334f7 # Parent d59f0f20fa8aaed0e1c646a945091168a3f3cba6 [svn] Display only distinct UID. The path selected is arbitrary, but it's always the current one if Current is pressed. diff -r d59f0f20fa8a -r 76768c12aa04 immsview --- a/immsview Fri Feb 06 20:21:32 2004 -0500 +++ b/immsview Fri Feb 06 23:14:40 2004 -0500 @@ -20,9 +20,13 @@ # Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. -_version_ = "$Id: immsview 1707 2004-02-07 01:21:32Z fabien $" +_version_ = "$Id: immsview 1708 2004-02-07 04:14:40Z fabien $" # $Log$ +# Revision 1.26 2004/02/07 04:14:40 fabien +# Display only distinct UID. The path selected is arbitrary, but +# it's always the current one if Current is pressed. +# # Revision 1.25 2004/02/07 01:21:32 fabien # Some typos... (better take a break now...) # @@ -111,6 +115,8 @@ # * IMMS: # - Add composed rating # - Rating edition +# - SID grouping +# - UID grouping!!! (yes, you can have different path with the same UID) # * XMMS: # - getting current playlist # - editing playlist @@ -227,15 +233,19 @@ # Better to fetch everything since locking can really mess # things in imms plugin. print time.ctime(time.time()) + ": mapping" - results = [] + results = {} tune = cu.fetchone() while tune: try: - tmp = {'uid' : int(tune[0]), - 'rating' : int(tune[1]), - 'path' : tune[2].decode('utf-8', 'replace'), - 'last' : int(tune[3])} - results.append(tmp) + uid = int(tune[0]) + if results.has_key(uid): + results[uid]['path'].append( + tune[2].decode('utf-8', 'replace')) + else: + results[uid] = { + 'rating' : int(tune[1]), + 'path' : [ tune[2].decode('utf-8', 'replace') ], + 'last' : int(tune[3])} except UnicodeDecodeError: print tune[2] tune = cu.fetchone() @@ -285,13 +295,21 @@ self.curtime = time.time() def default_sort(self, a, b, dummy): return 0 - def tune_to_giter(self, tune, giter = None): + def tune_to_giter(self, uid, tune, giter = None, path = None): + if path: + for fn in tune['path']: + if fn == path: + break + else: + fn = tune['path'][0] + else: + fn = tune['path'][0] if not giter: giter = self.append(None) self.set(giter, - IMMSStore.COL_UID, tune['uid'], + IMMSStore.COL_UID, uid, IMMSStore.COL_RATING, tune['rating'], - IMMSStore.COL_PATH, tune['path'], + IMMSStore.COL_PATH, fn, IMMSStore.COL_LAST, tune['last'], IMMSStore.COL_LAST_STR, strtime(self.curtime-tune['last']), IMMSStore.COL_RATING_COLOR, rating_to_color(tune['rating']), @@ -305,8 +323,8 @@ tunes = self.db.get_ratings_and_info() self.clear() print time.ctime(time.time()) + ": inserting" - for tune in tunes: - self.tune_to_giter(tune) + for uid, tune in tunes.items(): + self.tune_to_giter(uid, tune) print time.ctime(time.time()) + ": end insert" if col: self.set_sort_column_id(col, order) @@ -331,17 +349,17 @@ uid = uids[0] giter = self.find_giter_from_uid(uid) if not giter: - tunes = self.db.get_ratings_and_info(uids) - if len(tunes) > 0: - giter = self.tune_to_giter(tunes[0]) + tunes = self.db.get_ratings_and_info([uid]) + if tunes > 0: + giter = self.tune_to_giter(uid, tunes[uid], None, song) else: - giter = self.update_giter(giter) + giter = self.update_giter(giter, song) return giter - def update_giter(self, giter): + def update_giter(self, giter, path = None): uid = self.get_value(giter, IMMSStore.COL_UID) tunes = self.db.get_ratings_and_info([uid,]) if len(tunes) > 0: - return self.tune_to_giter(tunes[0], giter) + return self.tune_to_giter(uid, tunes[uid], giter, path) return giter ## def get_value(self, giter, col): ## # sniff! Can't override built-ins