2015-05-24 19:36:24 +08:00
|
|
|
package torrent_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
|
|
|
|
"github.com/anacrolix/torrent"
|
|
|
|
)
|
|
|
|
|
|
|
|
func Example() {
|
2015-06-03 11:30:55 +08:00
|
|
|
c, _ := torrent.NewClient(nil)
|
2015-05-24 19:36:24 +08:00
|
|
|
defer c.Close()
|
|
|
|
t, _ := c.AddMagnet("magnet:?xt=urn:btih:ZOCMZQIPFFW7OLLMIC5HUB6BPCSDEOQU")
|
|
|
|
<-t.GotInfo()
|
|
|
|
t.DownloadAll()
|
|
|
|
c.WaitAll()
|
|
|
|
log.Print("ermahgerd, torrent downloaded")
|
|
|
|
}
|
2015-06-03 11:30:55 +08:00
|
|
|
|
|
|
|
func Example_fileReader() {
|
2018-01-06 13:37:13 +08:00
|
|
|
var f torrent.File
|
|
|
|
// Accesses the parts of the torrent pertaining to f. Data will be
|
2015-06-04 12:25:52 +08:00
|
|
|
// downloaded as required, per the configuration of the torrent.Reader.
|
2018-01-06 13:37:13 +08:00
|
|
|
r := f.NewReader()
|
|
|
|
defer r.Close()
|
2015-06-03 11:30:55 +08:00
|
|
|
}
|