def _search_remote_callback(self, keywords, results, candidate): """ Callback that is called by Dispersy on incoming Torrent search results. :param keywords: Keywords that these results belong to. :param results: List of results. :param candidate: The peer that has the full torrent file. :return: Nothing. """ _logger.info( "******************** got %s unfiltered results for %s %s %s" % (len(results), keywords, candidate, time())) # Ignore searches we don't want (anymore) if not self._keywords == keywords: _logger.info("Ignored results for %s, we are looking for %s now" % (keywords, self._keywords)) return for result in results: try: categories = result[4] category_id = self._misc_db.categoryName2Id(categories) remoteHit = RemoteTorrent( -1, result[0], result[8], result[9], result[1], result[2], category_id, self._misc_db.torrentStatusName2Id(u'good'), result[6], result[7], set([candidate])) # Guess matches #keywordset = set(keywords) #swarmnameset = set(split_into_keywords(remoteHit.name)) #matches = {'fileextensions': set()} #matches['swarmname'] = swarmnameset & keywordset # all keywords matching in swarmname #matches['filenames'] = keywordset - matches['swarmname'] # remaining keywords should thus me matching in filenames or fileextensions #if len(matches['filenames']) == 0: # _, ext = os.path.splitext(result[0]) # ext = ext[1:] # matches['filenames'] = matches['swarmname'] # matches['filenames'].discard(ext) # if ext in keywordset: # matches['fileextensions'].add(ext) #remoteHit.assignRelevance(matches) remoteHit.misc_db = self._misc_db remoteHit.torrent_db = self._torrent_db remoteHit.channelcast_db = self._channelcast_db if remoteHit.category_id == self._xxx_category and self._category.family_filter_enabled( ): _logger.info("Ignore XXX torrent: %s" % remoteHit.name) else: # Add to result list. self._add_remote_result(remoteHit) except: pass return
def _search_remote_callback(self, keywords, results, candidate): """ Callback that is called by Dispersy on incoming Torrent search results. :param keywords: Keywords that these results belong to. :param results: List of results. :param candidate: The peer that has the full torrent file. :return: Nothing. """ _logger.info("******************** got %s unfiltered results for %s %s %s" % (len(results), keywords, candidate, time())) # Ignore searches we don't want (anymore) if not self._keywords == keywords: _logger.info("Ignored results for %s, we are looking for %s now" % (keywords, self._keywords)) return for result in results: try: categories = result[4] category_id = self._misc_db.categoryName2Id(categories) remoteHit = RemoteTorrent(-1, result[0], result[8], result[9], result[1], result[2], category_id, self._misc_db.torrentStatusName2Id(u'good'), result[6], result[7], set([candidate])) # Guess matches #keywordset = set(keywords) #swarmnameset = set(split_into_keywords(remoteHit.name)) #matches = {'fileextensions': set()} #matches['swarmname'] = swarmnameset & keywordset # all keywords matching in swarmname #matches['filenames'] = keywordset - matches['swarmname'] # remaining keywords should thus me matching in filenames or fileextensions #if len(matches['filenames']) == 0: # _, ext = os.path.splitext(result[0]) # ext = ext[1:] # matches['filenames'] = matches['swarmname'] # matches['filenames'].discard(ext) # if ext in keywordset: # matches['fileextensions'].add(ext) #remoteHit.assignRelevance(matches) remoteHit.misc_db = self._misc_db remoteHit.torrent_db = self._torrent_db remoteHit.channelcast_db = self._channelcast_db if remoteHit.category_id == self._xxx_category and self._category.family_filter_enabled(): _logger.info("Ignore XXX torrent: %s" % remoteHit.name) else: # Add to result list. self._add_remote_result(remoteHit) except: pass return