kemono

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2023 License: MIT Imports: 12 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SiteMap = map[string]string{
	"patreon":       "kemono",
	"fanbox":        "kemono",
	"gumroad":       "kemono",
	"subscribestar": "kemono",
	"dlsite":        "kemono",
	"discord":       "kemono",
	"fantia":        "kemono",
	"boosty":        "kemono",
	"afdian":        "kemono",
	"onlyfans":      "coomer",
	"fansly":        "coomer",
}

Functions

This section is empty.

Types

type AttachmentFilter

type AttachmentFilter func(i int, attachment File) bool

func ExtensionExcludeFilter

func ExtensionExcludeFilter(extension ...string) AttachmentFilter

ExtensionExcludeFilter A attachmentFilter filter that filters attachments without a specific extension

func ExtensionFilter

func ExtensionFilter(extension ...string) AttachmentFilter

ExtensionFilter A attachmentFilter filter that filters attachments with a specific extension

type Creator

type Creator struct {
	Favorited int       `json:"favorited"`
	Id        string    `json:"id"`
	Indexed   Timestamp `json:"indexed"`
	Name      string    `json:"name"`
	Service   string    `json:"service"`
	Updated   Timestamp `json:"updated"`
}

func FindCreator

func FindCreator(creators []Creator, id, service string) (Creator, bool)

FindCreator Get the Creator by ID and Service

func NewCreator

func NewCreator(service, id string) Creator

func (Creator) GetID

func (c Creator) GetID() string

GetID get creator id

func (Creator) GetService

func (c Creator) GetService() string

GetService get creator Service

func (Creator) PairString

func (c Creator) PairString() string

type CreatorFilter

type CreatorFilter func(i int, post Creator) bool

type DefaultLog

type DefaultLog struct {
	// contains filtered or unexported fields
}

func (*DefaultLog) Print

func (d *DefaultLog) Print(s string)

func (*DefaultLog) Printf

func (d *DefaultLog) Printf(format string, v ...interface{})

type Downloader

type Downloader interface {
	Download(<-chan FileWithIndex, Creator, Post) <-chan error
	Get(url string) (resp *http.Response, err error)
	WriteContent(Creator, Post, string) error
}

type FavoriteCreator added in v0.0.2

type FavoriteCreator struct {
	FavedSeq int    `json:"faved_seq"`
	Id       string `json:"id"`
	Index    string `json:"index"`
	Name     string `json:"name"`
	Service  string `json:"service"`
	Update   string `json:"update"`
}

type File

type File struct {
	Name string `json:"name"`
	Path string `json:"path"`
}

func (File) GetHash

func (f File) GetHash() (string, error)

GetHash get hash from file path

func (File) GetURL

func (f File) GetURL() string

GetURL return the url

func (File) Index

func (f File) Index(n int) FileWithIndex

type FileWithIndex

type FileWithIndex struct {
	Index int
	File
}

func AddIndexToAttachments added in v0.0.10

func AddIndexToAttachments(attachments []File) []FileWithIndex

type Kemono

type Kemono struct {
	// kemono or coomer ...
	Site string
	//download Banner
	Banner bool

	// downloader
	Downloader Downloader
	// contains filtered or unexported fields
}

func NewKemono

func NewKemono(options ...Option) *Kemono

func (*Kemono) DownloadPosts

func (k *Kemono) DownloadPosts(creator Creator, posts []Post) (err error)

DownloadPosts download posts

func (*Kemono) FetchCreators

func (k *Kemono) FetchCreators() (creators []Creator, err error)

FetchCreators fetch Creator list

func (*Kemono) FetchPosts

func (k *Kemono) FetchPosts(service, id string) (posts []Post, err error)

FetchPosts fetch post list

func (*Kemono) FilterAttachments

func (k *Kemono) FilterAttachments(user string, attachments []File) []File

func (*Kemono) FilterCreators

func (k *Kemono) FilterCreators(creators []Creator) []Creator

func (*Kemono) FilterPosts

func (k *Kemono) FilterPosts(posts []Post) []Post

func (*Kemono) Start

func (k *Kemono) Start()

Start fetch and download

type Log

type Log interface {
	Printf(format string, v ...interface{})
	Print(s string)
}

type Option

type Option func(*Kemono)

func SetDownloader

func SetDownloader(downloader Downloader) Option

SetDownloader set Downloader

func SetLog

func SetLog(log Log) Option

SetLog set log

func WithAttachmentFilter

func WithAttachmentFilter(filter ...AttachmentFilter) Option

WithAttachmentFilter Attachment filter

func WithBanner

func WithBanner(banner bool) Option

func WithCreatorFilter

func WithCreatorFilter(filter ...CreatorFilter) Option

WithCreatorFilter Creator filter

func WithCreators

func WithCreators(creators []Creator) Option

Custom the creator list

func WithDomain

func WithDomain(web string) Option

WithDomain Set Site

func WithPostFilter

func WithPostFilter(filter ...PostFilter) Option

WithPostFilter Post filter

func WithUserAttachmentFilter

func WithUserAttachmentFilter(creator Creator, filter ...AttachmentFilter) Option

func WithUserPostFilter

func WithUserPostFilter(creator Creator, filter ...PostFilter) Option

func WithUsers

func WithUsers(user ...Creator) Option

WithUsers Select a specific creator, if not specified, all creators will be selected

func WithUsersPair

func WithUsersPair(serviceIdPairs ...string) Option

WithUsersPair Select a specific creator, if not specified, all creators will be selected

type Post

type Post struct {
	Added       time.Time   `json:"added"`
	Attachments []File      `json:"attachments"`
	Content     string      `json:"content"`
	Edited      time.Time   `json:"edited"`
	Embed       interface{} `json:"embed"`
	File        File        `json:"file"`
	Id          string      `json:"id"`
	Published   time.Time   `json:"published"`
	Service     string      `json:"service"`
	SharedFile  bool        `json:"shared_file"`
	Title       string      `json:"title"`
	User        string      `json:"user"`
}

type PostFilter

type PostFilter func(i int, post Post) bool

func EditDateAfterFilter

func EditDateAfterFilter(from time.Time) PostFilter

EditDateAfterFilter A Post filter that filters posts with edit date after

func EditDateBeforeFilter

func EditDateBeforeFilter(to time.Time) PostFilter

EditDateBeforeFilter A Post filter that filters posts with edit date before

func EditDateFilter

func EditDateFilter(from, to time.Time) PostFilter

EditDateFilter A Post filter that filters posts with edit date

func IdFilter

func IdFilter(ids ...string) PostFilter

func NumbFilter

func NumbFilter(f func(i int) bool) PostFilter

NumbFilter A Post filter that filters posts with a specific number

func ReleaseDateAfterFilter

func ReleaseDateAfterFilter(from time.Time) PostFilter

ReleaseDateAfterFilter A Post filter that filters posts with release date after

func ReleaseDateBeforeFilter

func ReleaseDateBeforeFilter(to time.Time) PostFilter

ReleaseDateBeforeFilter A Post filter that filters posts with release date before

func ReleaseDateFilter

func ReleaseDateFilter(from, to time.Time) PostFilter

ReleaseDateFilter A Post filter that filters posts with release date

type PostRaw

type PostRaw struct {
	Added       string      `json:"added"`
	Attachments []File      `json:"attachments"`
	Content     string      `json:"content"`
	Edited      string      `json:"edited"`
	Embed       interface{} `json:"embed"`
	File        File        `json:"file"`
	Id          string      `json:"id"`
	Published   string      `json:"published"`
	Service     string      `json:"service"`
	SharedFile  bool        `json:"shared_file"`
	Title       string      `json:"title"`
	User        string      `json:"user"`
}

func (PostRaw) ParasTime

func (p PostRaw) ParasTime() Post

type Timestamp added in v0.0.11

type Timestamp struct {
	Time time.Time
}

func (*Timestamp) UnmarshalJSON added in v0.0.11

func (t *Timestamp) UnmarshalJSON(b []byte) error

type User

type User struct {
	Service string `json:"service"`
	Id      string `json:"id"`
}

User a creator according to the service and id

func (User) GetID

func (u User) GetID() string

GetID get user id

func (User) GetService

func (u User) GetService() string

GetService get user Service

Jump to

Keyboard shortcuts

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