You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package main
import (
"context""fmt""os""time""github.com/odwrtw/tpb"
)
funcmain() {
iferr:=run(); err!=nil {
fmt.Println(err)
os.Exit(1)
}
}
funcrun() error {
// The client supports multiple endpoints and will try to use one that// worksclient:=tpb.New(
"https://fakeapibay.org",
"https://apibay.org",
)
// You can create a context to cancel the searchctx, cancel:=context.WithTimeout(context.Background(), 60*time.Second)
defercancel()
// You can add search options or nil for the default options// torrents, err := client.Search(ctx, "Ubuntu", nil)// Or you can search within a given categorytorrents, err:=client.Search(ctx, "Ubuntu", &tpb.SearchOptions{
Category: tpb.Applications,
})
iferr!=nil {
returnerr
}
for_, t:=rangetorrents {
fmt.Println("--------------")
fmt.Printf("%s\nUploaded by %q (%d seeders / %d leechers)\nMagnet: %s",
t.Name,
t.User,
t.Seeders,
t.Leechers,
t.Magnet(),
)
}
returnnil
}