public static MagnetLink createFromURI(String uri) throws MalformedURLException, UnsupportedEncodingException, SocketException{
		
		byte []hashInfo;
		byte []peerID;
		String name;
		String udpTracker = null;
		String httpTracker = null;
		if(uri.startsWith("magnet:?")){
			//build search:
			//TODO: some extra trackers will be lost.
			Map<String,String> query =splitQuery(uri.substring("magnet:?".length()));
			if(!query.containsKey("xt")){
				throw new RuntimeException("invalid magnet link");
			}
			String hash = query.get("xt");
			
			if(hash.startsWith("urn:btih:")){
				hash = hash.substring("urn:btih:".length());
			}else{
				throw new RuntimeException("invalid magnet format. unknown hash format");
			}
			
			hashInfo = hexStringToByteArray(hash);
			//Check for the extra's:
			if(query.containsKey("dn")){
				name = query.get("dn");
			}else{
				name = hash;
			}
			//TODO: multiple
			if(query.containsKey("tr")){
				String tracker = query.get("tr");
				if(tracker.startsWith("udp")){
					udpTracker = tracker.substring(3);
				}else if(tracker.startsWith("http:")){
					httpTracker = tracker.substring(0);
				}else{
					//we dont support https...
				}
			}
			
		}else{
			//better be base32 hashinfo
			name = uri;
			hashInfo = hexStringToByteArray(uri);
			if(uri.length()!=40){
				throw new RuntimeException("NOT VALID HASHINFO, must be base 32");
			}
		}
		
		if(hashInfo.length!=20){
			throw new RuntimeException("NOT VALID HASHINFO, must be base 32");
		}
		
		
		peerID = Torrent.generateSessionKey(20).getBytes("UTF-8");
		
		return new MagnetLink(hashInfo,peerID,name,udpTracker,httpTracker);
	}