Alphyron
214aaceee0
All checks were successful
Gitea Build Check / Build (pull_request) Successful in 35s
59 lines
1.6 KiB
Go
59 lines
1.6 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"
|
|
"strconv"
|
|
)
|
|
|
|
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 note.
|
|
log.Println("Getting single note: ")
|
|
|
|
// Specify the note ID for retrieval.
|
|
noteID := 36957 // Replace with the desired note's ID.
|
|
|
|
// Call the GetNote function to retrieve the specified note.
|
|
getNote := builder.NewGetNoteBuilder(requestContext)
|
|
note, err := getNote.SetNoteID(noteID).Execute()
|
|
|
|
if err != nil {
|
|
log.Println(err)
|
|
} else {
|
|
// Log the body of the retrieved note.
|
|
log.Println(note.Body)
|
|
}
|
|
log.Println("----------")
|
|
|
|
// Log: Getting a list of notes.
|
|
log.Println("Getting a list of notes: ")
|
|
|
|
// Call the GetNotes function to retrieve a list of notes based on the query parameters.
|
|
getNotes := builder.NewGetNotesBuilder(requestContext)
|
|
notes, err := getNotes.SetLimit(5).Active(true).SearchInBody("furry").Execute()
|
|
|
|
if err != nil {
|
|
log.Println(err)
|
|
} else {
|
|
// Log the number of notes retrieved.
|
|
log.Println(len(notes))
|
|
for _, note := range notes {
|
|
log.Printf("Note by %s - %s : %s", note.CreatorName, note.Body, strconv.FormatInt(note.ID, 10))
|
|
}
|
|
}
|
|
log.Println("----------")
|
|
}
|