Documentation
¶
Index ¶
- Constants
- Variables
- func HighlightBytePosition(f io.Reader, pos int64) (line, col int, highlight string)
- func Host(host string) option
- func Session(sess *napping.Session) option
- func Userinfo(username, password string) option
- type APIError
- type Episode
- type Movie
- type Ratings
- type Season
- type Show
- type TraktTV
- func (t *TraktTV) GetMovie(slugOrImdbID string) (*Movie, error)
- func (t *TraktTV) GetShow(slugOrTvdbID string) (*Show, error)
- func (t *TraktTV) MovieSearch(query string) ([]Movie, error)
- func (t *TraktTV) ShowSearch(name string) ([]Show, error)
- func (t *TraktTV) ShowSeasons(slugOrTvdbID string, seasons []int) ([]Season, error)
Constants ¶
const TraktTVBaseURL = "https://api.trakt.tv"
Base URL for TraktTV api
Variables ¶
var MovieSearchTmpl = template.Must( template.New("MovieSearch").Parse("{{.Host}}/search/movies.json/{{.APIKey|urlquery}}?query={{.Query | urlquery}}"), )
https://trakt.tv/api-docs/search-movies
var MovieSummaryTmpl = template.Must( template.New("MovieSummary").Parse("{{.Host}}/movie/summary.json/{{.APIKey|urlquery}}/query={{.Query | urlquery}}"), )
https://trakt.tv/api-docs/movie-summary
var ShowSearchTempl = template.Must( template.New("ShowSearch").Parse("{{.Host}}/search/shows.json/{{.APIKey|urlquery}}?query={{.Query | urlquery}}&seasons=true"), )
https://trakt.tv/api-docs/search-shows
var ShowSeasonTmpl = template.Must( template.New("ShowSeason").Parse("{{.Host}}/show/season.json/{{.APIKey|urlquery}}/{{.Query | urlquery}}/{{.Season | urlquery}}"), )
https://trakt.tv/api-docs/show-season
var ShowSummaryTmpl = template.Must( template.New("ShowSummary").Parse("{{.Host}}/show/summary.json/{{.APIKey|urlquery}}/{{.Query | urlquery}}/extended"), )
Functions ¶
func HighlightBytePosition ¶
HighlightBytePosition takes a reader and the location in bytes of a parse error (for instance, from json.SyntaxError.Offset) and returns the line, column, and pretty-printed context around the error with an arrow indicating the exact position of the syntax error.
Taken from the Camlistore source
func Host ¶
func Host(host string) option
Host sets the host to use for talking to TraktTV This includes the protocol, hostname, port: i.e. https://api.trakt.tv:443
Types ¶
type Episode ¶
type Episode struct {
Season int `json:"season"`
Episode int `json:"episode"`
Number int `json:"number"`
TvdbID int `json:"tvdb_id"`
Title string `json:"title"`
Overview string `json:"overview"`
FirstAired int `json:"first_aired"`
FirstAiredIso string `json:"first_aired_iso"`
FirstAiredUtc int `json:"first_aired_utc"`
URL string `json:"url"`
Screen string `json:"screen"`
Images map[string]string `json:"images"`
Ratings Ratings `json:"ratings"`
//Not filled out as we don't do auth with the api
Watched bool `json:"watched"`
InCollection bool `json:"in_collection"`
InWatchlist bool `json:"in_watchlist"`
Rating bool `json:"rating"`
RatingAdvanced int `json:"rating_advanced"`
}
Episode contains the information for a given Show Episode
type Movie ¶
type Movie struct {
Title string `json:"title"`
Year int `json:"year"`
Released int `json:"released"`
URL string `json:"url"`
Trailer string `json:"trailer"`
Runtime int `json:"runtime"`
Tagline string `json:"tagline"`
Overview string `json:"overview"`
Certification string `json:"certification"`
ImdbID string `json:"imdb_id"`
TmdbID int `json:"tmdb_id"`
RtID int `json:"rt_id"`
LastUpdated int `json:"last_updated"`
Images struct {
Poster string `json:"poster"`
Fanart string `json:"fanart"`
} `json:"images"`
Genres []string `json:"genres"`
// It seems like if Age is unset it returns an empty string "" rather than 0,
// setting these to interface{} values lets the decoder work properly.
TopWatchers []struct {
Plays interface{} `json:"plays"`
Username string `json:"username"`
Protected bool `json:"protected"`
FullName string `json:"full_name"`
Gender string `json:"gender"`
Age interface{} `json:"age"`
Location string `json:"location"`
About string `json:"about"`
Joined interface{} `json:"joined"`
Avatar string `json:"avatar"`
URL string `json:"url"`
} `json:"top_watchers"`
Ratings struct {
Percentage int `json:"percentage"`
Votes int `json:"votes"`
Loved int `json:"loved"`
Hated int `json:"hated"`
} `json:"ratings"`
Stats struct {
Watchers int `json:"watchers"`
Plays int `json:"plays"`
Scrobbles int `json:"scrobbles"`
Checkins int `json:"checkins"`
Collection int `json:"collection"`
} `json:"stats"`
People struct {
Directors []struct {
Name string `json:"name"`
Images struct {
Headshot string `json:"headshot"`
} `json:"images"`
} `json:"directors"`
Writers []struct {
Name string `json:"name"`
Job string `json:"job"`
Images struct {
Headshot string `json:"headshot"`
} `json:"images"`
} `json:"writers"`
Producers []struct {
Name string `json:"name"`
Executive bool `json:"executive"`
Images struct {
Headshot string `json:"headshot"`
} `json:"images"`
} `json:"producers"`
Actors []struct {
Name string `json:"name"`
Character string `json:"character"`
Images struct {
Headshot string `json:"headshot"`
} `json:"images"`
} `json:"actors"`
} `json:"people"`
Watched bool `json:"watched"`
Plays int `json:"plays"`
Rating string `json:"rating"`
RatingAdvanced int `json:"rating_advanced"`
InWatchlist bool `json:"in_watchlist"`
InCollection bool `json:"in_collection"`
}
Movie holds the result of a Movie search from Trakt
type Ratings ¶
type Ratings struct {
Percentage int `json:"percentage"`
Votes int `json:"votes"`
Loved int `json:"loved"`
Hated int `json:"hated"`
}
Ratings represents the how the thing was rated by Trakt users
type Season ¶
type Season struct {
Season int `json:"season"`
URL string `json:"url"`
Poster string `json:"poster"`
Episodes []Episode `json:"episodes"`
}
Season is a containter for tv episodes
type Show ¶
type Show struct {
Title string `json:"title"`
Year int `json:"year"`
URL string `json:"url"`
FirstAired int `json:"first_aired"`
Country string `json:"country"`
Overview string `json:"overview"`
Runtime int `json:"runtime"`
Network string `json:"network"`
AirDay string `json:"air_day"`
AirTime string `json:"air_time"`
Certification string `json:"certification"`
ImdbID string `json:"imdb_id"`
TvdbID int `json:"tvdb_id"`
TvrageID int `json:"tvrage_id"`
Ended bool `json:"ended"`
Images map[string]string `json:"images"`
Genres []string `json:"genres"`
Seasons []Season `json:"seasons"`
}
Show is the show result from Trakt
type TraktTV ¶
type TraktTV struct {
APIKey string
BaseURL string
Session *napping.Session
Userinfo *url.Userinfo
}
TraktTV is the main struct used to query Trakt.tv. Use NewTraktTV to create new instances.
func (*TraktTV) MovieSearch ¶
MovieSearch searches Trakt.tv for movies matching the query
func (*TraktTV) ShowSearch ¶
ShowSearch searches tv shows