Yet another API client for TheTVDB. This one caches responses locally, and exposes a couple of classes to represent the data, if you don't like tearing through hashes.
Add this line to your application's Gemfile:
gem 'yatvdb'
And then execute:
$ bundle
Or install it yourself as:
$ gem install yatvdb
There's a basic command-line interface - just run yatvdb -h
after you've
installed it.
To use it in your own project:
# Search for the TV series "Justified"
require 'yatvdb/client'
client = YATVDB::Client.new(api_key: 'My API key', cache: '/path/to/cache')
results = client.get_series('Justified') # => [<YATVDB::Series...>]
justified = results.first
justified.overview # => "Deputy U.S. Marshal Raylan Givens is..."
justified.episodes # => [<YATVDB::Episode @name="Fire in the Hole"...>, ...]
justified.seasons # => [[<YATVDB::Episode @name="Fire in the Hole"...>...], ...]
YATVDB will look for a YAML or Ruby configuration file in:
- /config/yatvdb.yml
- ~/.yatvdb/config
- /usr/local/etc/yatvdb.conf
- /etc/yatvdb.conf
The file should be a simple YAML configuration, like
---
api_key: 1234567890
cache: /var/db/yatvdb
If a cache path can be determined (and it points to a writeable directory), then
it will be used to mirror the thetvdb.com. Lookups will first try to find the
files in that directory, before downloading them and caching them there. If
caching is enabled, then you should remember to run the utility
YATVDB.expire_cache
method occasionally to get the latest changes (it will
check for updates on the server, and just delete outdated cache files).
- Make the XML parsing pluggable (REXML, Nokogiri)
- See about always getting the zipped files
- Export to JSON/Ruby
- More tests and documentation
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request