/// <summary> /// Loads a .torrent file from the specified URL /// </summary> /// <param name="url">The URL to download the .torrent from</param> /// <param name="location">The path to download the .torrent to before it gets loaded</param> /// <returns></returns> public static async Task <Torrent> LoadAsync(Uri url, string location) { Check.Url(url); Check.Location(location); try { using (var client = new HttpClient()) { Stream stream; using (var responseStream = await client.GetStreamAsync(url)) { stream = new MemoryStream(); await responseStream.CopyToAsync(stream); stream.Position = 0; } using (stream) return(Load(stream)); } } catch (Exception ex) { throw new TorrentException("Could not download .torrent file from the specified url", ex); } }
public MagnetLink(string url) { Check.Url(url); AnnounceUrls = new RawTrackerTier(); Webseeds = new List <string>(); ParseMagnetLink(url); }