Class: UnifiedDB::Backend::TVDB

Inherits:
Base
  • Object
show all
Defined in:
lib/unified_db/backend/tvdb.rb

Instance Attribute Summary

Attributes inherited from Base

#id, #title

Instance Method Summary collapse

Methods inherited from Base

find, #find, #initialize, #result

Constructor Details

This class inherits a constructor from UnifiedDB::Backend::Base

Instance Method Details

#find_by_id(id) ⇒ Object


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/unified_db/backend/tvdb.rb', line 7

def find_by_id(id)
  movie = handler.get_series_by_id(id)
  raise if movie.nil?

  @result = Result::ID.new(
    :id => movie.id,
    :title => movie.name.to_s,
    :overview => movie.overview.to_s,
    :release_date => movie.first_aired.to_s,
    :genres => movie.genres,
    :rating => movie.rating.to_s,
    :runtime => movie.runtime.to_i.to_s,
    :actors => format_actors(movie.actors),
    :directors => [],
    :writers => [],
    :posters => format_posters(movie.banners)
  )
rescue
  raise ApiError, 'not found'
end

#find_by_title(title) ⇒ Object


28
29
30
31
32
33
34
35
36
37
# File 'lib/unified_db/backend/tvdb.rb', line 28

def find_by_title(title)
  movies = handler.search(title)
  movies.each do |movie|
    @result << Result::Title.new(
      :id => movie['seriesid'],
      :title => movie['SeriesName'],
      :year => movie['FirstAired'].to_s.split('-')[0])
  end
  result
end