Alphyron
214aaceee0
All checks were successful
Gitea Build Check / Build (pull_request) Successful in 35s
58 lines
1.5 KiB
Go
58 lines
1.5 KiB
Go
package main
|
|
|
|
import (
|
|
"git.anthrove.art/Anthrove/e621-sdk-go/pkg/e621/builder"
|
|
"git.anthrove.art/Anthrove/e621-sdk-go/pkg/e621/model"
|
|
_ "github.com/joho/godotenv/autoload"
|
|
"log"
|
|
"net/http"
|
|
"os"
|
|
)
|
|
|
|
func main() {
|
|
// Define the request context with essential information.
|
|
requestContext := model.RequestContext{
|
|
Client: http.Client{},
|
|
Host: "https://e621.net",
|
|
UserAgent: "Go-e621-SDK (@username)",
|
|
Username: os.Getenv("API_USER"), // Replace with your username
|
|
APIKey: os.Getenv("API_KEY"), // Replace with your API key
|
|
}
|
|
|
|
// Log: Getting a single pool.
|
|
log.Println("Getting single pool: ")
|
|
|
|
// Specify the pool ID for retrieval.
|
|
poolID := 36957 // Replace with the desired pool's ID.
|
|
|
|
// Call the GetPool function to retrieve the specified pool.
|
|
getPool := builder.NewGetPoolBuilder(requestContext)
|
|
pool, err := getPool.ID(poolID).Execute()
|
|
|
|
if err != nil {
|
|
log.Println(err)
|
|
} else {
|
|
// Log the name of the retrieved pool.
|
|
log.Println(pool.Name)
|
|
}
|
|
log.Println("----------")
|
|
|
|
// Log: Getting a list of pools.
|
|
log.Println("Getting a list of pools: ")
|
|
|
|
// Call the GetPools function to retrieve a list of pools based on the query parameters.
|
|
getPools := builder.NewGetPoolsBuilder(requestContext)
|
|
pools, err := getPools.SetLimit(5).Active(true).SearchDescription("mass effect").Execute()
|
|
|
|
if err != nil {
|
|
log.Println(err)
|
|
} else {
|
|
// Log the number of pools retrieved.
|
|
log.Println(len(pools))
|
|
log.Println(pools[1].Name)
|
|
log.Println(pools[1].ID)
|
|
}
|
|
log.Println("----------")
|
|
|
|
}
|