Documentation
¶
Index ¶
- Constants
- Variables
- func ExtractWorkID(urlStr string) int
- func FormatString(s string) string
- func ParseDocument(content []byte) (*goquery.Document, error)
- func SetRateLimiting(enable bool)
- func URLJoin(base string, parts ...string) string
- func WithAnyField(value string) func(*Search)
- func WithAuthor(value string) func(*Search)
- func WithBookmarks(constraint *Constraint) func(*Search)
- func WithCharacters(value string) func(*Search)
- func WithComments(constraint *Constraint) func(*Search)
- func WithCompletionStatus(value bool) func(*Search)
- func WithCrossovers(value bool) func(*Search)
- func WithExcludedTags(value string) func(*Search)
- func WithFandoms(value string) func(*Search)
- func WithHits(constraint *Constraint) func(*Search)
- func WithKudos(constraint *Constraint) func(*Search)
- func WithLanguage(value string) func(*Search)
- func WithPage(value int) func(*Search)
- func WithRating(value int) func(*Search)
- func WithRelationships(value string) func(*Search)
- func WithRevisedAt(value string) func(*Search)
- func WithSession(session *Session) func(*Search)
- func WithSingleChapter(value bool) func(*Search)
- func WithSortColumn(value string) func(*Search)
- func WithSortDirection(value string) func(*Search)
- func WithTags(value string) func(*Search)
- func WithTitle(value string) func(*Search)
- func WithWordCount(constraint *Constraint) func(*Search)
- func WordCount(text string) int
- func WorkIDFromURL(urlStr string) (int, error)
- type Chapter
- func (c *Chapter) Comment(commentText, email, name string, pseud *string) (*resty.Response, error)
- func (c *Chapter) GetComments(maximum *int) ([]*Comment, error)
- func (c *Chapter) GetImages() ([]ImageInfo, error)
- func (c *Chapter) GetText() (string, error)
- func (c *Chapter) GetURL() string
- func (c *Chapter) GetWork() *Work
- func (c *Chapter) IsLoaded() bool
- func (c *Chapter) Reload() error
- func (c *Chapter) SetSession(session *Session)
- func (c *Chapter) String() string
- type Comment
- func (c *Comment) Delete() error
- func (c *Comment) GetThread() ([]*Comment, error)
- func (c *Comment) IsLoaded() bool
- func (c *Comment) Reload() error
- func (c *Comment) Reply(commentText, email, name string, pseud *string) (*resty.Response, error)
- func (c *Comment) SetSession(session *Session)
- func (c *Comment) String() string
- type Constraint
- type GuestSession
- func (s *GuestSession) Comment(commentable interface{}, commentText string, oneshot bool, commentID *int, ...) (*resty.Response, error)
- func (s *GuestSession) Get(url string) (*resty.Response, error)
- func (s *GuestSession) Kudos(work *Work) (bool, error)
- func (s *GuestSession) Post(url string, data url.Values) (*resty.Response, error)
- func (s *GuestSession) RefreshAuthToken() error
- func (s *GuestSession) Request(url string) (*goquery.Document, error)
- type ImageInfo
- type Query
- type Requester
- type Search
- type Series
- func (s *Series) Bookmark(notes string, tags, collections []string, private, recommend bool, ...) error
- func (s *Series) IsLoaded() bool
- func (s *Series) Reload() error
- func (s *Series) SetSession(session *Session)
- func (s *Series) String() string
- func (s *Series) Subscribe() error
- func (s *Series) Unsubscribe() error
- type Session
- func (s *Session) ClearCache()
- func (s *Session) GetBookmarkCount() (int, error)
- func (s *Session) GetBookmarkPages() (int, error)
- func (s *Session) GetBookmarks(useThreading bool) ([]*Work, error)
- func (s *Session) GetMarkedForLater(sleep time.Duration, timeoutSleep time.Duration) ([]*Work, error)
- func (s *Session) GetSeriesSubscriptions(useThreading bool) ([]*Series, error)
- func (s *Session) GetStatistics(year *int) (map[string]int, error)
- func (s *Session) GetSubscriptions(useThreading bool) ([]interface{}, error)
- func (s *Session) GetUser() *User
- func (s *Session) GetUserSubscriptions(useThreading bool) ([]*User, error)
- func (s *Session) GetWorkSubscriptions(useThreading bool) ([]*Work, error)
- type SessionInterface
- type SimpleWorkInfo
- type User
- type Work
- func (w *Work) Bookmark(notes string, tags, collections []string, private, recommend bool, ...) error
- func (w *Work) Collect(collections []string) error
- func (w *Work) Comment(commentText, email, name string, pseud *string) (*resty.Response, error)
- func (w *Work) DeleteBookmark() error
- func (w *Work) Download(filetype string) ([]byte, error)
- func (w *Work) DownloadToFile(filename string, filetype string) error
- func (w *Work) GetComments(maximum *int) ([]*Comment, error)
- func (w *Work) GetImages() (map[int][]ImageInfo, error)
- func (w *Work) GetMetadata() map[string]interface{}
- func (w *Work) GetText() (string, error)
- func (w *Work) GetURL() string
- func (w *Work) IsLoaded() bool
- func (w *Work) IsOneshot() bool
- func (w *Work) LeaveKudos() (bool, error)
- func (w *Work) LoadChapters() error
- func (w *Work) Reload(loadChapters bool) error
- func (w *Work) SetSession(session *Session)
- func (w *Work) String() string
- func (w *Work) Subscribe() error
- func (w *Work) Unsubscribe() error
Constants ¶
const ( SortBestMatch = "_score" SortAuthor = "authors_to_sort_on" SortTitle = "title_to_sort_on" SortDatePosted = "created_at" SortDateUpdated = "revised_at" SortWordCount = "word_count" SortRating = "rating_ids" SortHits = "hits" SortBookmarks = "bookmarks_count" SortComments = "comments_count" SortKudos = "kudos_count" SortDirectionDescending = "desc" SortDirectionAscending = "asc" )
Constants for sorting
const VERSION = "1.0.0"
VERSION is the current version of the AO3 API
Variables ¶
var ( ErrLogin = errors.New("login error") ErrUnloaded = errors.New("unloaded error") ErrUnexpectedResponse = errors.New("unexpected response error") ErrInvalidID = errors.New("invalid ID error") ErrDownload = errors.New("download error") ErrAuth = errors.New("authentication error") ErrDuplicateComment = errors.New("duplicate comment error") ErrPseud = errors.New("pseud error") ErrHTTP = errors.New("HTTP error") ErrBookmark = errors.New("bookmark error") ErrCollect = errors.New("collect error") )
Error types
var DefaultRequester = NewRequester()
Global requester instance
Functions ¶
func ExtractWorkID ¶
ExtractWorkID extracts the work ID from an AO3 URL using regex This is a simpler alternative to WorkIDFromURL
func FormatString ¶
FormatString formats a string by removing commas
func ParseDocument ¶
ParseDocument parses HTML content into a goquery document
func SetRateLimiting ¶
func SetRateLimiting(enable bool)
SetRateLimiting enables or disables rate limiting
func WithAnyField ¶
WithAnyField sets the any_field search parameter
func WithAuthor ¶
WithAuthor sets the author search parameter
func WithBookmarks ¶
func WithBookmarks(constraint *Constraint) func(*Search)
WithBookmarks sets the bookmarks search parameter
func WithCharacters ¶
WithCharacters sets the characters search parameter
func WithComments ¶
func WithComments(constraint *Constraint) func(*Search)
WithComments sets the comments search parameter
func WithCompletionStatus ¶
WithCompletionStatus sets the completion_status search parameter
func WithCrossovers ¶
WithCrossovers sets the crossovers search parameter
func WithExcludedTags ¶
WithExcludedTags sets the excluded_tags search parameter
func WithFandoms ¶
WithFandoms sets the fandoms search parameter
func WithHits ¶
func WithHits(constraint *Constraint) func(*Search)
WithHits sets the hits search parameter
func WithKudos ¶
func WithKudos(constraint *Constraint) func(*Search)
WithKudos sets the kudos search parameter
func WithLanguage ¶
WithLanguage sets the language search parameter
func WithRating ¶
WithRating sets the rating search parameter
func WithRelationships ¶
WithRelationships sets the relationships search parameter
func WithRevisedAt ¶
WithRevisedAt sets the revised_at search parameter
func WithSession ¶
WithSession sets the session for the search
func WithSingleChapter ¶
WithSingleChapter sets the single_chapter search parameter
func WithSortColumn ¶
WithSortColumn sets the sort_column search parameter
func WithSortDirection ¶
WithSortDirection sets the sort_direction search parameter
func WithWordCount ¶
func WithWordCount(constraint *Constraint) func(*Search)
WithWordCount sets the word_count search parameter
func WorkIDFromURL ¶
WorkIDFromURL extracts the work ID from an AO3 URL (supports both full and relative URLs)
Types ¶
type Chapter ¶
type Chapter struct {
ID int
Title string
Number int
Words int
Summary string
StartNotes string
EndNotes string
AuthenticityToken string
// contains filtered or unexported fields
}
Chapter represents an AO3 chapter
func NewChapter ¶
NewChapter creates a new Chapter object
func (*Chapter) GetComments ¶
GetComments returns a list of all threads of comments in the chapter
func (*Chapter) SetSession ¶
SetSession sets the session used to make requests for this chapter
type Comment ¶
type Comment struct {
ID int
Text string
Author *User
AuthenticityToken string
// contains filtered or unexported fields
}
Comment represents an AO3 comment
func NewComment ¶
NewComment creates a new Comment object
func (*Comment) SetSession ¶
SetSession sets the session used to make requests for this comment
type Constraint ¶
Constraint represents a numeric constraint (e.g., for word count)
func NewConstraint ¶
func NewConstraint(lowerBound int, upperBound *int) Constraint
NewConstraint creates a new constraint
func (Constraint) String ¶
func (c Constraint) String() string
String returns the string representation of the constraint
type GuestSession ¶
type GuestSession struct {
IsAuthed bool
AuthenticityToken string
Username string
// contains filtered or unexported fields
}
GuestSession represents an unauthenticated AO3 session
func NewGuestSession ¶
func NewGuestSession() *GuestSession
NewGuestSession creates a new guest session
func (*GuestSession) Comment ¶
func (s *GuestSession) Comment(commentable interface{}, commentText string, oneshot bool, commentID *int, email, name string) (*resty.Response, error)
Comment leaves a comment on a specific work or chapter
func (*GuestSession) Get ¶
func (s *GuestSession) Get(url string) (*resty.Response, error)
Get makes a GET request
func (*GuestSession) Kudos ¶
func (s *GuestSession) Kudos(work *Work) (bool, error)
Kudos leaves kudos on a work
func (*GuestSession) RefreshAuthToken ¶
func (s *GuestSession) RefreshAuthToken() error
RefreshAuthToken refreshes the authenticity token
type Requester ¶
type Requester struct {
// contains filtered or unexported fields
}
Requester handles HTTP requests with rate limiting
func NewRequester ¶
func NewRequester() *Requester
NewRequester creates a new Requester with default settings
func (*Requester) Request ¶
func (r *Requester) Request(method, url string, cookies []*http.Cookie, headers map[string]string) (*resty.Response, error)
Request makes an HTTP request with rate limiting
func (*Requester) SetRequestsPerTimeWindow ¶
SetRequestsPerTimeWindow sets the maximum number of requests per time window
func (*Requester) SetTimeWindow ¶
SetTimeWindow sets the time window for rate limiting
type Search ¶
type Search struct {
AnyField string
Title string
Author string
SingleChapter bool
WordCount *Constraint
Language string
Fandoms string
Characters string
Relationships string
Tags string
Rating *int
Hits *Constraint
Kudos *Constraint
Crossovers *bool
Bookmarks *Constraint
ExcludedTags string
Comments *Constraint
CompletionStatus *bool
Page int
SortColumn string
SortDirection string
RevisedAt string
Results []*Work
TotalResults int
Pages int
// contains filtered or unexported fields
}
Search represents an AO3 search
func (*Search) FetchPages ¶
FetchPages fetches multiple pages of search results and returns all works
type Series ¶
type Series struct {
ID int
Name string
URL string
Description string
WorkList []*Work
Authors []*User
AuthenticityToken string
SubscriptionID *int
IsSubscribed bool
// contains filtered or unexported fields
}
Series represents an AO3 series
func (*Series) Bookmark ¶
func (s *Series) Bookmark(notes string, tags, collections []string, private, recommend bool, pseud *string) error
Bookmark bookmarks this series
func (*Series) SetSession ¶
SetSession sets the session used to make requests for this series
func (*Series) Unsubscribe ¶
Unsubscribe unsubscribes from this series
type Session ¶
type Session struct {
GuestSession
// contains filtered or unexported fields
}
Session represents an authenticated AO3 session
func NewSession ¶
NewSession creates a new authenticated session
func (*Session) GetBookmarkCount ¶
GetBookmarkCount returns the number of bookmarks
func (*Session) GetBookmarkPages ¶
GetBookmarkPages returns the number of bookmark pages
func (*Session) GetBookmarks ¶
GetBookmarks returns all bookmarks
func (*Session) GetMarkedForLater ¶
func (s *Session) GetMarkedForLater(sleep time.Duration, timeoutSleep time.Duration) ([]*Work, error)
GetMarkedForLater returns works marked for later
func (*Session) GetSeriesSubscriptions ¶
GetSeriesSubscriptions returns the series subscriptions
func (*Session) GetStatistics ¶
GetStatistics returns user statistics
func (*Session) GetSubscriptions ¶
GetSubscriptions returns all subscriptions
func (*Session) GetUserSubscriptions ¶
GetUserSubscriptions returns the user subscriptions
type SessionInterface ¶
type SessionInterface interface {
Request(url string) (*goquery.Document, error)
Get(url string) (*resty.Response, error)
}
SessionInterface defines the common methods between Session and GuestSession
func GetSessionInterface ¶
func GetSessionInterface(session interface{}) SessionInterface
GetSessionInterface returns a SessionInterface from either a Session or GuestSession
type SimpleWorkInfo ¶
type SimpleWorkInfo struct {
ID int
Title string
Author string
Chapters int
Words int
Kudos int
Hits int
Summary string
Fandoms []string
Tags []string
}
SimpleWorkInfo represents basic information about an AO3 work
func GetSimpleWorkInfo ¶
func GetSimpleWorkInfo(workID int) (*SimpleWorkInfo, error)
GetSimpleWorkInfo gets basic information about a work without using the full Work struct
type User ¶
type User struct {
Username string
URL string
Bio string
Works int
AuthenticityToken string
SubscriptionID *int
IsSubscribed bool
// contains filtered or unexported fields
}
User represents an AO3 user
func (*User) SetSession ¶
SetSession sets the session used to make requests for this user
func (*User) Unsubscribe ¶
Unsubscribe unsubscribes from this user
type Work ¶
type Work struct {
ID int
Title string
Authors []*User
Chapters []*Chapter
Series []*Series
Nchapters int
ExpectedChapters *int
Hits int
Kudos int
Comments int
Bookmarks int
Words int
Language string
Restricted bool
Complete bool
DatePublished time.Time
DateEdited time.Time
DateUpdated time.Time
Tags []string
Characters []string
Relationships []string
Fandoms []string
Categories []string
Warnings []string
Rating string
Summary string
StartNotes string
EndNotes string
Collections []string
Recommended bool
BookmarkID *int
AuthenticityToken string
SubscriptionID *int
IsSubscribed bool
// contains filtered or unexported fields
}
Work represents an AO3 work
func (*Work) Bookmark ¶
func (w *Work) Bookmark(notes string, tags, collections []string, private, recommend bool, pseud *string) error
Bookmark bookmarks this work
func (*Work) DeleteBookmark ¶
DeleteBookmark removes a bookmark from this work
func (*Work) DownloadToFile ¶
DownloadToFile downloads this work and saves it to a file
func (*Work) GetComments ¶
GetComments returns a list of all threads of comments in the work
func (*Work) GetMetadata ¶
GetMetadata returns a map of all work metadata
func (*Work) LeaveKudos ¶
LeaveKudos leaves kudos on this work
func (*Work) LoadChapters ¶
LoadChapters loads chapter objects for each chapter in the work
func (*Work) SetSession ¶
SetSession sets the session used to make requests for this work
func (*Work) Unsubscribe ¶
Unsubscribe unsubscribes from this work