https://github.com/pioz/tvdb2
Ruby wrapper for TVDB api version 2
https://github.com/pioz/tvdb2
api ruby tv-series tvdb
Last synced: 2 months ago
JSON representation
Ruby wrapper for TVDB api version 2
- Host: GitHub
- URL: https://github.com/pioz/tvdb2
- Owner: pioz
- License: mit
- Created: 2017-08-04T16:22:27.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2023-05-22T10:49:00.000Z (over 2 years ago)
- Last Synced: 2025-02-03T06:45:36.710Z (8 months ago)
- Topics: api, ruby, tv-series, tvdb
- Language: Ruby
- Size: 103 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# TVDB2 API for Ruby
Ruby wrapper for TVDB json api version 2.
The TVDB api version 2 documentation [can be found here](https://api.thetvdb.com/swagger).
## Installation
Add this line to your application's Gemfile:
```ruby
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:
* Register an account on http://thetvdb.com/?tab=register
* When you are logged register an api key on http://thetvdb.com/?tab=apiregister
* View your api keys on http://thetvdb.com/?tab=userinfo```
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](https://pioz.github.io/tvdb2).
## 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](http://opensource.org/licenses/MIT).