Permalink
Browse files

better fallbacks for mpaa rating

  • Loading branch information...
1 parent 41e8a6f commit 19aa1510a9a191953577ec3258e9f2fa5a635d5a @jacobwgillespie committed Apr 28, 2012
Showing with 19 additions and 1 deletion.
  1. +19 −1 app/models/movie.rb
View
20 app/models/movie.rb
@@ -118,6 +118,7 @@ def load_information
end
self.title = imdb.title
self.year = imdb.year
+
self.plot_summary = imdb.plot
self.remote_poster_url = imdb.poster
self.runtime = "#{imdb.length.to_i / 60}hrs #{imdb.length.to_i % 60}min" if imdb.length
@@ -142,7 +143,24 @@ def load_information
self.remote_backdrop_url = tmdb_backdrop['image']['url']
self.plot_details = result['overview']
self.tmdb_url = result['url']
- self.mpaa_rating = result['certification']
+ # TODO: find another source for mpaa rating
+ if imdb.mpaa_rating
+ if imdb.mpaa_rating.index /\bNC-17\b/
+ self.mpaa_rating = 'NC-17'
+ elsif imdb.mpaa_rating.index /\bPG-13\b/
+ self.mpaa_rating = 'PG-13'
+ elsif imdb.mpaa_rating.index /\bPG\b/
+ self.mpaa_rating = 'PG'
+ elsif imdb.mpaa_rating.index /\bR\b/
+ self.mpaa_rating = 'R'
+ elsif imdb.mpaa_rating.index /\bG\b/
+ self.mpaa_rating = 'G'
+ else
+ self.mpaa_rating = 'N/A'
+ end
+ else
+ self.mpaa_rating = result['certification']
+ end
search_title = "#{title} [#{year}}"

0 comments on commit 19aa151

Please sign in to comment.