This is simple torrent downloader written in Go. The purpose of this package is to download files using the BitTorrent protocol. It provides interfaces to download and get torrent information.
- Download files using BitTorrent protocol
- Supports multiple concurrent downloads
- Supports torrent magnet url and file path as well
- Pause and resume downloads
- Track download process with download speed rates
- Manage multiple torrents at once
- Go 1.18 or later
Install the package with go get -v github.com/aliworkshop/torrent
There are some small examples in the package documentation.
Communication about the project is primarily through issue tracker.
- Step 1: Create new client to add torrent files to.
TickerDuration is timer duration to show download process
client := torrent.NewClient(torrent.ClientConfig{
TickerDuration: 3 * time.Second,
})
- Step 2: Add torrent files to client
err := client.AddTorrent("magnet:?xt=urn:btih:AE204757FE376C70852CD5818B01870F05EE7064")
if err != nil {
log.Fatalln("error on add torrent magnet url: ", err.Error())
}
- Step 3: Start torrent files concurrent download
eg, _ := errgroup.WithContext(context.Background())
for _, tt := range client.GetTorrents() {
eg.Go(func(t torrent.TorrentModel) func() error {
return func() error {
t.Initiate()
t.Download()
go t.DownloadLog()
return nil
}
}(tt))
}
eg.Wait()
And add client.GetClient().WaitAll()
to wait for downloads to complete
Ali Torabi If this library helps you in anyway, show your love ❤️ by putting a ⭐ on this project ✌️
Torrent is licensed under the MIT licence.