tvdb

package module
v0.0.0-...-80f06ad Latest Latest
Warning

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

Go to latest
Published: May 17, 2017 License: Apache-2.0 Imports: 4 Imported by: 2

README

Documentation

Overview

Package tvdb a simple interface to thetvdb.com REST API

Copyright 2016 Lorenzo Giuliani <lorenzo@frenzart.com>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (

	// Version of the client
	Version = "0.1.0"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Auth

type Auth struct {
	APIKey   string
	UserKey  string
	Username string
}

Auth authentication scheme

type Client

type Client struct {

	// Authentication configuration
	Auth *Auth

	// Services
	Search   *SearchService
	Series   *SeriesService
	Episodes *EpisodesService
	Token    *TokenService
	// contains filtered or unexported fields
}

Client is the TvDB REST API client

func NewClient

func NewClient(httpClient *http.Client, auth *Auth) *Client

NewClient returns a new TvDB REST client

func (*Client) Login

func (c *Client) Login() error

Login calls the Client.Token#Login method

type Episode

type Episode struct {
	ID                 int32    `json:"id,omitempty"`
	AiredSeason        int32    `json:"airedSeason,omitempty"`
	AiredEpisodeNumber int32    `json:"airedEpisodeNumber,omitempty"`
	EpisodeName        string   `json:"episodeName,omitempty"`
	FirstAired         string   `json:"firstAired,omitempty"`
	GuestStars         []string `json:"guestStars,omitempty"`
	Director           string   `json:"director,omitempty"`
	Directors          []string `json:"directors,omitempty"`
	Writers            []string `json:"writers,omitempty"`
	Overview           string   `json:"overview,omitempty"`
	ProductionCode     string   `json:"productionCode,omitempty"`
	ShowURL            string   `json:"showUrl,omitempty"`
	LastUpdated        int32    `json:"lastUpdated,omitempty"`
	DvdDiscid          string   `json:"dvdDiscid,omitempty"`
	DvdSeason          int32    `json:"dvdSeason,omitempty"`
	DvdEpisodeNumber   float32  `json:"dvdEpisodeNumber,omitempty"`
	DvdChapter         float32  `json:"dvdChapter,omitempty"`
	AbsoluteNumber     int32    `json:"absoluteNumber,omitempty"`
	Filename           string   `json:"filename,omitempty"`
	SeriesID           string   `json:"seriesId,omitempty"`
	LastUpdatedBy      string   `json:"lastUpdatedBy,omitempty"`
	AirsAfterSeason    int32    `json:"airsAfterSeason,omitempty"`
	AirsBeforeSeason   int32    `json:"airsBeforeSeason,omitempty"`
	AirsBeforeEpisode  int32    `json:"airsBeforeEpisode,omitempty"`
	ThumbAuthor        int32    `json:"thumbAuthor,omitempty"`
	ThumbAdded         string   `json:"thumbAdded,omitempty"`
	ThumbWidth         string   `json:"thumbWidth,omitempty"`
	ThumbHeight        string   `json:"thumbHeight,omitempty"`
	ImdbID             string   `json:"imdbId,omitempty"`
	SiteRating         float32  `json:"siteRating,omitempty"`
	SiteRatingCount    int32    `json:"siteRatingCount,omitempty"`
}

Episode a single episode

func (*Episode) IsInFuture

func (e *Episode) IsInFuture() bool

Check if an episode is in the future

func (*Episode) ParseAired

func (e *Episode) ParseAired() *time.Time

I guess date/time parsing is difficult in go

type EpisodeRecordData

type EpisodeRecordData struct {
	Data   Episode   `json:"data,omitempty"`
	Errors JSONError `json:"jsonError,omitempty"`
}

EpisodeRecordData Searches results

type EpisodeSearchParams

type EpisodeSearchParams struct {
	AbsoluteNumber *string `url:"absoluteNumber,omitempty"`
	AiredSeason    *string `url:"airedSeason,omitempty"`
	AiredEpisode   *string `url:"airedEpisode,omitempty"`
	DvdSeason      *string `url:"dvdSeason,omitempty"`
	DvdEpisode     *string `url:"dvdEpisode,omitempty"`
	ImdbId         *string `url:"imdbId,omitempty"`
	Page           *string `url:"page,omitempty"`
}

SearchParams optional episodes search parameters

type EpisodesRecordData

type EpisodesRecordData struct {
	Data  []Episode `json:"data,omitempty"`
	Links Links     `json:"links,omitempty"`
}

Episodes Search Results

type EpisodesService

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

EpisodesService the episode service

func (*EpisodesService) Get

func (s *EpisodesService) Get(id int32) (*Episode, error)

Get a single episode

func (*EpisodesService) ListEpisodes

func (s *EpisodesService) ListEpisodes(seriesId int32, params *EpisodeSearchParams) (*EpisodesRecordData, error)

Note, only use the page value in EpisodeSearchParams

func (*EpisodesService) SearchEpisodes

func (s *EpisodesService) SearchEpisodes(seriesId int32, params *EpisodeSearchParams) (*EpisodesRecordData, error)

Find episodes meeting certain criteria

type JSONError

type JSONError struct {
	Message string `json:"error,omitempty"`
}

JSONError is a generic type for errors

func (JSONError) Empty

func (e JSONError) Empty() bool

Empty checks if an error message is empty

func (JSONError) Error

func (e JSONError) Error() string
type Links struct {
	First int32 `json:"first,omitempty"`
	Next  int32 `json:"next,omitempty"`
	Prev  int32 `json:"prev,omitempty"`
	Last  int32 `json:"last,omitempty"`
}

func (*Links) HasNext

func (l *Links) HasNext() bool

type SearchParams

type SearchParams struct {
	Name     *string `url:"name,omitempty"`
	ImdbID   *string `url:"imdbId,omitempty"`
	Zap2itID *string `url:"zap2itId,omitempty"`
}

SearchParams all optional search parameters

type SearchService

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

SearchService provides an interface to the search engine

func (*SearchService) ByImdbID

func (s *SearchService) ByImdbID(id string) ([]*SeriesSearchData, error)

ByImdbID Search by IMDB id

func (*SearchService) ByName

func (s *SearchService) ByName(name string) ([]*SeriesSearchData, error)

ByName Search series by name

func (*SearchService) ByZap2itID

func (s *SearchService) ByZap2itID(id string) ([]*SeriesSearchData, error)

ByZap2itID Search by Zap2it id

func (*SearchService) Search

func (s *SearchService) Search(params *SearchParams) ([]*SeriesSearchData, error)

Search search by SearchParams

type Series

type Series struct {
	ID              int32    `json:"id"`
	SeriesName      string   `json:"seriesName"`
	Aliases         []string `json:"aliases,omitempty"`
	Banner          string   `json:"banner,omitempty"`
	SeriesID        string   `json:"seriesId,omitempty"`
	Status          string   `json:"status,omitempty"`
	FirstAired      string   `json:"firstAired,omitempty"`
	Network         string   `json:"network,omitempty"`
	NetworkID       string   `json:"networkId,omitempty"`
	Runtime         string   `json:"runtime,omitempty"`
	Genre           []string `json:"genre,omitempty"`
	Overview        string   `json:"overview,omitempty"`
	LastUpdated     int32    `json:"lastUpdated,omitempty"`
	AirsDayOfWeek   string   `json:"airsDayOfWeek,omitempty"`
	AirsTime        string   `json:"airsTime,omitempty"`
	Rating          string   `json:"rating,omitempty"`
	ImdbID          string   `json:"imdbId,omitempty"`
	Zap2itID        string   `json:"zap2itId,omitempty"`
	Added           string   `json:"added,omitempty"`
	SiteRating      float32  `json:"siteRating,omitempty"`
	SiteRatingCount int32    `json:"siteRatingCount,omitempty"`
}

Series type

type SeriesData

type SeriesData struct {
	Data   Series      `json:"data,omitempty"`
	Errors []JSONError `json:"errors,omitempty"`
}

SeriesData response container

type SeriesSearchData

type SeriesSearchData struct {
	ID         int32    `json:"id,omitempty"`
	Aliases    []string `json:"aliases,omitempty"`
	Banner     string   `json:"banner,omitempty"`
	FirstAired string   `json:"firstAired,omitempty"`
	Network    string   `json:"network,omitempty"`
	Overview   string   `json:"overview,omitempty"`
	SeriesName string   `json:"seriesName,omitempty"`
	Status     string   `json:"status,omitempty"`
}

SeriesSearchData type definition of search results

type SeriesSearchResults

type SeriesSearchResults struct {
	Data []*SeriesSearchData `json:"data,omitempty"`
}

SeriesSearchResults contains search results

type SeriesService

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

SeriesService TV Series service

func (*SeriesService) Get

func (s *SeriesService) Get(id int32) (*Series, error)

Get one TV Serie by ID

type Token

type Token struct {
	Token string `json:"token"`
}

Token struct

type TokenService

type TokenService struct {
	Auth  *Auth
	Token *Token
	// contains filtered or unexported fields
}

TokenService tv series service

func (*TokenService) Login

func (s *TokenService) Login() (*Token, error)

Login requests and applies a new Token to the base client

func (*TokenService) Refresh

func (s *TokenService) Refresh() (*Token, *http.Response, error)

Refresh refreshes the stored token setting the new Authorization header

Directories

Path Synopsis
cli

Jump to

Keyboard shortcuts

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