Trakt¶ ↑
This is a Ruby API for the trakt.tv movie, tvshow service.
NOTE: This is for the old API. New API uses oauth and such. Feel free to submit a PR to make things work here.
Installation¶ ↑
Add this line to your application’s Gemfile:
gem 'trakt'
And then execute:
$ bundle
Or install it yourself as:
$ gem install trakt
Usage¶ ↑
All calls return an JSON structure.
This is a typical default setup
require 'trakt' trakt = Trakt.new trakt.apikey = 'your_api_key' trakt.username = 'your_username' trakt.password = 'your_password'
Settings¶ ↑
trakt.account.settings
Searching¶ ↑
trakt.search.movies "the shawshank redemption" trakt.search.shows "death note"
And wait, there’s more!¶ ↑
Check the spec directory for the rest of the functionality and how to use it. I got lazy with documentation it seems.
Examples¶ ↑
Adding all your seen movies from a text file.¶ ↑
Adding movies from a text file is a bit hit and miss, so it’s best if you create a list to add the movies to. You’ll have to make a list manually in advance since creation isn’t supported yet. The list takes a rather odd name. The one in the exaple here was created as “From my file”.
list = trakt.list.add('from-my-file'); IO.readlines(ENV['HOME']+"/misc/movies.txt").each do |movie| result = trakt.search.movies(movie) next unless result movie = result.first next unless movie list.add_item(type: :movie, imdb_id: movie['imdb_id']) end
Marking shows unseen¶ ↑
Example making all episodes of season 4 of winnie the pooh unseen. (You can use Trakt::Search.shows(“the new adventures of winnie the pooh”).first to get the imdb_id)
episodes = [] 1.upto(11) { |n| episodes << { "season" => 4, "episode" => n } } Trakt::Show.episode_unseen("imdb_id" => "tt0165052", episodes: episodes)
Contributing¶ ↑
-
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