diff -Nru rhythmbox-scope-0.1/debian/bzr-builder.manifest rhythmbox-scope-0.1/debian/bzr-builder.manifest --- rhythmbox-scope-0.1/debian/bzr-builder.manifest 2011-12-27 15:49:28.000000000 +0000 +++ rhythmbox-scope-0.1/debian/bzr-builder.manifest 2012-01-28 08:55:15.000000000 +0000 @@ -1,2 +1,2 @@ -# bzr-builder format 0.3 deb-version {debupstream}-0~11 -lp:~markjtully/+junk/rhythmbox-scope revid:markjtully@gmail.com-20111227141250-0fdo7w8q370a77lg +# bzr-builder format 0.3 deb-version {debupstream}-0~12 +lp:~markjtully/+junk/rhythmbox-scope revid:markjtully@gmail.com-20120127200843-w2kvq6rv6scfka18 diff -Nru rhythmbox-scope-0.1/debian/changelog rhythmbox-scope-0.1/debian/changelog --- rhythmbox-scope-0.1/debian/changelog 2011-12-27 15:49:28.000000000 +0000 +++ rhythmbox-scope-0.1/debian/changelog 2012-01-28 08:55:15.000000000 +0000 @@ -1,8 +1,8 @@ -rhythmbox-scope (0.1-0~11~oneiric1) oneiric; urgency=low +rhythmbox-scope (0.1-0~12~oneiric1) oneiric; urgency=low * Auto build. - -- Teester Tue, 27 Dec 2011 15:49:28 +0000 + -- Teester Sat, 28 Jan 2012 08:55:15 +0000 rhythmbox-scope (0.1) oneiric; urgency=low diff -Nru rhythmbox-scope-0.1/rhythmbox-scope rhythmbox-scope-0.1/rhythmbox-scope --- rhythmbox-scope-0.1/rhythmbox-scope 2011-12-27 15:49:27.000000000 +0000 +++ rhythmbox-scope-0.1/rhythmbox-scope 2012-01-28 08:55:15.000000000 +0000 @@ -13,7 +13,7 @@ import dbus, webbrowser import os, urlparse -MAX = 25 +MAX = 100 # # The primary bus name we grab *must* match what we specify in our .lens file @@ -32,6 +32,7 @@ # Listen for changes and requests self.scope.search_in_global = False + self.scope.connect ("notify::active", self.on_search_changed) self.scope.connect ("notify::active-search", self.on_search_changed) self.scope.connect ("notify::active-global-search", self.on_global_search_changed) self.scope.connect ("filters-changed", self.on_search_changed) @@ -44,7 +45,7 @@ rhythmbox_dbFile = os.getenv("HOME") + "/.local/share/rhythmbox/rhythmdb.xml" artdir = os.getenv("HOME") + "/.cache/rhythmbox/covers" - keys = set(("title", "artist", "album", "track-number", "location", "mimetype", "album-artist", "genre", "date")) + keys = set(("title", "artist", "album", "track-number", "location", "mimetype", "album-artist", "genre", "date", "track-number")) tracks = [] strmap = {} @@ -80,7 +81,10 @@ track[7] = int(info["date"])/365 else: track[7] = 0 - + if info.has_key('track-number'): + track[8] = info['track-number'] + else: + track[8] = 0 tracks.append(track) entry.clear() @@ -89,8 +93,49 @@ return tracks def getAlbumArt(self, track): + # First, try "/.cache/rhythmbox/covers" artdir = os.getenv("HOME") + "/.cache/rhythmbox/covers" - return "%s/%s - %s.jpg" % (artdir, track[2], track[3]) + if os.path.exists(artdir + track[2] + " - " + track[3]): + return "%s/%s - %s.jpg" % (artdir, track[2], track[3]) + + #print "Not in /.cache/rhythmbox/covers" + + # If that didn't work, try "/.cache/media-art" + artdir = os.getenv("HOME") + "/.cache/media-art" + import unicodedata + import hashlib + + hashname = unicode(track[5]) + hashname2 = unicode(track[3]) + hashname = unicodedata.normalize("NFKD", hashname) + hashname2 = unicodedata.normalize("NFKD", hashname2) + md5album = hashlib.md5() + md5album2 = hashlib.md5() + try: + md5album.update(hashname) + md5album2.update(hashname2) + value = md5album.hexdigest() + "-" + md5album2.hexdigest() + except: + value = "" + + if os.path.exists(artdir + "/album-" + value + ".jpeg"): + return "%s/album-%s.jpeg" % (artdir, value) + + hashname = unicode(track[5] + "\t" + track[3]) + hashname = unicodedata.normalize("NFKD", hashname) + md5album = hashlib.md5() + try: + md5album.update(hashname) + value = md5album.hexdigest() + except: + value = "" + + if os.path.exists(artdir + "/album-" + value + ".jpg"): + return "%s/album-%s.jpg" % (artdir, value) + + #print "not in /.cache/media-art/" + + return "" def _lookup_string(self, string, strmap): """Look up @string in the string map, @@ -148,6 +193,7 @@ def update_results_model (self, search, model): model.clear () + self.getMusicFromRhythmbox() # Available filters are: decade & genre f = self.scope.get_filter("decade") firstdecadefilter = "" @@ -176,11 +222,13 @@ artist = "" if track[2] is None else track[2] album = "" if track[3] is None else track[3] mimetype = "" if track[4] is None else track[4] + albumartist = "" if track[5] is None else track[5] itemtype = "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Audio" trackname = title + " - " + album + " - " + artist if not trackname.lower().find(search.lower()) == -1: if self.i < MAX: albumart = self.getAlbumArt(track) + albumuri = "album://" + albumartist + "/" + album # If the album is between the decdes filtered, include. if int(track[7]) >= firstdecadefilter and int(track[7]) <= lastdecadefilter: @@ -212,15 +260,16 @@ title, # display name artist + "\n" + album, # comment uri) # dnduri - + print uri if album not in albums: - model.append (uri, # uri + model.append (albumuri, # uri albumart, # string formatted GIcon ALBUMS, # numeric group id mimetype, # mimetype album, # display name artist + "\n" + album, # comment uri) # dnduri + print albumuri if album != None: albums.append(album) @@ -231,19 +280,44 @@ import subprocess print uri albumtracks = [] - albumtracks.append("rhythmbox-client") - albumtracks.append("--enqueue") + # Stupid hacks are required because of the removal of rhythmbox-client in oneiric + # and rhythmbox does not have an enqueue command line function + albumtracks.append("rhythmbox") + + # This would be what to do if rhythmbox-client was around + #albumtracks.append("rhythmbox-client") + #albumtracks.append("--enqueue") + # If uri starts with album:// then we need to play all the songs on it - if not uri.startswith("album://") == -1: + if uri.startswith("album://"): + trackdetails = [] for track in self.tracks: + trackdetail = [] album = "album://" + track[5] + "/" + track[3] if not album.find(uri) == -1: - albumtrack = "file://" + track[1] - albumtracks.append(albumtrack) + albumtrack = track[1] + trackdetail.append(albumtrack) + trackdetail.append(track[8]) + trackdetails.append(trackdetail) + + # Pass the first track of the album and hope that the + # rhythmbox library is sorted by album + trackdetails.sort(key=lambda track: int(track[1])) + track = trackdetails[0] + albumtracks.append(track[0]) + + # This would be what to do if rhythmbox-client was around + #for track in trackdetails: + # print track + # if int(track[1]) == 1: + # albumtracks.append(track[0]) + subprocess.Popen(albumtracks) + else: - albumtracks.append("file://" + uri) + albumtracks.append(uri) subprocess.Popen(albumtracks) + return Unity.ActivationResponse (handled = Unity.HandledType.HIDE_DASH, goto_uri = '') if __name__ == "__main__":