def _similar_artists(self, artist_nameA, artist_nameB, match, source, locked=False): if not locked: self.acquire() #self._logger.debug(u"%s: [%s]-[%s] %2.2f" % (source, artist_nameA, # artist_nameB, match)) artistA = ArtistFactory.by_key(artist_nameA) artistB = ArtistFactory.by_key(artist_nameB) #if not artistA: self._logger.debug(u"similar_artists[%s]: not found" % # artist_nameA) #if not artistB: self._logger.debug(u"similar_artists[%s]: not found" % # artist_nameB) if artistA and artistB: relation = ArtistRelationFactory.get(artistA, artistB) old_rating = relation.rating relation.rate(0.75 + 0.25 * match) self._logger.debug(u"%s [%s]-[%s] m(%2.2f) r(%2.2f|%2.2f)" % (source, artistA, artistB, match, relation.rating, old_rating)) if self._queue_lookup_results: if self._lastfm: self._lastfm.similar_artists_low(self.similar_artists, artist_nameB, self._thres_lastfm_lookup) if self._echonest: self._echonest.similar_artists_low(self.similar_artists, artist_nameB, self._thres_lastfm_lookup) if not locked: self.release()
def __setstate__(self, dict): artistA = ArtistFactory.by_key(dict['artistA_key']) del dict['artistA_key'] artistB = ArtistFactory.by_key(dict['artistB_key']) del dict['artistB_key'] self.__dict__ = dict self.artistA = artistA self.artistB = artistB
def __setstate__(self, dict): # Logger.info(u"track dict in: %s" % dict) artist = ArtistFactory.by_key(dict['artist_key']) del dict['artist_key'] ratingref = RatingFactory.by_key(dict['ratingref_key']) del dict['ratingref_key'] self.__dict__ = dict self.artist = artist self.ratingref = ratingref # Logger.info(u"track.dict out: %s" % self.__dict__) TrackFactory.register(self)