static async Task <CustomPiecePicker> ChangeTorrentManagerPicker(TorrentManager torrentManager)
        {
            var picker = new CustomPiecePicker(new StandardPicker());
            await torrentManager.ChangePickerAsync(picker);

            return(picker);
        }
Beispiel #2
0
        public async Task LoadTorrentAsync(string torrentFilePath, string savePath)
        {
            // Load a .torrent file into memory
            Torrent torrent = await Torrent.LoadAsync(torrentFilePath);

            // Set all the files to not download
            //foreach (TorrentFile file in torrent.Files)
            //    file.Priority = Priority.High;
            ////Set First File Prioroty
            //torrent.Files[1].Priority = Priority.Highest;
            if (string.IsNullOrWhiteSpace(savePath))
            {
                savePath = "TorrentsDownload";
            }
            //Proceed
            if (!Directory.Exists(savePath))
            {
                Directory.CreateDirectory(savePath);
            }

            TorrentManager manager = new TorrentManager(torrent, savePath, new TorrentSettings());

            managers.Add(manager);
            await engine.Register(manager);

            // Disable rarest first and randomised picking - only allow priority based picking (i.e. selective downloading)
            PiecePicker picker = new StandardPicker();

            picker = new PriorityPicker(picker);
            await manager.ChangePickerAsync(picker);

            await engine.StartAll();
        }