Giter Club home page Giter Club logo

tvdb2's Introduction

TVDB2 API for Ruby

Ruby wrapper for TVDB json api version 2.

The TVDB api version 2 documentation can be found here.

Installation

Add this line to your application's Gemfile:

gem 'tvdb2'

And then execute:

$ bundle

Or install it yourself as:

$ gem install tvdb2

Usage

First of all you need to get your API key:

require 'tvdb2'

# Create a client object with your api key
client = TVDB.new(apikey: 'YOUR_API_KEY', language: 'en')

# Search series by name
results = client.search(name: 'Game of Thrones')
puts results.map(&:name).inspect
# Get best series result by name
got = best_result = client.best_search('Game of Thrones')
puts got.name

# Get list of actors
actors = got.actors
puts actors.first.name
puts actors.first.role
puts actors.first.image_url

# Print some info about all episodes
got.episodes.each do |episode|
  puts episode.x
  puts episode.absoluteNumber
  puts episode.seasonNumber
  puts episode.number
  puts episode.overview
end
# Get only episodes from 101 and 200
episodes = got.episodes(page: 2)
# Get all episodes of season 1
episodes = got.episodes(airedSeason: 1)
# Get episode by index
puts got[3].name
# Get episode by x syntax (SEASON_NUMBERxEPISODE_NUMBER)
ep = got['3x9']
puts ep.name
puts ep.x # print '3x9'

# Get banner
url = got.banner_url
# Get random banner
url = got.banner_url(random: true)
# Get poster
url = got.poster_url
# Get random poster
url = got.poster_url(random: true)
# Get all posters
posters = got.posters
puts posters.first.url
# or
posters = got.images(keyType: 'poster')
# Get all season images
images = got.season_images
puts images.first.url
# Get all season images of season 2
images = got.season_images(season: 2)
puts images.first.url

# Switch language
ep = got['3x9']
client.language = 'it'
puts ep.name           # print episode title in italian
client.language = 'en'
puts ep.name           # print episode title in english
# or you can swith language only in a block
client.with_language(:it) do
  puts ep.name
end

The complete documentation can be found here.

Missing REST endpoints

This wrapper do not coverage all 100% api REST endpoints. Missing methods are:

  • Series
    • filter: GET /series/{id}/filter
  • Updates
    • updadad: GET /updated/query
  • Users
    • user: GET /user
    • favorites: GET /user/favorites
    • delete favorites: DELETE /user/favorites/{id}
    • add favorites: PUT /user/favorites/{id}
    • ratings: GET /user/ratings
    • ratings with query: GET /user/ratings/query
    • delete rating: DELETE /user/ratings/{itemType}/{itemId}
    • add rating: PUT /user/ratings/{itemType}/{itemId}/{itemRating}

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/pioz/tvdb2.

License

The gem is available as open source under the terms of the MIT License.

tvdb2's People

Contributors

klausmeyer avatar pioz avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

tvdb2's Issues

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.