Class: Trakt::Show

Inherits:
Object
  • Object
show all
Includes:
Connection
Defined in:
lib/trakt/show.rb

Instance Attribute Summary

Attributes included from Connection

#trakt

Instance Method Summary collapse

Methods included from Connection

#initialize, #require_settings

Instance Method Details

#episode_seen(data) ⇒ Object



8
9
10
11
# File 'lib/trakt/show.rb', line 8

def episode_seen(data)
  require_settings %w|username password apikey|
  post('show/episode/seen/', data)
end

#episode_unseen(data) ⇒ Object



4
5
6
7
# File 'lib/trakt/show.rb', line 4

def episode_unseen(data)
  require_settings %w|username password apikey|
  post('show/episode/unseen/', data)
end

#seasons(title) ⇒ Object



31
32
33
# File 'lib/trakt/show.rb', line 31

def seasons(title)
  get('show/seasons.json/', title)
end

#seen(data) ⇒ Object



12
13
14
15
# File 'lib/trakt/show.rb', line 12

def seen(data)
  require_settings %w|username password apikey|
  post('show/seen/', data)
end

#unseen(title) ⇒ Object

need to use thetvdb id here since the slug can’t be used for unseen



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/trakt/show.rb', line 17

def unseen(title)
  all = seasons title
  episodes_per_season = {}
  episodes_to_remove = []
  all.each do |season_info|
    season_num = season_info['season']
    next if season_num == 0 # dont need to remove specials
    episodes    = season_info['episodes']
    1.upto(episodes) do |episode|
      episodes_to_remove << { season: season_num, episode: episode }
    end
  end
  episode_unseen tvdb_id: title, episodes: episodes_to_remove
end