def __init__(self, url, callback, timeout, max_connections=30):
        """
        If the URL conforms to a magnet link, the .torrent info is
        downloaded and returned to CALLBACK.
        """
        # _callback is called when the metadata is retrieved.
        self._callback = callback

        dn, xt, trs = self.parse_url(url)

        # _name is the unicode name suggested for the swarm.
        assert dn is None or isinstance(dn, unicode), "DN has invalid type: %s" % type(dn)
        self._name = dn

        # _info_hash is the 20 byte binary info hash that identifies
        # the swarm.
        assert isinstance(xt, str), "XT has invalid type: %s" % type(xt)
        assert len(xt) == 20, "XT has invalid length: %d" % len(xt)
        self._info_hash = xt

        # _tracker is an optional tracker address.
        self._trackers = trs

        # _swarm is a MiniBitTorrent.MiniSwarm instance that connects
        # to peers to retrieve the metadata.
        self.magnet_handler = MagnetHandler.get_instance()
        self.magnet_handler.add_magnet(self, timeout)
        self._swarm = MiniSwarm(self._info_hash, self.magnet_handler.get_raw_server(), self.metainfo_retrieved, max_connections=max_connections)