def add_entry(self, result): # add only distinct songs (unique by title+artist+duration) to prevent duplicates strhash = ('%s%s%s' % (result.title, result.artist, result.duration)).lower() if strhash in self.entries_hashes: return self.entries_hashes.append(strhash) #first, let's try to find if the song with this url is already in db entry = self.db.entry_lookup_by_location(result.url) if entry is not None: return #add song to db entry = RB.RhythmDBEntry.new(self.db, self.entry_type, result.url) self.db.commit() if entry is not None: #update metadata self.db.entry_set( entry, RB.RhythmDBPropType.TITLE, decode_htmlentities(result.title).encode("utf-8")) self.db.entry_set(entry, RB.RhythmDBPropType.DURATION, result.duration) self.db.entry_set( entry, RB.RhythmDBPropType.ARTIST, decode_htmlentities(result.artist).encode("utf-8")) #all the songs will get "vk.com" album self.db.entry_set(entry, RB.RhythmDBPropType.ALBUM, "vk.com".encode("utf-8")) self.db.commit()
def add_entry(self, result): entry = self.db.entry_lookup_by_location(result.url) # add only distinct songs (unique by title+artist+duration) to prevent duplicates hash = ('%s%s%s' % (result.title, result.artist, result.duration)).lower() if hash in self.entries_hashes: return self.entries_hashes.append(hash) if entry is None: entry = self.db.entry_new(self.entry_type, result.url) if result.title: self.db.set(entry, rhythmdb.PROP_TITLE, decode_htmlentities(result.title)) if result.duration: self.db.set(entry, rhythmdb.PROP_DURATION, result.duration) if result.artist: self.db.set(entry, rhythmdb.PROP_ARTIST, decode_htmlentities(result.artist)) self.query_model.add_entry(entry, -1)
def add_entry(self, result): entry = self.db.entry_lookup_by_location(result.url) # add only distinct songs (unique by title+artist+duration) to prevent duplicates hash = ('%s%s%s' % (result.title, result.artist, result.duration)).lower() if hash in self.entries_hashes: return self.entries_hashes.append(hash) if entry is None: entry = RB.RhythmDBEntry.new(self.db, self.entry_type, result.url) if result.title: self.db.entry_set(entry, RB.RhythmDBPropType.TITLE, utf8ise(decode_htmlentities(result.title))) if result.duration: self.db.entry_set(entry, RB.RhythmDBPropType.DURATION, result.duration) if result.artist: self.db.entry_set(entry, RB.RhythmDBPropType.ARTIST, utf8ise(decode_htmlentities(result.artist))) self.query_model.add_entry(entry, -1) self.db.commit()
def add_entry(self, result): # add only distinct songs (unique by title+artist+duration) to prevent duplicates strhash = ('%s%s%s' % (result.title, result.artist, result.duration)).lower() if strhash in self.entries_hashes: return self.entries_hashes.append(strhash) #first, let's try to find if the song with this url is already in db entry = self.db.entry_lookup_by_location(result.url) if entry is not None : return #add song to db entry = RB.RhythmDBEntry.new(self.db, self.entry_type, result.url) self.db.commit() if entry is not None : #update metadata self.db.entry_set(entry, RB.RhythmDBPropType.TITLE, decode_htmlentities(result.title).encode("utf-8")) self.db.entry_set(entry, RB.RhythmDBPropType.DURATION, result.duration) self.db.entry_set(entry, RB.RhythmDBPropType.ARTIST, decode_htmlentities(result.artist).encode("utf-8")) #all the songs will get "vk.com" album self.db.entry_set(entry, RB.RhythmDBPropType.ALBUM, "vk.com".encode("utf-8")) self.db.commit()