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, subject, change_type, object_id, search_results): """ Callback that is called by Dispersy on incoming Torrent search results. :param search_results: A dictionary with keywords to which the results belong, a list of the results themselves and a candidate: the peer that has the full torrent file. :return: Nothing. """ keywords = search_results['keywords'] results = search_results['results'] candidate = search_results['candidate'] _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: infohash = result[0] name = result[1] length = result[2] category = result[4][0] #FIXME num_seeders = result[6] num_leechers = result[7] remoteHit = RemoteTorrent(-1, infohash, name, length, category, u'good', num_seeders, num_leechers, 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.torrent_db = self._torrent_db remoteHit.channelcast_db = self._channelcast_db if remoteHit.category.lower() == u'xxx' 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 Exception, e: _logger.info("Ignored one result in results from %s because of the following exception: %s" % (keywords, e)) pass
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