'This function called when a source is finally determined. Fetch some torrents from it,
then insert it into our data'

def on_torrent_insert(self, source, infohash, torrent):

    self._logger.debug('remember    torrent    %s    from    %s', torrent, source_to_string(source))
    torrent['source'] = source_to_string(source)
    boost_source = self.boosting_sources.get(source, None)
    if (not boost_source):
        self._logger.info('Dropping    torrent    insert    from    removed    source:    %s', repr(torrent))
        return
    elif boost_source.archive:
        torrent['preload'] = True
        torrent['prio'] = 100
    duplicates = [other for other in self.torrents.values() if compare_torrents(torrent, other)]
    if duplicates:
        duplicates += [torrent]
        healthiest_torrent = max([(torrent['num_seeders'], torrent) for torrent in duplicates])[1]
        for duplicate in duplicates:
            is_duplicate = (healthiest_torrent != duplicate)
            duplicate['is_duplicate'] = is_duplicate
            if (is_duplicate and duplicate.get('download', None)):
                self.stop_download(duplicate)
    self.torrents[infohash] = torrent
