Documentation
¶
Index ¶
- func CountComments(comments []*Comment) int
- func FetchFullPostIndex(ctx context.Context, client *Client, user string) ([]int, error)
- func FetchPostIndex(ctx context.Context, client *Client, user string) ([]int, error)
- func FindFirstPostID(ctx context.Context, client *Client, user string) (int, error)
- func FindLastPostID(ctx context.Context, client *Client, user string) (int, error)
- func HTMLToMarkdown(html string) string
- func ParseDate(s string) time.Time
- func ParseJournal(ctx context.Context, client *Client, user string, comments bool, ...) error
- func ParseJournalIndex(body io.Reader) ([]int, error)
- func ParsePostURL(rawURL string) (user string, id int, err error)
- func ParseProfileStats(ctx context.Context, client *Client, user string) (int, error)
- type Client
- type Comment
- type OGMeta
- type Post
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CountComments ¶ added in v0.2.1
CountComments returns the total number of comments in a tree (including nested children).
func FetchFullPostIndex ¶ added in v0.2.0
FetchFullPostIndex returns all post IDs by iterating monthly archive pages. This catches old posts that FetchPostIndex misses due to LJ index page limits.
func FetchPostIndex ¶
FetchPostIndex returns all post LJ IDs in chronological order (oldest first).
func FindFirstPostID ¶
FindFirstPostID returns the ID of the oldest post in the journal. Uses exponential search + binary search on post URLs.
func FindLastPostID ¶
FindLastPostID returns the ID of the newest post in the journal.
func HTMLToMarkdown ¶
HTMLToMarkdown converts HTML to Markdown. Handles the subset of HTML found in LiveJournal posts: p, br, b/strong, i/em, a, img, blockquote, ul/ol/li, h1-h6.
func ParseJournal ¶
func ParseJournal(ctx context.Context, client *Client, user string, comments bool, onPost func(*Post) error) error
ParseJournal fetches all posts from a journal, calling onPost for each.
func ParseJournalIndex ¶
ParseJournalIndex extracts post IDs from a journal index page HTML.
Types ¶
type Client ¶
type Client struct {
Log func(format string, args ...any) // progress logger, nil = silent
BodyFormat string // "html" (default), "markdown", "text"
ImagesDir string // download images to this dir, empty = skip
SkipIDs map[int]bool // skip these post IDs (for resume)
// contains filtered or unexported fields
}
func (*Client) DownloadFile ¶
DownloadFile downloads a URL to a local file. Skips if file already exists.
type Comment ¶
type Comment struct {
ID int `json:"id"`
TalkID int `json:"talk_id"`
ParentID int `json:"parent_id"`
Level int `json:"level"`
Author string `json:"author"`
Username string `json:"username"`
Date string `json:"date"`
DateUnix int64 `json:"date_unix"`
Body string `json:"body"`
Subject string `json:"subject,omitempty"`
Userpic string `json:"userpic,omitempty"`
Deleted bool `json:"deleted,omitempty"`
Children []*Comment `json:"children,omitempty"`
}
func BuildCommentTree ¶
type Post ¶
type Post struct {
ID int `json:"id"`
URL string `json:"url"`
Title string `json:"title"`
Date string `json:"date"`
DateUnix int64 `json:"date_unix,omitempty"`
Author string `json:"author"`
Body string `json:"body"`
Tags []string `json:"tags,omitempty"`
OG *OGMeta `json:"og,omitempty"`
Comments []*Comment `json:"comments,omitempty"`
}