Beispiel #1
0
        private (torrent_handle torrentHandle, string downloadLocation, string name) AddToSession(string source)
        {
            using (var addTorrentParams = CreateAddTorrentParams(source))
            {
                var name          = addTorrentParams.ti?.name() ?? addTorrentParams.name;
                var infohash      = addTorrentParams.ti?.info_hash() ?? addTorrentParams.info_hash();
                var alreadyExists = _session.get_torrents().Any(t => t.info_hash() == infohash);
                if (alreadyExists)
                {
                    throw new OperationException("Torrent already exists");
                }

                var torrentHandle    = _session.add_torrent(addTorrentParams);
                var downloadLocation = Path.Combine(_downloadsFolder, name);
                return(torrentHandle, downloadLocation, name);
            }
        }