def _handle_internal(self, params):
        import time
        t = time.time()
        update_user_agent_counter(self.redis, params.application_id, self.user_agent, self.user_ip)
        searcher = FingerprintSearcher(self.conn, self.index)
        searcher.max_length_diff = params.max_duration_diff
        if params.batch:
            fingerprints = params.fingerprints
        else:
            fingerprints = params.fingerprints[:1]
        all_matches = []
        for p in fingerprints:
            if p['track_gid']:
                track_id = resolve_track_gid(self.conn, p['track_gid'])
                matches = [(0, track_id, p['track_gid'], 1.0)]
            else:
                matches = searcher.search(p['fingerprint'], p['duration'])
            all_matches.append(matches)
        response = {}
        if params.batch:
            response['fingerprints'] = fps = []
            result_map = {}
            for p, matches in zip(fingerprints, all_matches):
                results = []
                fps.append({'index': p['index'], 'results': results})
                track_ids = self._inject_results(results, result_map, matches)
                update_lookup_counter(self.redis, params.application_id, bool(track_ids))
                logger.debug("Lookup from %s: %s", params.application_id, list(track_ids))
        else:
            response['results'] = results = []
            result_map = {}
            self._inject_results(results, result_map, all_matches[0])
            update_lookup_counter(self.redis, params.application_id, bool(result_map))
            logger.debug("Lookup from %s: %s", params.application_id, result_map.keys())
        if params.meta and result_map:
            self.inject_metadata(params.meta, result_map)
        if fingerprints:
            time_per_fp = (time.time() - t) / len(fingerprints)
            update_lookup_avg_time(self.redis, time_per_fp)
        return response
dataset/ETHPy150Open lalinsky/acoustid-server/acoustid/api/v2/__init__.py/LookupHandler._handle_internal/original