Documentation ¶
Overview ¶
Package letterboxd is the client for interacting with the http api
Index ¶
- Variables
- func BindDiaryFilterWithCobra(cmd *cobra.Command, opts DiaryCobraOpts)
- func DiaryFilterDateSpecified(e DiaryEntry, f DiaryFilterOpts) bool
- func DiaryFilterEarliest(e DiaryEntry, f DiaryFilterOpts) bool
- func DiaryFilterLatest(e DiaryEntry, f DiaryFilterOpts) bool
- func DiaryFilterMaxRating(e DiaryEntry, f DiaryFilterOpts) bool
- func DiaryFilterMinRating(e DiaryEntry, f DiaryFilterOpts) bool
- func DiaryFilterRewatch(e DiaryEntry, f DiaryFilterOpts) bool
- func GetFilmographyProfessions() []string
- func WithBaseURL(u string) func(*Client)
- func WithCache(cc *cache.Cache) func(*Client)
- func WithNoCache() func(*Client)
- type Client
- type ClientConfig
- type DiaryCobraOpts
- type DiaryEntries
- type DiaryEntry
- type DiaryFilter
- type DiaryFilterBulk
- type DiaryFilterOpts
- type ErrorResponse
- type ExternalFilmIDs
- type Film
- type FilmBatchOpts
- type FilmListOpts
- type FilmService
- type FilmServiceOp
- func (f *FilmServiceOp) EnhanceFilm(ctx context.Context, film *Film) error
- func (f *FilmServiceOp) EnhanceFilmList(ctx context.Context, films *FilmSet) error
- func (f *FilmServiceOp) ExtractEnhancedFilmsWithPath(ctx context.Context, path string) (FilmSet, *Pagination, error)
- func (f *FilmServiceOp) ExtractFilmsWithPath(ctx context.Context, path string) (FilmSet, *Pagination, error)
- func (f *FilmServiceOp) Filmography(ctx context.Context, opt *FilmographyOpt) (FilmSet, error)
- func (f *FilmServiceOp) Get(ctx context.Context, slug string) (*Film, error)
- func (f *FilmServiceOp) GetWatchedIMDBIDs(ctx context.Context, username string) ([]string, error)
- func (f *FilmServiceOp) List(ctx context.Context, opts *FilmListOpts) (FilmSet, error)
- func (f *FilmServiceOp) StreamBatch(ctx context.Context, batchOpts *FilmBatchOpts, filmsC chan *Film, ...)
- type FilmSet
- type FilmographyOpt
- type ListFilmsOpt
- type ListID
- type ListService
- type ListServiceOp
- type PageData
- type Pagination
- func ExtractPagination(r io.Reader) (*Pagination, error)
- func ExtractPaginationWithDoc(doc *goquery.Document) (*Pagination, error)
- func ExtractPeople(r io.Reader) (interface{}, *Pagination, error)
- func ExtractPeopleWithBytes(b []byte) (interface{}, *Pagination, error)
- func ExtractUser(r io.Reader) (interface{}, *Pagination, error)
- func ExtractUserFilms(r io.Reader) (interface{}, *Pagination, error)
- type Response
- type URLService
- type URLServiceOp
- type User
- type UserService
- type UserServiceOp
- func (u *UserServiceOp) Diary(ctx context.Context, username string) (DiaryEntries, error)
- func (u *UserServiceOp) Exists(ctx context.Context, userID string) (bool, error)
- func (u *UserServiceOp) ExtractDiaryEntries(r io.Reader) (interface{}, *Pagination, error)
- func (u *UserServiceOp) Followers(ctx context.Context, userID string) ([]string, *Response, error)
- func (u *UserServiceOp) Following(ctx context.Context, userID string) ([]string, *Response, error)
- func (u *UserServiceOp) MustDiary(ctx context.Context, username string) DiaryEntries
- func (u *UserServiceOp) Profile(ctx context.Context, userID string) (*User, *Response, error)
- func (u *UserServiceOp) StreamDiary(ctx context.Context, username string, dec chan *DiaryEntry, done chan error)
- func (u *UserServiceOp) StreamList(ctx context.Context, username string, slug string, rchan chan *Film, ...)
- func (u *UserServiceOp) StreamWatchList(ctx context.Context, username string, rchan chan *Film, done chan error)
- func (u *UserServiceOp) StreamWatched(ctx context.Context, userID string, rchan chan *Film, done chan error)
- func (u *UserServiceOp) WatchList(ctx context.Context, userID string) (FilmSet, *Response, error)
Constants ¶
This section is empty.
Variables ¶
var Professions = []string{"actor", "director", "producer", "writer"}
Professions is a string array of all the professions this module cares about
Functions ¶
func BindDiaryFilterWithCobra ¶ added in v0.1.25
func BindDiaryFilterWithCobra(cmd *cobra.Command, opts DiaryCobraOpts)
BindDiaryFilterWithCobra inits all the pieces in a given Cmd to allow for diary filters
func DiaryFilterDateSpecified ¶ added in v0.1.24
func DiaryFilterDateSpecified(e DiaryEntry, f DiaryFilterOpts) bool
DiaryFilterDateSpecified only returns items that actually list the date they were watched
func DiaryFilterEarliest ¶ added in v0.1.24
func DiaryFilterEarliest(e DiaryEntry, f DiaryFilterOpts) bool
DiaryFilterEarliest filters based on the earliest date
func DiaryFilterLatest ¶ added in v0.1.24
func DiaryFilterLatest(e DiaryEntry, f DiaryFilterOpts) bool
DiaryFilterLatest filters based on the latest date
func DiaryFilterMaxRating ¶ added in v0.2.0
func DiaryFilterMaxRating(e DiaryEntry, f DiaryFilterOpts) bool
DiaryFilterMaxRating filters based on maximum rating
func DiaryFilterMinRating ¶ added in v0.2.0
func DiaryFilterMinRating(e DiaryEntry, f DiaryFilterOpts) bool
DiaryFilterMinRating filters based on minimum rating
func DiaryFilterRewatch ¶ added in v0.1.24
func DiaryFilterRewatch(e DiaryEntry, f DiaryFilterOpts) bool
DiaryFilterRewatch only show entries that are re-watches
func GetFilmographyProfessions ¶
func GetFilmographyProfessions() []string
GetFilmographyProfessions is just a hard coded list of professions. Should this be a constant instead?
func WithBaseURL ¶ added in v0.2.2
WithBaseURL sets the url (Example: https://letterboxd.com) to use for scraping
func WithCache ¶ added in v0.2.2
func WithCache(cc *cache.Cache) func(*Client)
WithCache applies a given cache.Cache to the letterboxd library
func WithNoCache ¶ added in v0.2.2
func WithNoCache() func(*Client)
WithNoCache removes the default cache
Types ¶
type Client ¶
type Client struct { UserAgent string // Options MaxConcurrentPages int Cache *cache.Cache User UserService Film FilmService List ListService URL URLService // contains filtered or unexported fields }
Client represents the thing containing services and methods for interacting with Letterboxd
type ClientConfig ¶ added in v0.1.7
type ClientConfig struct { HTTPClient *http.Client BaseURL string MaxConcurrentPages int DisableCache bool RedisHost string RedisPassword string RedisDB int Cache *cache.Cache CacheTime *time.Duration // Maybe favor this instead of cache.Cache? RedisClient *redis.Client }
ClientConfig is the configuration strcut for the client
type DiaryCobraOpts ¶ added in v0.2.0
type DiaryCobraOpts struct {
Prefix string
}
DiaryCobraOpts allows customization of the options passed in to Cobra Cmd
type DiaryEntries ¶ added in v0.1.24
type DiaryEntries []*DiaryEntry
DiaryEntries is multiple DiaryEntry items
func ApplyDiaryFilters ¶ added in v0.1.24
func ApplyDiaryFilters(records DiaryEntries, opts DiaryFilterOpts, filters ...DiaryFilter) DiaryEntries
ApplyDiaryFilters applies all of the given filters to a given diary
func SlurpDiary ¶ added in v0.1.21
func SlurpDiary(itemC chan *DiaryEntry, doneC chan error) (DiaryEntries, error)
SlurpDiary is just a helper to quickly read in all Diary streams
type DiaryEntry ¶ added in v0.1.21
type DiaryEntry struct { Watched *time.Time Rating *int Rewatch bool SpecifiedDate bool Film *Film Slug *string }
DiaryEntry is a specific film from a users Diary
func NewDiaryEntry ¶ added in v0.2.2
func NewDiaryEntry(s *goquery.Selection) *DiaryEntry
NewDiaryEntry returns a new DiaryEntry with attributes for a goquery.Selection
type DiaryFilter ¶ added in v0.1.24
type DiaryFilter func(DiaryEntry, DiaryFilterOpts) bool
DiaryFilter is a generic function to filter diary entries
type DiaryFilterBulk ¶ added in v0.1.24
type DiaryFilterBulk func(DiaryEntries, DiaryFilterOpts) DiaryEntries
DiaryFilterBulk is a generic function to filter diary entries in bulk
type DiaryFilterOpts ¶ added in v0.1.24
type DiaryFilterOpts struct { Earliest *time.Time Latest *time.Time MinRating *int MaxRating *int Rewatch *bool SpecifiedDate *bool }
DiaryFilterOpts provides options for filtering a user diary
func DiaryFilterWithCobra ¶ added in v0.1.25
func DiaryFilterWithCobra(cmd *cobra.Command, dopts DiaryCobraOpts) (*DiaryFilterOpts, error)
DiaryFilterWithCobra returns a diary filter from a Cobra Cmd
type ErrorResponse ¶
type ErrorResponse struct {
Message string `json:"errors"`
}
ErrorResponse just contains the errors of a response
type ExternalFilmIDs ¶
ExternalFilmIDs references 3rd party IDs for a given film
type Film ¶
type Film struct { ID string `json:"id"` Title string `json:"title"` Slug string `json:"slug"` Target string `json:"target"` Year int `json:"year"` ExternalIDs *ExternalFilmIDs `json:"external_ids,omitempty"` }
Film represents a Letterboxd Film
type FilmBatchOpts ¶
type FilmBatchOpts struct { Watched []string `json:"watched"` List []*ListID `json:"list"` WatchList []string `json:"watchlist"` }
FilmBatchOpts provides options for retrieving a batch of films
type FilmListOpts ¶ added in v0.1.23
FilmListOpts options for listing films
type FilmService ¶
type FilmService interface { EnhanceFilm(context.Context, *Film) error EnhanceFilmList(context.Context, *FilmSet) error Filmography(context.Context, *FilmographyOpt) (FilmSet, error) Get(context.Context, string) (*Film, error) GetWatchedIMDBIDs(context.Context, string) ([]string, error) ExtractFilmsWithPath(context.Context, string) (FilmSet, *Pagination, error) ExtractEnhancedFilmsWithPath(context.Context, string) (FilmSet, *Pagination, error) StreamBatch(context.Context, *FilmBatchOpts, chan *Film, chan error) List(context.Context, *FilmListOpts) (FilmSet, error) }
FilmService defines a service to handle methods against Letterboxd films
type FilmServiceOp ¶
type FilmServiceOp struct {
// contains filtered or unexported fields
}
FilmServiceOp is the operator for a FilmService
func (*FilmServiceOp) EnhanceFilm ¶
func (f *FilmServiceOp) EnhanceFilm(ctx context.Context, film *Film) error
EnhanceFilm Given a film, with some minimal information (like the slug), get as much data as you can
func (*FilmServiceOp) EnhanceFilmList ¶
func (f *FilmServiceOp) EnhanceFilmList(ctx context.Context, films *FilmSet) error
EnhanceFilmList takes a list of films, and returns the enhanced version
func (*FilmServiceOp) ExtractEnhancedFilmsWithPath ¶
func (f *FilmServiceOp) ExtractEnhancedFilmsWithPath(ctx context.Context, path string) (FilmSet, *Pagination, error)
ExtractEnhancedFilmsWithPath returns a list of data enriched films from a URL path
func (*FilmServiceOp) ExtractFilmsWithPath ¶
func (f *FilmServiceOp) ExtractFilmsWithPath(ctx context.Context, path string) (FilmSet, *Pagination, error)
ExtractFilmsWithPath Given a url path, return a list of films it contains
func (*FilmServiceOp) Filmography ¶
func (f *FilmServiceOp) Filmography(ctx context.Context, opt *FilmographyOpt) (FilmSet, error)
Filmography returns the Filmography based on certain options
func (*FilmServiceOp) GetWatchedIMDBIDs ¶ added in v0.1.17
GetWatchedIMDBIDs returns a list of imdb ids that have been watched by a given user
func (*FilmServiceOp) List ¶ added in v0.1.23
func (f *FilmServiceOp) List(ctx context.Context, opts *FilmListOpts) (FilmSet, error)
List lists out all films using the given options
func (*FilmServiceOp) StreamBatch ¶
func (f *FilmServiceOp) StreamBatch(ctx context.Context, batchOpts *FilmBatchOpts, filmsC chan *Film, done chan error)
StreamBatch Get a bunch of different films at once and stream them back to the user
type FilmSet ¶ added in v0.1.23
type FilmSet []*Film
FilmSet is just a list of pointers to Film items
func SlurpFilms ¶ added in v0.1.9
SlurpFilms Helper blocking function to slurp a batch of films from the streaming calls. This negates the whole 'Streaming' thing, so use sparingly
type FilmographyOpt ¶
type FilmographyOpt struct { Person string // Person whos filmography is to be fetched Profession string // Profession of the person (actor, writer, director) }
FilmographyOpt is the options for a filmography
func (*FilmographyOpt) Validate ¶
func (f *FilmographyOpt) Validate() error
Validate ensures that filmography options contains the appropriate fields
type ListFilmsOpt ¶
type ListFilmsOpt struct { User string // Username of the user for the list. Example: 'dave' Slug string // Slug of the list: Example: 'official-top-250-narrative-feature-films' FirstPage int // First page to fetch. Defaults to 1 LastPage int // Last page to fetch. Defaults to FirstPage. Use -1 to fetch all pages }
ListFilmsOpt is the options for the ListFilms method
type ListID ¶
ListID is the base amount of info we need to find a list
func ParseListArgs ¶
ParseListArgs Given a slice of strings, return a slice of ListIDs
type ListService ¶
type ListService interface { GetOfficialMap(context.Context) map[string]string GetOfficial(context.Context) []*ListID }
ListService is the interface defining which methods we can use for List items
type ListServiceOp ¶
type ListServiceOp struct {
// contains filtered or unexported fields
}
ListServiceOp is the Operator for the ListService
func (*ListServiceOp) GetOfficial ¶ added in v0.1.20
func (l *ListServiceOp) GetOfficial(ctx context.Context) []*ListID
GetOfficial returns the official lists as a slice
func (*ListServiceOp) GetOfficialMap ¶ added in v0.1.20
func (l *ListServiceOp) GetOfficialMap(ctx context.Context) map[string]string
GetOfficialMap returns the official letterboxd lists using the slug as the key
type PageData ¶
type PageData struct { Data interface{} Pagination Pagination }
PageData just provides Pagination info and 'Data'
type Pagination ¶
type Pagination struct { CurrentPage int `json:"current_page"` NextPage int `json:"next_page"` TotalPages int `json:"total_pages"` TotalItems int `json:"total_items"` ItemsPerPage int `json:"items_per_page"` IsLast bool `json:"is_last"` }
Pagination contains all the information about a pages pagination
func ExtractPagination ¶ added in v0.2.3
func ExtractPagination(r io.Reader) (*Pagination, error)
ExtractPagination pulls the pagination from an io.Reader
func ExtractPaginationWithDoc ¶
func ExtractPaginationWithDoc(doc *goquery.Document) (*Pagination, error)
ExtractPaginationWithDoc returns a pagination object from a goquery Doc
func ExtractPeople ¶ added in v0.2.0
func ExtractPeople(r io.Reader) (interface{}, *Pagination, error)
ExtractPeople returns people from a given io.Reader
func ExtractPeopleWithBytes ¶ added in v0.2.0
func ExtractPeopleWithBytes(b []byte) (interface{}, *Pagination, error)
ExtractPeopleWithBytes returns people from a given byte array
func ExtractUser ¶
func ExtractUser(r io.Reader) (interface{}, *Pagination, error)
ExtractUser returns a user from a given io.Reader
func ExtractUserFilms ¶
func ExtractUserFilms(r io.Reader) (interface{}, *Pagination, error)
ExtractUserFilms returns a list of films from an io.Reader
func (*Pagination) SetTotalItems ¶ added in v0.2.1
func (p *Pagination) SetTotalItems(i int)
SetTotalItems will set the TotalItems count, along with anything else that needs an update based on the TotalItems
type URLService ¶
URLService is an interface for defining methods on a URL
type URLServiceOp ¶
type URLServiceOp struct {
// contains filtered or unexported fields
}
URLServiceOp is the operator for an URLService
type User ¶
type User struct { Username string `json:"username"` Bio string `json:"bio,omitempty"` WatchedFilmCount int `json:"watched_film_count"` Following []string `json:"following"` Followers []string `json:"followers"` }
User represents a Letterboxd user
type UserService ¶
type UserService interface { Exists(context.Context, string) (bool, error) Profile(context.Context, string) (*User, *Response, error) Following(context.Context, string) ([]string, *Response, error) Followers(context.Context, string) ([]string, *Response, error) // Interact with Diary StreamDiary(context.Context, string, chan *DiaryEntry, chan error) Diary(context.Context, string) (DiaryEntries, error) MustDiary(context.Context, string) DiaryEntries StreamList(context.Context, string, string, chan *Film, chan error) StreamWatched(context.Context, string, chan *Film, chan error) StreamWatchList(context.Context, string, chan *Film, chan error) WatchList(context.Context, string) (FilmSet, *Response, error) ExtractDiaryEntries(io.Reader) (interface{}, *Pagination, error) }
UserService provides an interface to user methods
type UserServiceOp ¶
type UserServiceOp struct {
// contains filtered or unexported fields
}
UserServiceOp is the operator for the UserService
func (*UserServiceOp) Diary ¶ added in v0.1.24
func (u *UserServiceOp) Diary(ctx context.Context, username string) (DiaryEntries, error)
Diary returns all diary entries for a given order, sorted by watched date, with the most recent watches first
func (*UserServiceOp) ExtractDiaryEntries ¶ added in v0.1.21
func (u *UserServiceOp) ExtractDiaryEntries(r io.Reader) (interface{}, *Pagination, error)
ExtractDiaryEntries returns a list of DiaryEntries
func (*UserServiceOp) Followers ¶ added in v0.2.1
Followers returns a list of users a given id is following
func (*UserServiceOp) Following ¶ added in v0.2.0
Following returns a list of users following a given user
func (*UserServiceOp) MustDiary ¶ added in v0.1.24
func (u *UserServiceOp) MustDiary(ctx context.Context, username string) DiaryEntries
MustDiary See GetDiary, but will panic instead of returning an error
func (*UserServiceOp) StreamDiary ¶ added in v0.1.21
func (u *UserServiceOp) StreamDiary(ctx context.Context, username string, dec chan *DiaryEntry, done chan error)
StreamDiary streams a users diary in to the given channels
func (*UserServiceOp) StreamList ¶ added in v0.1.3
func (u *UserServiceOp) StreamList( ctx context.Context, username string, slug string, rchan chan *Film, done chan error, )
StreamList streams a list back through channels
func (*UserServiceOp) StreamWatchList ¶ added in v0.1.2
func (u *UserServiceOp) StreamWatchList( ctx context.Context, username string, rchan chan *Film, done chan error, )
StreamWatchList streams a WatchList back to channels
func (*UserServiceOp) StreamWatched ¶
func (u *UserServiceOp) StreamWatched(ctx context.Context, userID string, rchan chan *Film, done chan error)
StreamWatched streams a given list of Watched films