libgallery

package module
v0.0.0-...-c1da5af Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 17, 2022 License: AGPL-3.0 Imports: 2 Imported by: 0

README

libgallery
==========

libgallery provides an interface for accessing boorus,
and other resources in a booru-like fashion. It is
currently very unstable, as I want people to start
toying with this so we can refine how things work.
Once we reach 1.0 there will be no backwards
incompatible changes.

Also included is a command line interface and some 
official drivers. libgallery also includes a registry
that third-party drivers can use import side-effects 
to automatically register with (like database/sql).
This makes it trivial to add drivers to existing 
programs using libgallery.

If you're writing quality drivers with minimal
external dependencies, you're strongly encouraged to
contribute and make them official drivers.

Further things worth researching:

- Bindings to languages like Python via the C API
- Runtime plugins with something like yaegi
- Interfaces for authentication

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

View Source
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.

Functions

func Register

func Register(name string, impl Driver)

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

Types

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 {
	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

Path Synopsis
Importing this package is the same as blank importing the below packages
Importing this package is the same as blank importing the below packages
danbooru
Driver for Danbooru and compatible APIs.
Driver for Danbooru and compatible APIs.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL