public void download ( String magnetUri , File saveDir ) { if ( session == null ) { return ; } error_code ec = new error_code ( ) ; add_torrent_params p = add_torrent_params . parse_magnet_uri ( magnetUri , ec ) ; if ( ec . value ( ) != 0 ) { throw new IllegalArgumentException ( ec . message ( ) ) ; } sha1_hash info_hash = p . getInfo_hash ( ) ; torrent_handle th = session . find_torrent ( info_hash ) ; if ( th != null && th . is_valid ( ) ) { // found a download with the same hash return ; } if ( saveDir != null ) { p . setSave_path ( saveDir . getAbsolutePath ( ) ) ; } torrent_flags_t flags = p . getFlags ( ) ; flags = flags . and_ ( TorrentFlags . AUTO_MANAGED . inv ( ) ) ; p . setFlags ( flags ) ; session . async_add_torrent ( p ) ; }
Downloads a magnet uri .