def removeRBRatings(self, ratingLevel): shell = self.object db = shell.props.db #query = db.query_new() #db.query_append(query, (rhythmdb.QUERY_PROP_EQUALS, rhythmdb.PROP_RATING, float(ratingLevel))) query = GLib.PtrArray() db.query_append_params(query, RB.RhythmDBQueryType.EQUALS, RB.RhythmDBPropType.RATING, float(ratingLevel)) #db.query_append_params( query, RB.RhythmDBQueryType.EQUALS, RB.RhythmDBPropType.TITLE, 'some song name' ) query_model = RB.RhythmDBQueryModel.new_empty(db) #self.db.do_full_query_parsed(query_model, query) #db.do_full_query_parsed(query_model, (RB.RhythmDBQueryType.EQUALS, RB.RhythmDBPropType.RATING, float(ratingLevel))) db.do_full_query_parsed(query_model, query) entries = [row[0] for row in query_model] print( "Found %d entries in RhythmDB with rating level '%d' for removal:" % (len(entries), ratingLevel)) for entry in entries: #print entry #entry_title = db.entry_get_string(entry, RB.RhythmDBPropType.TITLE) entry_title = entry.get_string(RB.RhythmDBPropType.TITLE) #entry_artist = db.entry_get_string_(entry, RB.RhythmDBPropType.ARTIST) entry_artist = entry.get_string(RB.RhythmDBPropType.ARTIST) entry_rating = entry.get_double(RB.RhythmDBPropType.RATING) print("- Artist: '%s', Name: '%s', Rating: '%d'" % (entry_artist, entry_title, entry_rating)) #db.set(entry, rhythmdb.PROP_RATING, float(0)) db.entry_set(entry, RB.RhythmDBPropType.RATING, float(0)) db.commit()
def __do_query(self, params): query_model = RB.RhythmDBQueryModel.new_empty(self.db) query = GLib.PtrArray() for param in params: self.db.query_append_params(query, param[2], param[0], param[1]) self.db.do_full_query_parsed(query_model, query) return query_model
def __do_single_query(self, prop, value, query_type=RB.RhythmDBQueryType.EQUALS): query_model = RB.RhythmDBQueryModel.new_empty(self.db) query = GLib.PtrArray() self.db.query_append_params(query, query_type, prop, value) self.db.do_full_query_parsed(query_model, query) return query_model
def new_model(self): shell = self.props.shell plugin = self.props.plugin db = shell.props.db self.search_count = self.search_count + 1 q = GLib.PtrArray() db.query_append_params(q, RB.RhythmDBQueryType.EQUALS, RB.RhythmDBPropType.TYPE, plugin.entry_type) db.query_append_params(q, RB.RhythmDBQueryType.EQUALS, RB.RhythmDBPropType.LAST_SEEN, self.search_count) model = RB.RhythmDBQueryModel.new_empty(db) db.do_full_query_async_parsed(model, q) self.props.query_model = model self.songs.set_model(model)
def on_search(self, entry, text): db = self.props.shell.props.db query_model = RB.RhythmDBQueryModel.new_empty(db) query = GLib.PtrArray() db.query_append_params( query, RB.RhythmDBQueryType.FUZZY_MATCH, RB.RhythmDBPropType.COMMENT, text.lower().encode('utf8'), ) db.query_append_params( query, RB.RhythmDBQueryType.EQUALS, RB.RhythmDBPropType.GENRE, 'google-play-music', # shit! ) db.do_full_query_parsed(query_model, query) self.browser.set_model(query_model, False) self.update_view()
def find_track(self, artist, title): query_model = RB.RhythmDBQueryModel.new_empty(self.db) query = GLib.PtrArray() self.db.query_append_params(query, RB.RhythmDBQueryType.EQUALS, RB.RhythmDBPropType.ARTIST, artist) self.db.query_append_params(query, RB.RhythmDBQueryType.EQUALS, RB.RhythmDBPropType.TITLE, title) self.db.do_full_query_parsed(query_model, query) for row in query_model: if self.past_entries.count((artist, title)) > 0: continue self.shell.get_property('queue_source').add_entry(row[0], -1) self.past_entries.append((artist, title)) if len(self.past_entries) > 200: del self.past_entries[0] return True else: return False
def load_albums(self): ''' Initiates the process of recover, create and load all the albums from the Rhythmbox's db and their covers provided by artsearch plugin. Specifically, it throws the query against the RhythmDB. ''' print "CoverArtBrowser DEBUG - load_albums" # build the query q = GLib.PtrArray() self.db.query_append_params(q, RB.RhythmDBQueryType.EQUALS, RB.RhythmDBPropType.TYPE, self.db.entry_type_get_by_name('song')) # create the model and connect to the completed signal qm = RB.RhythmDBQueryModel.new_empty(self.db) qm.connect('complete', self._query_complete_callback) # throw the query self.db.do_full_query_async_parsed(qm, q) print "CoverArtBrowser DEBUG - end load_albums"
def updateRBRating(self, track): shell = self.object db = shell.props.db query = GLib.PtrArray() db.query_append_params( query, RB.RhythmDBQueryType.FUZZY_MATCH, RB.RhythmDBPropType.ARTIST_FOLDED, track['artist'] ) # use str(..) for the query value if byte literals are passed (e.g. b'foo') otherwise segmentation fault db.query_append_params(query, RB.RhythmDBQueryType.FUZZY_MATCH, RB.RhythmDBPropType.TITLE_FOLDED, track['name']) query_model = RB.RhythmDBQueryModel.new_empty(db) #print(track['artist'] ) #print(track['name'] ) #print("updateRBRating: query executing for '%s' - '%s'..." %( track['artist'], track['name'] )) db.do_full_query_parsed(query_model, query) print("updateRBRating: query finished") entries = [row[0] for row in query_model] print( "Found %d entries in RhythmDB with search for [Artist: '%s', Name: '%s']:" % (len(entries), track['artist'], track['name'])) #print("Found %d entries in RhythmDB with search for [Artist: '%s', Name: '%s']:" %(len(query_model), track['artist'], track['name'])) for treerow in query_model: entry, path = list(treerow) #print entry entry_title = entry.get_string(RB.RhythmDBPropType.TITLE) entry_artist = entry.get_string(RB.RhythmDBPropType.ARTIST) entry_rating = entry.get_double(RB.RhythmDBPropType.RATING) print( "- Give loved track 5* rating: Artist: '%s', Name: '%s', Rating: '%d'" % (entry_artist, entry_title, entry_rating)) db.entry_set(entry, RB.RhythmDBPropType.RATING, float(5)) db.commit() return True return False