spiderden.net/go/libgallery Index | Files | Directories

package libgallery

import "spiderden.net/go/libgallery"

libgallery provides an interface for accessing boorus, and other resources in a booru-like fashion.

Index

Package Files

interface.go registry.go

Variables

var Registry map[string]Driver = map[string]Driver{}

The registry contains a list of names suitable for identification mapped to implementations. The key should not have spaces or captialisation.

func Register

func Register(name string, impl Driver)

Register new implementation, should only be accessed during Init() by implementation packages!

type Comment

type Comment struct {
    Author string    `json:"author"`
    Body   string    `json:"body"`
    Date   time.Time `json:"date"`
    Score  int64     `json:"score"`
}

type Driver

type Driver interface {
    Name() string // The proper name of a site, i.e. "Danbooru"
    // Search() can only accept space-separated snake-case tags.
    // If a booru doesn't support it you will need to
    // transmogrify the query.
    Search(string, uint64) ([]Post, error) // Tags, and page number.
    File(string) (Files, error)            // Fetches a file with a given ID.
    Comments(string) ([]Comment, error)    // Fetches the comments from a given ID.
}

Driver interface provides a method to access boorus, or a view of resources in a booru-like fashion (called virtual implementations)

type Files

type Files []io.ReadCloser

func (*Files) Close

func (f *Files) Close()

type Post

type Post struct {
    URL         string
    ID          string    `json:"id"`
    NSFW        bool      `json:"nsfw"`
    Date        time.Time `json:"date"`
    Description string    `json:"description"`
    Tags        string    `json:"tags"`
    Uploader    string    `json:"uploader"`
    Source      []string  `json:"source"`
    Score       int64     `json:"score"`
}

Post has various fields for what a post may contain. All zero values aside from Score and NSFW should be considered not-implemented on the site or otherwise unfetchable. Uploader should be the ID, not the username (unless usernames are used as IDs like Reddit)

Directories

PathSynopsis
cmd
driversImporting this package is the same as blank importing the below packages
drivers/danbooruDriver for Danbooru and compatible APIs.
drivers/e621
drivers/internal
drivers/rule34
Version
v0.0.0-20220811054116-d01eb42b47e5 (latest)
Published
Aug 11, 2022
Platform
linux/amd64
Imports
2 packages (graph)
Last checked
2 months ago

Tools for package owners.