fourchan

package
v0.0.0-...-b2f97d1 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2020 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BIZCatalogURL    = "https://a.4cdn.org/biz/catalog.json"
	BIZThreadLinkURL = "https://boards.4channel.org/biz/thread"
)
View Source
const (
	ThreadsCSVFile = "threads.csv"
	CSVSeparator   = '|'
)

Variables

This section is empty.

Functions

func BuildLink(id int, replyId int) string

func GetKeywords

func GetKeywords() []string

GetKeywords func returns the mandatory keywords defined from config

func PeriodicCheck

func PeriodicCheck(cfg common.Config)

PeriodicCheck will request the 4chan API regularly for latest posts

func Process

func Process(config common.Config) error

Process func reads local csv file as a base for old files and requests the 4chan API for new entries. Completely new thread IDs will be treated as new found threads and for same thread IDs the last timestamp will be used to determine if an update (thread reply) occurred.

Types

type APIThread

type APIThread struct {
	No            int         `json:"no"`
	Sticky        int         `json:"sticky,omitempty"`
	Closed        int         `json:"closed,omitempty"`
	Now           string      `json:"now"`
	Name          string      `json:"name"`
	Sub           string      `json:"sub,omitempty"`
	Com           string      `json:"com,omitempty"`
	Filename      string      `json:"filename"`
	Ext           string      `json:"ext"`
	W             int         `json:"w"`
	H             int         `json:"h"`
	TnW           int         `json:"tn_w"`
	TnH           int         `json:"tn_h"`
	Tim           int64       `json:"tim"`
	Time          int         `json:"time"`
	Md5           string      `json:"md5"`
	Fsize         int         `json:"fsize"`
	Resto         int         `json:"resto"`
	ID            string      `json:"id"`
	Capcode       string      `json:"capcode,omitempty"`
	SemanticURL   string      `json:"semantic_url"`
	Replies       int         `json:"replies"`
	Images        int         `json:"images"`
	LastModified  int         `json:"last_modified"`
	Bumplimit     int         `json:"bumplimit,omitempty"`
	Imagelimit    int         `json:"imagelimit,omitempty"`
	OmittedPosts  int         `json:"omitted_posts,omitempty"`
	OmittedImages int         `json:"omitted_images,omitempty"`
	LastReplies   []LastReply `json:"last_replies,omitempty"`
}

type CatalogPageItems

type CatalogPageItems struct {
	Page    int         `json:"page"`
	Threads []APIThread `json:"threads"`
}

type CatalogResponse

type CatalogResponse []CatalogPageItems

type Client

type Client struct {
	BaseURL string
	// contains filtered or unexported fields
}

func NewClient

func NewClient() *Client

func (*Client) GetCatalog

func (c *Client) GetCatalog() (*[]CatalogPageItems, error)

type LastReply

type LastReply struct {
	No       int    `json:"no"`
	Now      string `json:"now"`
	Name     string `json:"name"`
	Com      string `json:"com"`
	Time     int    `json:"time"`
	Resto    int    `json:"resto"`
	ID       string `json:"id"`
	Filename string `json:"filename,omitempty"`
	Ext      string `json:"ext,omitempty"`
	W        int    `json:"w,omitempty"`
	H        int    `json:"h,omitempty"`
	TnW      int    `json:"tn_w,omitempty"`
	TnH      int    `json:"tn_h,omitempty"`
	Tim      int64  `json:"tim,omitempty"`
	Md5      string `json:"md5,omitempty"`
	Fsize    int    `json:"fsize,omitempty"`
}

type Thread

type Thread struct {
	Id                 int    `csv:"id"`
	Timestamp          int    `csv:"timestamp"`
	Subject            string `csv:"subject"`
	Author             string `csv:"author"`
	Content            string `csv:"content"`
	Replies            int    `csv:"replies"`
	Images             int    `csv:"images"`
	LastReplyId        int    `csv:"last_reply_id"`
	LastReplyTimestamp int    `csv:"last_reply_time"`
	LastReplyAuthor    string `csv:"last_reply_author"`
	LastReplyContent   string `csv:"last_reply"`
}

func APIThreadToCSVThreads

func APIThreadToCSVThreads(apiThreads []APIThread) []Thread

func GetLatestThreads

func GetLatestThreads() ([]Thread, error)

Jump to

Keyboard shortcuts

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