当前位置: 首页>>代码示例>>C#>>正文


C# Api.DownloadFromUrls方法代码示例

本文整理汇总了C#中Api.DownloadFromUrls方法的典型用法代码示例。如果您正苦于以下问题:C# Api.DownloadFromUrls方法的具体用法?C# Api.DownloadFromUrls怎么用?C# Api.DownloadFromUrls使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Api的用法示例。


在下文中一共展示了Api.DownloadFromUrls方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestGetGeneralProperties

        public async Task TestGetGeneralProperties()
        {
            var api = new Api(_serverCredential);

            var uris = new[]
            {
                new Uri(
                    "magnet:?xt=urn:btih:cd8158937344b2a066446bed7e7a0c45214f1245&dn=debian-8.2.0-amd64-DVD-1.iso&tr=http%3a%2f%2fbttracker.debian.org%3a6969%2fannounce")
            };
            var hashes = new[]
            {
                "cd8158937344b2a066446bed7e7a0c45214f1245"
            };

            await api.DownloadFromUrls(uris);

            await api.WaitForTorrentToBePausedByHash(hashes.FirstOrDefault());

            await api.Resume(hashes.FirstOrDefault());

            await api.WaitForTorrentToStartByHash(hashes.FirstOrDefault());

            var generalProperties = await api.GetGeneralProperties(hashes.SingleOrDefault());

            Assert.True(generalProperties.TimeElapsed >= 0);

            await api.DeletePermanently(hashes);
        }
开发者ID:rbarbe,项目名称:qBittorrentApi,代码行数:28,代码来源:Functional.cs

示例2: TestGetProperties

        public async Task TestGetProperties()
        {
            var api = new Api(_serverCredential);

            var uris = new[]
            {
                new Uri(
                    "magnet:?xt=urn:btih:cd8158937344b2a066446bed7e7a0c45214f1245&dn=debian-8.2.0-amd64-DVD-1.iso&tr=http%3a%2f%2fbttracker.debian.org%3a6969%2fannounce")
            };
            var hashes = new[]
            {
                "cd8158937344b2a066446bed7e7a0c45214f1245"
            };

            await api.DownloadFromUrls(uris);

            //await api.WaitForTorrentToBePausedByHash(hashes.FirstOrDefault());

            //await api.Resume(hashes.FirstOrDefault());

            await api.WaitForTorrentToStartByHash(hashes.FirstOrDefault());

            var trackersPropertieses = await api.GetTrackersProperties(hashes.SingleOrDefault());

            Assert.True(trackersPropertieses.Any(p => p.Url.Contains("http://bttracker.debian.org:6969/announce")));

            var filesPropertieses = await api.GetFilesProperties(hashes.SingleOrDefault());
            var file = filesPropertieses.Single();
            Assert.Equal("debian-8.2.0-amd64-DVD-1.iso", file.Name);
            Assert.Equal(3992977408, file.Size);

            var transferInfo = await api.GetTransferInfo();
            Assert.True(transferInfo.DhtNodes >= 0);

            var setCategoryResult = await api.SetCategory(hashes, "linux-distro");
            Assert.True(transferInfo.DhtNodes >= 0);

            var recheckResult = await api.Recheck(hashes.SingleOrDefault());
            Assert.True(recheckResult);

            var addTrackerResult = await api.AddTrackers(hashes.SingleOrDefault(), new[] { new Uri("http://test1/"), new Uri("http://test2/") });
            Assert.True(addTrackerResult);

            await api.DeletePermanently(hashes);
        }
开发者ID:rbarbe,项目名称:qBittorrentApi,代码行数:45,代码来源:Functional.cs

示例3: TestDownloadFromUrls

        public async Task TestDownloadFromUrls()
        {
            var api = new Api(_serverCredential);

            var uris = new[]
            {
                new Uri(
                    "magnet:?xt=urn:btih:cd8158937344b2a066446bed7e7a0c45214f1245&dn=debian-8.2.0-amd64-DVD-1.iso&tr=http%3a%2f%2fbttracker.debian.org%3a6969%2fannounce"),
                new Uri(
                    "magnet:?xt=urn:btih:e508e5f1c7ad6650eb41d38f29aa567923b3934f&dn=debian-8.2.0-amd64-DVD-2.iso&tr=http%3a%2f%2fbttracker.debian.org%3a6969%2fannounce")
            };

            var hashes = new[]
            {
                "cd8158937344b2a066446bed7e7a0c45214f1245",
                "e508e5f1c7ad6650eb41d38f29aa567923b3934f"
            };

            var initialCount = (await api.GetTorrents()).Count;

            await api.DownloadFromUrls(uris);

            foreach(var hash in hashes)
            {
                //await api.WaitForTorrentToBePausedByHash(hash);
                //await api.Resume(hash);
                await api.WaitForTorrentToStartByHash(hash);
            }

            var after2AddCount = (await api.GetTorrents()).Count;
            Assert.Equal(initialCount + 2, after2AddCount);

            await api.DeletePermanently(hashes);
            var after2Delete = (await api.GetTorrents()).Count;

            Assert.Equal(initialCount, after2Delete);
        }
开发者ID:rbarbe,项目名称:qBittorrentApi,代码行数:37,代码来源:Functional.cs


注:本文中的Api.DownloadFromUrls方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。