Code Monkey home page Code Monkey logo

go-trakt's Introduction

Go-Trakt

Trakt API v2 Wrapper for GO (Golang).
Under heavy development and in dire need of work.

API structure and quite a bit of code has been shamelessly ripped off from go-octokit; a lovely GitHub API wrapper, the authors of which I owe one or more beers.

Current Features

  • Authenticate via AccessToken
  • Retrieve shows by show.ids.trakt
  • Retrieve seasons by show.ids.trakt and season.number
  • Retrieve episodes by show.ids.trakt and season.number

Example

package main

import (
  "fmt"

  "github.com/42minutes/go-trakt"
)

func main() {
  client := trakt.NewClient(
    "CLIENT_ID",
    trakt.TokenAuth{AccessToken: "ACCESS_TOKEN"},
  )

  shows, err := client.Shows().AllPopular()
  fmt.Println(shows)
  fmt.Println(err) // Should be nil

  show, err := client.Shows().One(1390)
  fmt.Println(show)
  fmt.Println(err) // Should be nil

  seasons, err := client.Seasons().All(1390)
  fmt.Println(seasons)
  fmt.Println(err) // Should be nil

  episodes, err := client.Episodes().AllBySeason(1390, 1)
  fmt.Println(episodes)
  fmt.Println(err) // Should be nil

  showResults, err := client.Shows().Search("game of thrones")
  for _, showResult := range showResults {
    fmt.Println(showResult.Show)
  }
  fmt.Println(err) // Should be nil
}

go-trakt's People

Contributors

geoah avatar haarts avatar superdecimal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

go-trakt's Issues

The API url changed, again

It's now https://api-v2launch.trakt.tv. The const TraktAPIURL should be changed to reflect this.

Workaround is using trakt.NewClientWith(....).

ID Lookup: search a show by id

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

I tried to add the feature myself, as you can see here: https://github.com/varyoo/go-trakt/blob/id-lookup/shows.go#L42, unfortunately it dosen't works well.

Take the following code:

_, res := trakt.Shows().IdLookup("tvdb", 269613)
println(res.Err.Error())

Output: json: cannot unmarshal string into Go value of type int

I'm not sure why, but I guess it's because we can't specify the type of the results for an ID Lookup (I tried to append &type=show to the URL it dosen't work), so the json parser run into other types of results. (an episode in this case).

Thanks for any help.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.