e621-sdk-go/example/highlevel/favorites.go
2024-07-20 11:04:53 +02:00

54 lines
1.1 KiB
Go

package main
import (
"git.anthrove.art/anthrove/e621-sdk-go/pkg/e621"
_ "github.com/joho/godotenv/autoload"
"log"
"os"
)
func main() {
client := e621.NewClient(os.Getenv("API_USER"), os.Getenv("API_KEY"))
{
favorites, err := client.GetFavoritesForUser("selloo")
if err != nil {
log.Panic(err)
}
posts, err := favorites.Execute()
if err != nil {
log.Panic(err)
}
log.Printf("URL of favorite post 0 is: %s", posts[0].File.URL)
}
{
favoritesBuilder, _ := client.GetFavoritesForUser("selloo")
favorites, err := client.GetNFavoritesForUser(10, favoritesBuilder)
if err != nil {
log.Panic(err)
}
log.Println(len(favorites))
}
{
favoritesBuilder, _ := client.GetFavoritesForUser("selloo")
favorites, err := client.GetAllFavoritesForUser(favoritesBuilder)
if err != nil {
log.Panic(err)
}
log.Println(len(favorites))
}
{
favoritesWithTags := client.GetFavoritesForUserWithTags("selloo", "fennec male solo")
posts, err := favoritesWithTags.Execute()
if err != nil {
log.Panic(err)
}
log.Printf("URL of favorite post 0 with tags is: %s", posts[0].File.URL)
}
}