Class: ImdbInfo
- Inherits:
-
Object
- Object
- ImdbInfo
- Defined in:
- lib/dvdprofiler2xbmc/models/imdb_info.rb
Constant Summary collapse
- IMDB_HASH_TO_INFO_MAP =
Synopsis
maps the imdb.movie hash to the info hash
{ 'title' => 'title', 'mpaa' => 'mpaa', 'rating' => 'rating', 'plot' => 'plot', 'tagline' => 'tagline', 'year' => 'year', 'directors' => 'director', 'length' => 'runtime', 'genres' => 'genre', 'id' => 'id', # Unused: 'company', 'countries', 'poster_url', 'writers', 'photos' # 'poster', 'color', 'aspect_ratio', 'languages', 'release_date' # 'tiny_poster_url', 'also_known_as' }
Class Method Summary collapse
-
.find(options) ⇒ Object
Synopsis See ImdbProfile.all for options.
Instance Method Summary collapse
- #imdb_id ⇒ Object
-
#initialize(profile) ⇒ ImdbInfo
constructor
A new instance of ImdbInfo.
-
#to_xbmc_info ⇒ Object
Synopsis maps the imdb.movie hash to the info hash.
Constructor Details
#initialize(profile) ⇒ ImdbInfo
Returns a new instance of ImdbInfo.
3 4 5 |
# File 'lib/dvdprofiler2xbmc/models/imdb_info.rb', line 3 def initialize(profile) @profile = profile end |
Class Method Details
Instance Method Details
#imdb_id ⇒ Object
67 68 69 |
# File 'lib/dvdprofiler2xbmc/models/imdb_info.rb', line 67 def imdb_id @profile.imdb_id rescue nil end |
#to_xbmc_info ⇒ Object
Synopsis
maps the imdb.movie hash to the info hash
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/dvdprofiler2xbmc/models/imdb_info.rb', line 38 def to_xbmc_info info = Hash.new unless @profile.movie.blank? IMDB_HASH_TO_INFO_MAP.each do |key, value| info[value] = @profile.movie[key] unless @profile.movie[key].blank? end info['id'] = self.imdb_id if info['id'].blank? # special cases: if info['mpaa'].blank? && !@profile.movie['certifications'].blank? @profile.movie['certifications'].each do |certs| if certs['country'] == 'USA' AppConfig[:logger].info { "Using alternative USA certification instead of mpaa rating" } info['mpaa'] = certs['rating'] unless certs['rating'].blank? break end end end unless @profile.movie['cast_members'].blank? @profile.movie['cast_members'].each do |anon| # anon[2] => {name,role} info['actor'] ||= [] info['actor'] << {'name' => anon[0], 'role' => anon[1]} end end info['year'] ||= @profile.movie['release_year'] end info end |