precum

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

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

Go to latest
Published: Jan 21, 2022 License: MIT Imports: 11 Imported by: 0

README

precum

NSFW websites metadata resolver inspired by Tissue's MetadataResolver.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// 処理に全く対応していないURLが渡された時のエラー
	ErrUnsupportedUrl = errors.New("unsupported url")
	// resolverがサイトのコンテンツに対応しておらず、他のresolverに委譲する時のエラー
	ErrUnsupportedContent = errors.New("unsupported content")
)
View Source
var DefaultRouter = &Router{
	Rules: []Rule{
		{regexp.MustCompile("komiflo\\.com(/#!)?/comics/(\\d+)"), NewKomifloResolver},
		{regexp.MustCompile("ss\\.kb10uy\\.org/posts/\\d+$"), NewKbS3Resolver},
		{regexp.MustCompile(".*"), NewOGPResolver},
	},
}

Functions

This section is empty.

Types

type Material

type Material struct {
	Url         string
	Title       string
	Description string
	Image       string
	Tags        []string
}

func Resolve

func Resolve(ctx context.Context, url string) (*Material, error)

type Resolver

type Resolver interface {
	Resolve(ctx context.Context, url string) (*Material, error)
}

func NewKbS3Resolver

func NewKbS3Resolver() Resolver

func NewKomifloResolver

func NewKomifloResolver() Resolver

func NewOGPResolver

func NewOGPResolver() Resolver

type Router

type Router struct {
	Rules []Rule
}

func (*Router) Resolve

func (r *Router) Resolve(ctx context.Context, url string) (*Material, error)

type Rule

type Rule struct {
	Pattern *regexp.Regexp
	Factory func() Resolver
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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