inital commit

This commit is contained in:
2026-05-26 20:21:55 +02:00
parent 965f9d6ad4
commit 0ae20aa68d
21 changed files with 651 additions and 111 deletions

View File

@@ -22,7 +22,7 @@ type Journal struct {
}
// GetJournal fetches a journal entry by its numeric ID.
func (c *Client) GetJournal(ctx context.Context, id JournalID) (*Journal, error) {
func (c *Client) GetJournal(ctx context.Context, id JournalID, opts ...Option) (*Journal, error) {
if id <= 0 {
return nil, fmt.Errorf("fa: GetJournal: id must be > 0")
}
@@ -34,7 +34,7 @@ func (c *Client) GetJournal(ctx context.Context, id JournalID) (*Journal, error)
}
out = j
return nil
})
}, opts...)
if err != nil {
return nil, err
}
@@ -45,7 +45,7 @@ func (c *Client) GetJournal(ctx context.Context, id JournalID) (*Journal, error)
// each [Journal] preview (full body included on FA's listing page).
//
// Use [ListOptions.MaxPages] to bound the crawl.
func (c *Client) UserJournals(ctx context.Context, name string, opts ListOptions) iter.Seq2[*Journal, error] {
func (c *Client) UserJournals(ctx context.Context, name string, opts ListOptions, reqOpts ...Option) iter.Seq2[*Journal, error] {
return func(yield func(*Journal, error) bool) {
page := opts.firstPage()
pagesFetched := 0
@@ -60,7 +60,7 @@ func (c *Client) UserJournals(ctx context.Context, name string, opts ListOptions
err := c.fetch(ctx, urls.UserJournals(name, page), func(doc *goquery.Document) error {
items, hasNext = parseUserJournalsPage(doc)
return nil
})
}, reqOpts...)
if err != nil {
yield(nil, err)
return