public static void Main(string[] args) { UserConfig userConfig = LoadCredentialsFromFile(); NcoreClient nCore = GetAuthenticatedClientFor(userConfig) .ConfigureAwait(false).GetAwaiter().GetResult(); Thread.Sleep(TimeSpan.FromSeconds(2)); ISearchResultContainer resultContainer = nCore.Search.List() .GetAwaiter().GetResult(); Thread.Sleep(TimeSpan.FromSeconds(2)); ISearchResultContainer innaResults = nCore.Search.For("Inna") .ConfigureAwait(false).GetAwaiter().GetResult(); IEnumerable <HitAndRunTorrent> hitAndRunTorrents = nCore.HitAndRuns.List() .ConfigureAwait(false).GetAwaiter().GetResult(); Torrent torrent = nCore.Torrent.Get(1683491) .ConfigureAwait(false).GetAwaiter().GetResult(); FileStream destination = new FileStream($"{torrent.UploadName}.torrent", FileMode.CreateNew); torrent.DownloadAsFileTo(destination) .ConfigureAwait(false).GetAwaiter().GetResult(); Console.Read(); }
private static async Task <NcoreClient> GetAuthenticatedClientFor(UserConfig userConfig) { NcoreClient client = new NcoreClient(); await client.Login.AuthenticateWith(userConfig).ConfigureAwait(false); return(client); }
protected NcoreClient GetAuthenticatedClient() { var client = new NcoreClient(Web); SetServerResponse("LoginEndPoint", "authenticated"); client.Login.AuthenticateWith(new UserConfig(null, null, null)) .ConfigureAwait(false).GetAwaiter().GetResult(); return(client); }