Comments (1)
public async Task CreateAsync(CancellationToken token, string torrentsPath, string downloadsPath)
{
try
{
DAPLauncher.MainWindow targetWindow = System.Windows.Application.Current.Windows.Cast<Window>().FirstOrDefault(window => window is DAPLauncher.MainWindow) as DAPLauncher.MainWindow;
targetWindow.file_local.Content = "1. Created Torrent File : " + torrentsPath;
int CountF = 0;
ViewModel._orders.Clear();
DirectoryInfo dir = new(downloadsPath);
Files = dir.GetFiles("*", SearchOption.AllDirectories);
for (int fcount = 0; fcount < Files.Length; fcount++)
{
CountF++;
}
targetWindow.progressload.Maximum = CountF + 1;
string pubIp = new WebClient().DownloadString("https://api.ipify.org");
TorrentType torrentType = TorrentType.V1Only;
if (bCheckV1Only)
{
torrentType = TorrentType.V1Only;
}
if (bCheckV1OnlyWithPaddingFiles)
{
torrentType = TorrentType.V1OnlyWithPaddingFiles;
}
if (bCheckV2Only)
{
torrentType = TorrentType.V2Only;
}
if (bCheckV1V2Hybrid)
{
torrentType = TorrentType.V1V2Hybrid;
}
Factories factories = new()
{
};
TorrentCreator torrentCreator = new(torrentType, factories);
TorrentFileSource torrentFileSource = new(downloadsPath)
{
TorrentName = Path.GetFileName(torrentsPath).Replace(".torrent", string.Empty)
};
torrentCreator.Hashed += async delegate (object o, TorrentCreatorEventArgs e)
{
targetWindow.md5local.Dispatcher.Invoke(DispatcherPriority.Background, new Action(() =>
{
targetWindow.md5local.Content = e.CurrentFile + "[FileSize : " + TotalFile(e.FileSize) + "/ FileBytesHashed : " + TotalFile(e.FileBytesHashed) + "]FileCompletion : " + e.FileCompletion;
if (e.FileCompletion == 1.0)
{
targetWindow.progressload.Value++;
ViewModel._orders.Add(new TorrentFileEntity
{
Name = Path.GetFileName(e.CurrentFile),
Path = e.CurrentFile,
Size = TotalFile(e.FileSize),
PriorityText = "",
ProgressText = string.Format("{0:0.00}%", e.FileCompletion),
Progress = 100
});
targetWindow.DataGFileTorrent.ItemsSource = ViewModel._orders;
}
}));
StatusMessage?.Invoke(this, $"" + "DownloadAsync," + e.CurrentFile + "[FileSize : " + TotalFile(e.FileSize) + "/ FileBytesHashed : " + TotalFile(e.FileBytesHashed) + "]FileCompletion : " + e.FileCompletion);
await Task.Delay(500, token);
};
StatusMessage?.Invoke(this, $"" + "Engine," + Path.GetFileName(torrentsPath).Replace(".torrent", string.Empty));
torrentCreator.Announces.Add(new List<string>());
try
{
torrentCreator.Announces[0].Add("http://" + pubIp + ":" + PortTrackerhttp + "/announce");
torrentCreator.Announces[0].Add("udp://" + pubIp + ":" + PortTrackerudp + "/announce");
for (int pBName = 0; pBName < ListTrackers.Count; pBName++)
{
torrentCreator.Announces[0].Add(ListTrackers[pBName].Tracker);
}
}
catch (Exception ex) { System.Windows.MessageBox.Show("ADD TRACKERS : " + ex.Message); }
torrentCreator.Comment = "ServerManager[SM]";
torrentCreator.Publisher = "https://discord.com/invite/ZTJTRpb9TF";
await torrentCreator.CreateAsync(torrentFileSource, torrentsPath, token);
await Task.Delay(1000, token);
ViewModel._orders.Clear();
targetWindow.DataGFileTorrent.ItemsSource = ViewModel._orders;
targetWindow.RLogTorrent.Document.Blocks.Clear();
targetWindow.RichLogFirst.Document.Blocks.Clear();
TorrentCreatOrDownloading = false;
Thread FileSearch = new(new ThreadStart(targetWindow.StartHeSH))
{
IsBackground = true
};
FileSearch.Start();
}
catch (Exception ex) { System.Windows.MessageBox.Show("CreateAsync : " + ex.Message); }
}
from monotorrent.
Related Issues (20)
- HashCheckAsync find some failed hashes on a V1only torrent that was fully downloaded a second ago HOT 1
- torrent won't announce if it is added as seeding HOT 2
- Can we get an update to the nuget package?
- Download Multiple Torrents HOT 1
- MagnetLink not working HOT 2
- WebSeed: Pieces get out of order and create an http request with a negative end
- Any sample code? Does this work with VB.NET also? HOT 1
- Help
- Is there any TorrentEditor?
- Doesnt work with TooLongPath HOT 1
- I donβt know what to do with this anymore
- Using no disk based files with torrent creation. HOT 3
- CancellationToken works chaotically
- This project lacks documentation...
- Question: are there any advantages of `ReusableTask` over `ValueTask`
- Unable to seed giant torrents: ProtocolException: Invalid message length received
- Logging++
- Feature request: announce multiple endpoints
- MonoTorrent is unable to transmit files >2GB HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from monotorrent.