class Rmpv::Trakt
Constants
- TRAKTAPIKEY
Initialize the trakt client
Public Class Methods
new()
click to toggle source
# File lib/rmpv/trakt.rb, line 19 def initialize traktconfig = YAML.load File.open("#{Dir.home}/.rmpvrc") @trakt = Traktr::Client.new(TRAKTAPIKEY, \ traktconfig["trakt"]["username"], \ traktconfig["trakt"]["password"], true) end
Public Instance Methods
scrobble(show, progress, type='show')
click to toggle source
Scrobble the show
# File lib/rmpv/trakt.rb, line 56 def scrobble(show, progress, type='show') tries = 5 begin if type == 'show' info = @trakt.search.shows(show.name) res = @trakt.show.scrobble(info[0], show.series, show.episode,\ progress, Rmpv::VERSION, Rmpv::BUILD) elsif type == 'movie' info = @trakt.search.movies(show.name) res = @trakt.movie.scrobble(info[0], progress, \ Rmpv::VERSION, Rmpv::BUILD) end puts "Scrobbled to trakt (Y) - #{show.name}" rescue Exception => e tries -= 1 if tries > 0 retry else puts "Couldn't connect to trakt servers: #{e}, #{res}" end end end
watching(show, progress, type='show')
click to toggle source
Set as watching
# File lib/rmpv/trakt.rb, line 29 def watching(show, progress, type='show') tries = 5 begin if type == 'show' info = @trakt.search.shows(show.name) res = @trakt.show.watching(info[0], show.series, show.episode, \ progress, Rmpv::VERSION, Rmpv::BUILD) elsif type == 'movie' info = @trakt.search.movies(show.name) res = @trakt.movie.watching(info[0], progress, \ Rmpv::VERSION, Rmpv::BUILD) end puts "Watching to trakt (Y) - #{show.name}" rescue Exception => e tries -= 1 if tries > 0 retry else puts "Couldn't connect to trakt servers: #{e}, #{res}" end end info[0].runtime # return duration end