2015-05-24 11:36:24 +00:00
|
|
|
package torrent_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
|
2016-01-18 14:28:56 +00:00
|
|
|
"github.com/anacrolix/missinggo"
|
|
|
|
|
2015-05-24 11:36:24 +00:00
|
|
|
"github.com/anacrolix/torrent"
|
|
|
|
)
|
|
|
|
|
|
|
|
func Example() {
|
2015-06-03 03:30:55 +00:00
|
|
|
c, _ := torrent.NewClient(nil)
|
2015-05-24 11:36:24 +00: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 03:30:55 +00:00
|
|
|
|
|
|
|
func Example_fileReader() {
|
|
|
|
var (
|
2016-04-03 08:40:43 +00:00
|
|
|
t *torrent.Torrent
|
2015-06-03 03:30:55 +00:00
|
|
|
f torrent.File
|
|
|
|
)
|
|
|
|
r := t.NewReader()
|
|
|
|
defer r.Close()
|
2015-06-04 04:25:52 +00:00
|
|
|
// Access the parts of the torrent pertaining to f. Data will be
|
|
|
|
// downloaded as required, per the configuration of the torrent.Reader.
|
2016-01-18 14:28:56 +00:00
|
|
|
_ = missinggo.NewSectionReadSeeker(r, f.Offset(), f.Length())
|
2015-06-03 03:30:55 +00:00
|
|
|
}
|