Documentation
¶
Index ¶
- Constants
- type BaseEpisode
- type Client
- func (c *Client) OAuth(redirectURI string) *OAuthService
- func (c *Client) Scrobble() *ScrobbleService
- func (c *Client) Search() *SearchService
- func (c *Client) Show(showID uint64) *ShowService
- func (c *Client) Sync() *SyncService
- func (c *Client) User(userID string) *UserService
- func (c *Client) Users() *UsersService
- type ClientConfig
- type Episode
- type Error
- type GetAccessTokenResponse
- type HTTPClient
- type HistoryItem
- type Item
- type ItemIDs
- type ItemType
- type Key
- type LastActivities
- type Movie
- type OAuthService
- type RefreshTokenResponse
- type ScrobbleItem
- type ScrobbleService
- func (s *ScrobbleService) Pause(ctx context.Context, item *Item, progress float64) (*ScrobbleItem, error)
- func (s *ScrobbleService) Start(ctx context.Context, item *Item, progress float64) (*ScrobbleItem, error)
- func (s *ScrobbleService) Stop(ctx context.Context, item *Item, progress float64) (*ScrobbleItem, error)
- type SearchService
- type Season
- type ServiceType
- type Show
- type ShowSeasonEpisodeService
- type ShowSeasonService
- type ShowSeasonsService
- type ShowService
- type SyncService
- func (s *SyncService) AddHistory(ctx context.Context, item *Item, watchedAt time.Time) (bool, error)
- func (s *SyncService) GetHistory(ctx context.Context, itemType ItemType, itemID uint64) ([]*HistoryItem, error)
- func (s *SyncService) GetHistoryAll(ctx context.Context, itemType ItemType) ([]*HistoryItem, error)
- func (s *SyncService) GetLastActivities(ctx context.Context) (*LastActivities, error)
- func (s *SyncService) GetWatched(ctx context.Context, itemType ItemType, seasons bool) ([]*Watched, error)
- func (s *SyncService) GetWatchlist(ctx context.Context, itemType ItemType, sort WatchlistSortBy) ([]*WatchlistItem, error)
- func (s *SyncService) RemoveHistory(ctx context.Context, historyID uint64) (bool, error)
- type UserListService
- type UserService
- type UserSettings
- type UsersService
- type Watched
- type WatchlistItem
- type WatchlistSortBy
Constants ¶
const Version = "0.1.0"
Version of go-trakt.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseEpisode ¶
type BaseEpisode struct { Season uint16 `json:"season"` Number uint16 `json:"number"` Title string `json:"title"` IDs ItemIDs `json:"ids"` }
BaseEpisode represents the base set of fields for an episode.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps connection parameters for the Trakt.tv API.
func NewClient ¶
func NewClient(options ClientConfig) *Client
NewClient returns new Trakt.tv client.
func (*Client) OAuth ¶
func (c *Client) OAuth(redirectURI string) *OAuthService
OAuth creates a new OAuthService.
func (*Client) Scrobble ¶
func (c *Client) Scrobble() *ScrobbleService
Scrobble creates a new ScrobbleService.
func (*Client) Search ¶
func (c *Client) Search() *SearchService
Search creates a new SearchService.
func (*Client) Show ¶
func (c *Client) Show(showID uint64) *ShowService
Show creates a new ShowService.
func (*Client) User ¶
func (c *Client) User(userID string) *UserService
User creates a new UserService.
type ClientConfig ¶
ClientConfig contains auth and connection details for the Trakt.tv API.
type Episode ¶
type Episode struct { BaseEpisode FirstAired time.Time `json:"first_aired"` }
Episode represents an episode.
type Error ¶
type GetAccessTokenResponse ¶
type GetAccessTokenResponse struct { Error string `json:"error"` ErrorDescription string `json:"error_description"` AccessToken string `json:"access_token"` TokenType string `json:"token_type"` ExpiresIn uint64 `json:"expires_in"` RefreshToken string `json:"refresh_token"` Scope string `json:"scope"` CreatedAt uint64 `json:"created_at"` }
GetAccessTokenResponse response for a access token request.
type HTTPClient ¶
HTTPClient is a subset of the http.Client interface defining only the methods required.
type HistoryItem ¶
type HistoryItem struct { Item ID uint64 `json:"id"` WatchedAt time.Time `json:"watched_at"` Action string `json:"action"` }
HistoryItem a movie, show, season or episode from watch histroy.
type Item ¶
type Item struct { Type ItemType `json:"type"` Movie Movie `json:"movie"` Show Show `json:"show"` Season Season `json:"season"` Episode Episode `json:"episode"` }
Item a movie, show, episode, person or list.
type LastActivities ¶
type LastActivities struct { All time.Time `json:"all"` Movies struct { WatchedAt time.Time `json:"watched_at"` CollectedAt time.Time `json:"collected_at"` RatedAt time.Time `json:"rated_at"` WatchlistedAt time.Time `json:"watchlisted_at"` RecommendationsAt time.Time `json:"recommendations_at"` CommentedAt time.Time `json:"commented_at"` PausedAt time.Time `json:"paused_at"` HiddenAt time.Time `json:"hidden_at"` } `json:"movies"` Episodes struct { WatchedAt time.Time `json:"watched_at"` CollectedAt time.Time `json:"collected_at"` RatedAt time.Time `json:"rated_at"` WatchlistedAt time.Time `json:"watchlisted_at"` CommentedAt time.Time `json:"commented_at"` PausedAt time.Time `json:"paused_at"` } `json:"episodes"` Shows struct { RatedAt time.Time `json:"rated_at"` WatchlistedAt time.Time `json:"watchlisted_at"` RecommendationsAt time.Time `json:"recommendations_at"` CommentedAt time.Time `json:"commented_at"` HiddenAt time.Time `json:"hidden_at"` } `json:"shows"` Seasons struct { RatedAt time.Time `json:"rated_at"` WatchlistedAt time.Time `json:"watchlisted_at"` CommentedAt time.Time `json:"commented_at"` HiddenAt time.Time `json:"hidden_at"` } `json:"seasons"` Comments struct { LikedAt time.Time `json:"liked_at"` BlockedAt time.Time `json:"blocked_at"` } `json:"comments"` Lists struct { LikedAt time.Time `json:"liked_at"` UpdatedAt time.Time `json:"updated_at"` CommentedAt time.Time `json:"commented_at"` } `json:"lists"` Watchlist struct { UpdatedAt time.Time `json:"updated_at"` } `json:"watchlist"` Recommendations struct { UpdatedAt time.Time `json:"updated_at"` } `json:"recommendations"` Account struct { SettingsAt time.Time `json:"settings_at"` FollowedAt time.Time `json:"followed_at"` FollowingAt time.Time `json:"following_at"` PendingAt time.Time `json:"pending_at"` RequestedAt time.Time `json:"requested_at"` } `json:"account"` SavedFilters struct { UpdatedAt time.Time `json:"updated_at"` } `json:"saved_filters"` }
LastActivities represents the last activity of a user.
type Movie ¶
type Movie struct { Title string `json:"title"` Year uint16 `json:"year"` IDs ItemIDs `json:"ids"` }
Movie represents a movie.
type OAuthService ¶
OAuthService services wrapping the OAuth scope.
func (*OAuthService) GetAccessToken ¶
func (s *OAuthService) GetAccessToken(ctx context.Context, code string) (*GetAccessTokenResponse, error)
GetAccessToken exchange code for access_token.
func (*OAuthService) RefreshToken ¶
func (s *OAuthService) RefreshToken(ctx context.Context, refreshToken string) (*RefreshTokenResponse, error)
RefreshToken exchange refresh_token for access_token.
type RefreshTokenResponse ¶
type RefreshTokenResponse struct { Error string `json:"error"` ErrorDescription string `json:"error_description"` AccessToken string `json:"access_token"` TokenType string `json:"token_type"` ExpiresIn uint64 `json:"expires_in"` RefreshToken string `json:"refresh_token"` Scope string `json:"scope"` CreatedAt uint64 `json:"created_at"` }
RefreshTokenResponse response for a refresh token request.
type ScrobbleItem ¶
type ScrobbleItem struct { Item ID uint64 `json:"id"` Action string `json:"action"` Progress float64 `json:"progress"` }
ScrobbleItem a movie, show, season or episode from a scrobble response.
type ScrobbleService ¶
type ScrobbleService struct {
Client *Client
}
ScrobbleService services wrapping the scrobble scope.
func (*ScrobbleService) Pause ¶
func (s *ScrobbleService) Pause(ctx context.Context, item *Item, progress float64) (*ScrobbleItem, error)
Pause watching in a media center.
func (*ScrobbleService) Start ¶
func (s *ScrobbleService) Start(ctx context.Context, item *Item, progress float64) (*ScrobbleItem, error)
Start watching in a media center.
func (*ScrobbleService) Stop ¶
func (s *ScrobbleService) Stop(ctx context.Context, item *Item, progress float64) (*ScrobbleItem, error)
Stop watching in a media center.
type SearchService ¶
type SearchService struct {
Client *Client
}
SearchService services wrapping the search scope.
func (*SearchService) IDLookup ¶
func (s *SearchService) IDLookup( ctx context.Context, serviceType ServiceType, itemID string, itemType ItemType, ) ([]*Item, error)
IDLookup find items by service id and optional type.
type Season ¶
type Season struct { Number uint16 `json:"number"` Episodes []Episode `json:"episodes"` IDs ItemIDs `json:"ids"` }
Season represents a season.
type ServiceType ¶
type ServiceType string
ServiceType type of service.
const ( ServiceTypeTrakt ServiceType = "trakt" ServiceTypeIMDB ServiceType = "imdb" ServiceTypeTMDB ServiceType = "tmdb" ServiceTypeTVDB ServiceType = "tvdb" )
Service types.
type ShowSeasonEpisodeService ¶
type ShowSeasonEpisodeService struct { Client *Client ShowID uint64 SeasonNumber uint16 EpisodeNumber uint16 }
ShowSeasonEpisodeService services wrapping the episodes scope for a single episode within the seasons scope for a single season within the shows scope for a single show.
type ShowSeasonService ¶
ShowSeasonService services wrapping the seasons scope for a single season within the shows scope for a single show.
func (*ShowSeasonService) Episode ¶
func (s *ShowSeasonService) Episode(episodeNumber uint16) *ShowSeasonEpisodeService
Episode creates a new ShowSeasonEpisodeService.
type ShowSeasonsService ¶
ShowSeasonsService services wrapping the seasons scope within the shows scope for a single show.
type ShowService ¶
ShowService services wrapping the shows scope for a single show.
func (*ShowService) LastEpisode ¶
func (s *ShowService) LastEpisode(ctx context.Context) (*BaseEpisode, error)
LastEpisode gets the most recently aired episode for a show.
func (*ShowService) Season ¶
func (s *ShowService) Season(seasonNumber uint16) *ShowSeasonService
Season creates a new ShowSeasonService.
func (*ShowService) Seasons ¶
func (s *ShowService) Seasons() *ShowSeasonsService
Seasons creates a new ShowSeasonsService.
type SyncService ¶
type SyncService struct {
Client *Client
}
SyncService services wrapping the sync scope.
func (*SyncService) AddHistory ¶
func (s *SyncService) AddHistory(ctx context.Context, item *Item, watchedAt time.Time) (bool, error)
AddHistory remove watched item from history.
func (*SyncService) GetHistory ¶
func (s *SyncService) GetHistory(ctx context.Context, itemType ItemType, itemID uint64) ([]*HistoryItem, error)
GetHistory get watches of movie, show, season or episode by type and id.
func (*SyncService) GetHistoryAll ¶
func (s *SyncService) GetHistoryAll(ctx context.Context, itemType ItemType) ([]*HistoryItem, error)
GetHistoryAll get all watched movies, shows, seasons and episodes.
func (*SyncService) GetLastActivities ¶
func (s *SyncService) GetLastActivities(ctx context.Context) (*LastActivities, error)
GetLastActivities gets information about the most recent activity for a user.
func (*SyncService) GetWatched ¶
func (s *SyncService) GetWatched(ctx context.Context, itemType ItemType, seasons bool) ([]*Watched, error)
GetWatched gets watched information for the provided type.
func (*SyncService) GetWatchlist ¶
func (s *SyncService) GetWatchlist( ctx context.Context, itemType ItemType, sort WatchlistSortBy, ) ([]*WatchlistItem, error)
GetWatchlist gets watchlist information for the provided item type and sorted by sort method. Default sort method is rank. Provided sort value is only used if itemType is not ItemTypeAll.
func (*SyncService) RemoveHistory ¶
RemoveHistory remove watched item from history.
type UserListService ¶
UserListService services wrapping the list scope for a single list within the users scope for a single user.
func (*UserListService) Items ¶
func (s *UserListService) Items(ctx context.Context) ([]*Item, error)
Items items on a list.
func (*UserListService) RemoveItems ¶
RemoveItems removes items from a list.
type UserService ¶
UserService services wrapping the users scope for a single user.
func (*UserService) List ¶
func (s *UserService) List(name string) *UserListService
List creates a new UserListService.
type UserSettings ¶
type UserSettings struct { User struct { Username string `json:"username"` Name string `json:"name"` Private bool `json:"private"` VIP bool `json:"vip"` VIPExecutiveProducer bool `json:"vip_ep"` IDs struct { Slug string `json:"slug"` } `json:"ids"` } `json:"user"` }
UserSettings response for a settings request.
type UsersService ¶
type UsersService struct {
Client *Client
}
UsersService services wrapping the users scope.
func (*UsersService) Settings ¶
func (s *UsersService) Settings(ctx context.Context) (*UserSettings, error)
Settings get user settings.
type Watched ¶
type Watched struct { Plays uint16 `json:"plays"` LastWatchedAt time.Time `json:"last_watched_at"` LastUpdatedAt time.Time `json:"last_updated_at"` ResetAt any `json:"reset_at,omitempty"` Show struct { Title string `json:"title"` Year uint16 `json:"year"` IDs ItemIDs `json:"ids"` } `json:"show"` Seasons []struct { Number uint16 `json:"number"` Episodes []struct { Number uint16 `json:"number"` Plays uint16 `json:"plays"` LastWatchedAt time.Time `json:"last_watched_at"` } `json:"episodes"` } `json:"seasons"` Movie struct { Title string `json:"title"` Year uint16 `json:"year"` IDs ItemIDs `json:"ids"` } `json:"movie"` }
Watched represents a watched movie, show, season or episode.
type WatchlistItem ¶
type WatchlistItem struct { Rank uint16 `json:"rank"` ID uint64 `json:"id"` ListedAt time.Time `json:"listed_at"` Notes string `json:"notes"` Item }
WatchlistItem a movie, show, season or episode from a watchlist response.
type WatchlistSortBy ¶
type WatchlistSortBy string
WatchlistSortBy attribute to sort by.
const ( WatchlistSortByRank WatchlistSortBy = "rank" WatchlistSortByAdded WatchlistSortBy = "added" WatchlistSortByReleased WatchlistSortBy = "released" WatchlistSortByTitle WatchlistSortBy = "title" )
WatchlistSortBy attributes.