Class: Mediaman::Metadata
- Inherits:
-
Hashie::Mash
- Object
- Hashie::Mash
- Mediaman::Metadata
- Defined in:
- lib/mediaman/metadata.rb
Instance Method Summary collapse
- #canonical_description ⇒ Object
- #canonical_director ⇒ Object
- #canonical_episode_name ⇒ Object
- #canonical_image_url ⇒ Object
- #canonical_movie_title ⇒ Object
- #canonical_rating ⇒ Object
- #canonical_show_name ⇒ Object
- #canonical_year ⇒ Object
- #episode_id ⇒ Object
- #library_category ⇒ Object
- #to_subler_hash ⇒ Object
- #uuid ⇒ Object
Instance Method Details
#canonical_description ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/mediaman/metadata.rb', line 38 def canonical_description if tv? episode_details.try(:[], "overview").presence else movie_details.try(:[], "overview").presence end end |
#canonical_director ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'lib/mediaman/metadata.rb', line 46 def canonical_director if movie? d = movie_details.try(:[], "people").try(:[], "directors").presence if d d.map{|director| director.name}.join ", " end end end |
#canonical_episode_name ⇒ Object
12 13 14 |
# File 'lib/mediaman/metadata.rb', line 12 def canonical_episode_name episode_details.try(:title).presence end |
#canonical_image_url ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/mediaman/metadata.rb', line 30 def canonical_image_url if tv? episode_details.try(:[], "images").try(:first).try(:last) else movie_details.try(:[], "poster").presence end end |
#canonical_movie_title ⇒ Object
16 17 18 |
# File 'lib/mediaman/metadata.rb', line 16 def canonical_movie_title movie_details.try(:title).presence || name.presence || raw_name.presence end |
#canonical_rating ⇒ Object
55 56 57 |
# File 'lib/mediaman/metadata.rb', line 55 def movie_details.try(:[], "certification").presence end |
#canonical_show_name ⇒ Object
8 9 10 |
# File 'lib/mediaman/metadata.rb', line 8 def canonical_show_name show_details.try(:title).presence || name.presence || raw_name.presence end |
#canonical_year ⇒ Object
59 60 61 |
# File 'lib/mediaman/metadata.rb', line 59 def canonical_year movie_details.try(:[], "year").presence || year.presence end |
#episode_id ⇒ Object
20 21 22 |
# File 'lib/mediaman/metadata.rb', line 20 def episode_id "#{season_number}x#{"%02d" % episode_number}" end |
#library_category ⇒ Object
24 25 26 27 28 |
# File 'lib/mediaman/metadata.rb', line 24 def library_category return "TV Shows" if tv? return "Movies" if movie? "Other Media" end |
#to_subler_hash ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/mediaman/metadata.rb', line 67 def to_subler_hash h = {} if movie? h[:name] = canonical_movie_title h[:media_kind] = "Movie" h[:rating] = if h[:year] = canonical_year if canonical_year end if tv? h[:name] = canonical_episode_name h[:tv_show] = canonical_show_name h[:album] = canonical_show_name h[:tv_episode_id] = episode_id h[:tv_episode_number] = episode_number h[:tv_season] = season_number h[:track_number] = "#{episode_number}/0" h[:media_kind] = "TV Show" end h[:description] = canonical_description if canonical_description.present? h[:hd_video] = true if hd? h end |
#uuid ⇒ Object
63 64 65 |
# File 'lib/mediaman/metadata.rb', line 63 def uuid movie_details.try(:[], "imdb_id") || Digest::MD5.hexdigest("#{filename}") end |