internal

package
v1.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 26, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package internal used for client and services

Package internal used for client and services

Package internal used for client and services

Package internal used for client and services

Package internal used for client and services

Package internal used for client and services

Package internal used for client and services

Package internal used for client and services

Package internal used for client and services

Package internal used for client and services

Package internal used for client and services

Package internal used for client and services

Package internal used for client and services

Index

Constants

View Source
const (
	Version = "2"

	HeaderRateLimit           = "X-RateLimit"
	HeaderRetryAfter          = "Retry-After"
	HeaderPaginationPage      = "X-Pagination-Page"
	HeaderPaginationPageCount = "X-Pagination-Page-Count"
	HeaderUpgradeURL          = "X-Upgrade-URL"
)

basic consts for client

Variables

This section is empty.

Functions

This section is empty.

Types

type AbuseRateLimitError

type AbuseRateLimitError struct {
	Response   *http.Response
	RetryAfter *time.Duration
	Message    string `json:"message"`
}

AbuseRateLimitError occurs when trakt.tv returns 429 too many requests header

func (*AbuseRateLimitError) Error

func (r *AbuseRateLimitError) Error() string

type CalendarsService

type CalendarsService Service

CalendarsService handles communication with the calendars related methods of the Trakt API.

func (*CalendarsService) GetDVDReleases

func (c *CalendarsService) GetDVDReleases(ctx context.Context, actionType *string, startDate *string, days *int, opts *uri.ListOptions) ([]*str.CalendarList, *str.Response, error)

GetDVDReleases Returns all movies with a DVD release date during the time period specified.

API docs: https://trakt.docs.apiary.io/#reference/calendars/my-dvd/get-dvd-releases API docs: https://trakt.docs.apiary.io/#reference/calendars/all-dvd/get-dvd-releases

func (*CalendarsService) GetFinales

func (c *CalendarsService) GetFinales(ctx context.Context, actionType *string, startDate *string, days *int, opts *uri.ListOptions) ([]*str.CalendarList, *str.Response, error)

GetFinales Returns all show finales (mid_season_finale, season_finale, series_finale) airing during the time period specified.

API docs: https://trakt.docs.apiary.io/#reference/calendars/my-finales/get-finales API docs: https://trakt.docs.apiary.io/#reference/calendars/all-finales/get-finales

func (*CalendarsService) GetMovies

func (c *CalendarsService) GetMovies(ctx context.Context, actionType *string, startDate *string, days *int, opts *uri.ListOptions) ([]*str.CalendarList, *str.Response, error)

GetMovies Returns all movies with a release date during the time period specified.

API docs: https://trakt.docs.apiary.io/#reference/calendars/my-movies/get-movies API docs: https://trakt.docs.apiary.io/#reference/calendars/all-movies/get-movies

func (*CalendarsService) GetNewShows

func (c *CalendarsService) GetNewShows(ctx context.Context, actionType *string, startDate *string, days *int, opts *uri.ListOptions) ([]*str.CalendarList, *str.Response, error)

GetNewShows Returns all new show premieres airing during the time period specified.

API docs: https://trakt.docs.apiary.io/#reference/calendars/my-new-shows/get-new-shows API docs: https://trakt.docs.apiary.io/#reference/calendars/all-new-shows/get-new-shows

func (*CalendarsService) GetSeasonPremieres

func (c *CalendarsService) GetSeasonPremieres(ctx context.Context, actionType *string, startDate *string, days *int, opts *uri.ListOptions) ([]*str.CalendarList, *str.Response, error)

GetSeasonPremieres Returns all show premieres (mid_season_premiere, season_premiere, series_premiere) airing during the time period specified.

API docs: https://trakt.docs.apiary.io/#reference/calendars/my-season-premieres/get-season-premieres API docs: https://trakt.docs.apiary.io/#reference/calendars/all-season-premieres/get-season-premieres

func (*CalendarsService) GetShows

func (c *CalendarsService) GetShows(ctx context.Context, actionType *string, startDate *string, days *int, opts *uri.ListOptions) ([]*str.CalendarList, *str.Response, error)

GetShows Returns all shows airing during the time period specified.

API docs: https://trakt.docs.apiary.io/#reference/calendars/my-shows/get-shows API docs: https://trakt.docs.apiary.io/#reference/calendars/all-shows/get-shows

type CheckinService added in v1.5.0

type CheckinService Service

CheckinService handles communication with the checkin related methods of the Trakt API.

func (*CheckinService) CheckintoAnItem added in v1.5.0

func (c *CheckinService) CheckintoAnItem(ctx context.Context, checkin *str.CheckIn) (*str.CheckIn, *str.Response, error)

CheckintoAnItem Check into a movie or episode.

API docs: https://trakt.docs.apiary.io/#reference/checkin/checkin/check-into-an-item

func (*CheckinService) DeleteAnyActiveCheckins added in v1.5.0

func (c *CheckinService) DeleteAnyActiveCheckins(ctx context.Context) (*str.Response, error)

DeleteAnyActiveCheckins Removes any active checkins, no need to provide a specific item.

API docs: https://trakt.docs.apiary.io/#reference/checkin/checkin/delete-any-active-checkins

type Client

type Client struct {
	RateLimitReset time.Time

	BaseURL    *url.URL
	UpgradeURL *url.URL

	Oauth     *OauthService
	Users     *UsersService
	Sync      *SyncService
	People    *PeopleService
	Calendars *CalendarsService
	Checkin   *CheckinService
	Search    *SearchService
	Lists     *ListsService
	Movies    *MoviesService
	Episodes  *EpisodesService
	Shows     *ShowsService
	// contains filtered or unexported fields
}

A Client manages communication with the trakt.tv API.

func NewClient

func NewClient(httpClient *http.Client) *Client

NewClient returns a new API client. If a nil httpClient is provided, a new http.Client will be used.

func (*Client) BareDo

func (c *Client) BareDo(ctx context.Context, req *http.Request) (*str.Response, error)

BareDo sends an API request and lets you handle the api response.

func (*Client) CheckResponse

func (c *Client) CheckResponse(r *http.Response) error

CheckResponse checks if api response have errors.

func (*Client) CheckRetryAfter

func (c *Client) CheckRetryAfter(req *http.Request) *AbuseRateLimitError

CheckRetryAfter check Retry After header.

func (*Client) Do

func (c *Client) Do(ctx context.Context, req *http.Request, v any) (*str.Response, error)

Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred

func (*Client) HavePages added in v1.0.3

func (*Client) HavePages(page int, resp *str.Response) bool

HavePages checks if we have available pages to fetch

func (*Client) NewRequest

func (c *Client) NewRequest(method, urlStr string, body any, opts ...RequestOption) (*http.Request, error)

NewRequest creates an API request.

func (*Client) NewResponse

func (c *Client) NewResponse(r *http.Response) *str.Response

NewResponse creates a new Response for the provided http.Response. r must not be nil.

func (*Client) ParseRate

func (*Client) ParseRate(r *http.Response) str.Rate

ParseRate parses the rate related headers.

func (*Client) ParseRateLimit

func (*Client) ParseRateLimit(r *http.Response) *time.Duration

ParseRateLimit parses related headers, and returns the time to retry after.

func (*Client) ParseUpgradeUser added in v1.1.0

func (*Client) ParseUpgradeUser(r *http.Response) *url.URL

ParseUpgradeUser parses related headers, and returns upgradeUrl.

func (*Client) UpdateHeaders

func (c *Client) UpdateHeaders(headers map[string]any)

UpdateHeaders is for update client headers map

func (*Client) WithContext

func (*Client) WithContext(ctx context.Context, req *http.Request) *http.Request

WithContext pass context to request

type ConflictError added in v1.5.0

type ConflictError struct {
	Response *http.Response
	Message  string `json:"message"`
}

ConflictError occurs when trakt.tv returns 409 error

func (*ConflictError) Error added in v1.5.0

func (r *ConflictError) Error() string

type EpisodesService added in v1.5.0

type EpisodesService Service

EpisodesService handles communication with the episodes related methods of the Trakt API.

func (*EpisodesService) GetEpisode added in v1.5.0

func (m *EpisodesService) GetEpisode(ctx context.Context, id *int) (*str.Episode, *str.Response, error)

GetEpisode Returns episode object.

func (*EpisodesService) GetSingleEpisodeForShow added in v1.5.0

func (m *EpisodesService) GetSingleEpisodeForShow(ctx context.Context, id *int, season *int, episode *int) (*str.Episode, *str.Response, error)

GetSingleEpisodeForShow Returns a single episode's details.

API docs: https://trakt.docs.apiary.io/#reference/episodes/summary/get-a-single-episode-for-a-show

type ListsService added in v1.4.0

type ListsService Service

ListsService handles communication with the lists related methods of the Trakt API.

func (*ListsService) GetAllUsersWhoLikedList added in v1.4.0

func (l *ListsService) GetAllUsersWhoLikedList(ctx context.Context, opts *uri.ListOptions, id *int) ([]*str.UserLike, *str.Response, error)

GetAllUsersWhoLikedList Returns all users who liked a list.

API docs: https://trakt.docs.apiary.io/#reference/lists/list-likes/get-all-users-who-liked-a-list

func (*ListsService) GetList added in v1.4.0

func (l *ListsService) GetList(ctx context.Context, id *int) (*str.PersonalList, *str.Response, error)

GetList Returns a single list. Use the /lists/:id/items method to get the actual items this list contains.

API docs: https://trakt.docs.apiary.io/#reference/lists/list/get-list

func (*ListsService) GetListComments added in v1.4.0

func (l *ListsService) GetListComments(ctx context.Context, id *int, sort *string, opts *uri.ListOptions) ([]*str.ListComment, *str.Response, error)

GetListComments Returns comments from single list.

API docs: https://trakt.docs.apiary.io/#reference/lists/list-comments/get-all-list-comments

func (*ListsService) GetListItems added in v1.4.0

func (l *ListsService) GetListItems(ctx context.Context, id *int, t *string, opts *uri.ListOptions) ([]*str.UserListItem, *str.Response, error)

GetListItems Returns items from single list.

API docs: https://trakt.docs.apiary.io/#reference/lists/list-items/get-items-on-a-list

func (*ListsService) GetPopularLists added in v1.4.0

func (l *ListsService) GetPopularLists(ctx context.Context, opts *uri.ListOptions) ([]*str.List, *str.Response, error)

GetPopularLists Returns the most popular lists. Popularity is calculated using total number of likes and comments..

API docs: https://trakt.docs.apiary.io/#reference/lists/popular/get-popular-lists

func (*ListsService) GetTrendingLists added in v1.4.0

func (l *ListsService) GetTrendingLists(ctx context.Context, opts *uri.ListOptions) ([]*str.List, *str.Response, error)

GetTrendingLists Returns all lists with the most likes and comments over the last 7 days.

API docs: https://trakt.docs.apiary.io/#reference/lists/trending/get-trending-lists

func (*ListsService) LikeList added in v1.4.0

func (l *ListsService) LikeList(ctx context.Context, id *int) (*str.Response, error)

LikeList Votes help determine popular lists. Only one like is allowed per list per user.

API docs: https://trakt.docs.apiary.io/#reference/lists/list-like/like-a-list

func (*ListsService) RemoveLikeList added in v1.4.0

func (l *ListsService) RemoveLikeList(ctx context.Context, id *int) (*str.Response, error)

RemoveLikeList Remove a like on a list.

API docs: https://trakt.docs.apiary.io/#reference/lists/list-like/remove-like-on-a-list

type MoviesService added in v1.5.0

type MoviesService Service

MoviesService handles communication with the movies related methods of the Trakt API.

func (*MoviesService) GetMovie added in v1.5.0

func (m *MoviesService) GetMovie(ctx context.Context, id *int) (*str.Movie, *str.Response, error)

GetMovie Returns movie object.

type NotFoundError added in v1.4.0

type NotFoundError struct {
	Response *http.Response
	Message  string `json:"message"`
}

NotFoundError occurs when trakt.tv returns 404 error

func (*NotFoundError) Error added in v1.4.0

func (r *NotFoundError) Error() string

type OauthService

type OauthService Service

OauthService handles communication with the oauth related methods of the Trakt API.

API docs: https://trakt.docs.apiary.io/#reference/authentication-oauth

func (*OauthService) ExchangeRefreshTokenForAccessToken

func (o *OauthService) ExchangeRefreshTokenForAccessToken(ctx context.Context, deviceToken *str.CurrentDeviceToken) (*str.DeviceToken, *str.Response, error)

ExchangeRefreshTokenForAccessToken Use the refresh_token to get a new access_token without asking the user to re-authenticate. The access_token is valid for 3 months before it needs to be refreshed again.

API docs: https://trakt.docs.apiary.io/#reference/authentication-oauth/get-token/exchange-refresh_token-for-access_token

func (*OauthService) GenerateNewDeviceCodes

func (o *OauthService) GenerateNewDeviceCodes(ctx context.Context, code *str.NewDeviceCode) (*str.DeviceCode, *str.Response, error)

GenerateNewDeviceCodes Generate new codes to start the device authentication process.

API docs: https://trakt.docs.apiary.io/#reference/authentication-devices/device-code/generate-new-device-codes

func (*OauthService) PoolForTheAccessToken

func (o *OauthService) PoolForTheAccessToken(ctx context.Context, deviceToken *str.NewDeviceToken) (*str.DeviceToken, *str.Response, error)

PoolForTheAccessToken Use the device_code and poll at the interval (in seconds) to check if the user has authorized you app.

API docs: https://trakt.docs.apiary.io/#reference/authentication-devices/get-token/poll-for-the-access_token

type PeopleService

type PeopleService Service

PeopleService handles communication with the people related methods of the Trakt API.

func (*PeopleService) GetListsContainingThisPerson

func (p *PeopleService) GetListsContainingThisPerson(ctx context.Context, id *string, typeString *string, sort *string, opts *uri.ListOptions) ([]*str.PersonalList, *str.Response, error)

GetListsContainingThisPerson Returns all lists that contain this person.

API docs: https://trakt.docs.apiary.io/#reference/people/lists/get-lists-containing-this-person

func (*PeopleService) GetMovieCredits

func (p *PeopleService) GetMovieCredits(ctx context.Context, id *string, opts *uri.ListOptions) (*str.PersonMovies, *str.Response, error)

GetMovieCredits Returns all movies where this person is in the cast or crew.

API docs: https://trakt.docs.apiary.io/#reference/people/movies/get-movie-credits

func (*PeopleService) GetRecentlyUpdatedPeople

func (p *PeopleService) GetRecentlyUpdatedPeople(ctx context.Context, startDate *string, opts *uri.ListOptions) ([]*str.PersonItem, *str.Response, error)

GetRecentlyUpdatedPeople Returns all people updated since the specified UTC date and time.

API docs: https://trakt.docs.apiary.io/#reference/people/updates/get-recently-updated-people

func (*PeopleService) GetRecentlyUpdatedPeopleTraktIDs

func (p *PeopleService) GetRecentlyUpdatedPeopleTraktIDs(ctx context.Context, startDate *string, opts *uri.ListOptions) ([]*int, *str.Response, error)

GetRecentlyUpdatedPeopleTraktIDs Returns all people Trakt IDs updated since the specified UTC date and time.

API docs: https://trakt.docs.apiary.io/#reference/people/updated-ids

func (*PeopleService) GetShowCredits

func (p *PeopleService) GetShowCredits(ctx context.Context, id *string, opts *uri.ListOptions) (*str.PersonShows, *str.Response, error)

GetShowCredits Returns all shows where this person is in the cast or crew, including the episode_count for which they appear.

API docs: https://trakt.docs.apiary.io/#reference/people/shows/get-show-credits

func (*PeopleService) GetSinglePerson

func (p *PeopleService) GetSinglePerson(ctx context.Context, id *string, opts *uri.ListOptions) (*str.Person, *str.Response, error)

GetSinglePerson Returns a single person's details.

API docs: https://trakt.docs.apiary.io/#reference/people/summary/get-a-single-person

func (*PeopleService) RefreshPersonMetadata added in v1.5.0

func (p *PeopleService) RefreshPersonMetadata(ctx context.Context, id *string) (*str.Response, error)

RefreshPersonMetadata Queue this person for a full metadata and image refresh. It might take up to 8 hours for the updated metadata to be availabe through the API.

API docs: https://trakt.docs.apiary.io/#reference/people/refresh/refresh-person-metadata

type RequestOption

type RequestOption func(req *http.Request)

RequestOption represents an option that can modify an http.Request.

type SearchService

type SearchService Service

SearchService handles communication with the search related methods of the Trakt API.

func (*SearchService) GetIDLookupResults

func (s *SearchService) GetIDLookupResults(ctx context.Context, formatType *string, id *string, opts *uri.ListOptions) ([]*str.SearchListItem, *str.Response, error)

GetIDLookupResults Lookup items by their Trakt, IMDB, TMDB, or TVDB ID. If you use the search url without a type it might return multiple items if the id_type is not globally unique. Specify the type of results by sending a single value or a comma delimited string for multiple types.

API docs: https://trakt.docs.apiary.io/#reference/search/id-lookup/get-id-lookup-results

func (*SearchService) GetTextQueryResults

func (s *SearchService) GetTextQueryResults(ctx context.Context, searchType *string, opts *uri.ListOptions) ([]*str.SearchListItem, *str.Response, error)

GetTextQueryResults Search all text fields that a media object contains (i.e. title, overview, etc). Results are ordered by the most relevant score. Specify the type of results by sending a single value or a comma delimited string for multiple types.

API docs: https://trakt.docs.apiary.io/#reference/search/text-query/get-text-query-results

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service structure for other services

type ShowsService added in v1.5.0

type ShowsService Service

ShowsService handles communication with the shows related methods of the Trakt API.

func (*ShowsService) GetShow added in v1.5.0

func (s *ShowsService) GetShow(ctx context.Context, id *int, opts *uri.ListOptions) (*str.Show, *str.Response, error)

GetShow Returns episode object.

type SyncService

type SyncService Service

SyncService handles communication with the sync related methods of the Trakt API.

func (*SyncService) GetCollection

func (s *SyncService) GetCollection(ctx context.Context, types *string, opts *uri.ListOptions) ([]*str.ExportlistItem, *str.Response, error)

GetCollection Get all collected items in a user's collection.

API docs: https://trakt.docs.apiary.io/#reference/sync/get-collection/get-collection

func (*SyncService) GetWatchedHistory

func (s *SyncService) GetWatchedHistory(ctx context.Context, types *string, opts *uri.ListOptions) ([]*str.ExportlistItem, *str.Response, error)

GetWatchedHistory Returns movies and episodes that a user has watched, sorted by most recent.

API docs: https://trakt.docs.apiary.io/#reference/sync/get-watched/get-watched-history

func (*SyncService) GetWatchlist

func (s *SyncService) GetWatchlist(ctx context.Context, types *string, sort *string, opts *uri.ListOptions) ([]*str.ExportlistItem, *str.Response, error)

GetWatchlist Returns all items in a user's watchlist filtered by type.

API docs: https://trakt.docs.apiary.io/#reference/sync/get-watchlist/get-watchlist

type UpgradeRequiredError added in v1.1.0

type UpgradeRequiredError struct {
	Response   *http.Response
	UpgradeURL *url.URL
	Message    string `json:"message"`
}

UpgradeRequiredError occurs when trakt.tv returns 426 user must upgrade to vip header

func (*UpgradeRequiredError) Error added in v1.1.0

func (r *UpgradeRequiredError) Error() string

type UsersService

type UsersService Service

UsersService handles communication with the users related methods of the Trakt API.

func (*UsersService) GetItemstOnAPersonalList

func (u *UsersService) GetItemstOnAPersonalList(ctx context.Context, id *string, listID *string, t *string) ([]*str.UserListItem, *str.Response, error)

GetItemstOnAPersonalList Get all items on a personal list.

API docs: https://trakt.docs.apiary.io/#reference/users/list-items/get-items-on-a-personal-list

func (*UsersService) GetSavedFilters added in v1.1.0

func (u *UsersService) GetSavedFilters(ctx context.Context, section *string) ([]*str.SavedFilter, *str.Response, error)

GetSavedFilters Get all saved filters a users has created.

API docs: https://trakt.docs.apiary.io/#reference/users/saved-filters/get-saved-filters

func (*UsersService) GetStats added in v1.2.0

func (u *UsersService) GetStats(ctx context.Context, id *string) (*str.UserStats, *str.Response, error)

GetStats Returns stats about the movies, shows, and episodes a user has watched, collected, and rated.

API docs:https://trakt.docs.apiary.io/#reference/users/stats/get-stats

func (*UsersService) GetUserProfile

func (u *UsersService) GetUserProfile(ctx context.Context, id *string) (*str.UserProfile, *str.Response, error)

GetUserProfile Get a user's profile information.

API docs:https://trakt.docs.apiary.io/#reference/users/profile/get-user-profile

func (*UsersService) GetUsersPersonalLists

func (u *UsersService) GetUsersPersonalLists(ctx context.Context, id *string) ([]*str.PersonalList, *str.Response, error)

GetUsersPersonalLists Returns all personal lists for a user.

API docs: https://trakt.docs.apiary.io/#reference/users/lists/get-a-user's-personal-lists

func (*UsersService) GetWatched added in v1.3.0

func (u *UsersService) GetWatched(ctx context.Context, id *string, watchType *string, opts *uri.ListOptions) ([]*str.UserWatched, *str.Response, error)

GetWatched Returns all movies or shows a user has watched sorted by most plays.

API docs:https://trakt.docs.apiary.io/#reference/users/watched/get-watched

func (*UsersService) RetrieveSettings added in v1.5.0

func (u *UsersService) RetrieveSettings(ctx context.Context) (*str.UserSettings, *str.Response, error)

RetrieveSettings Get the user's settings so you can align your app's experience with what they're used to on the trakt website.

API docs: https://trakt.docs.apiary.io/#reference/users/settings/retrieve-settings

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL