Class: Videoinfo::Videos::Tv
- Inherits:
-
Videoinfo::Video
- Object
- Videoinfo::Video
- Videoinfo::Videos::Tv
- Defined in:
- lib/videoinfo/videos/tv.rb
Instance Attribute Summary collapse
-
#episode_number ⇒ Object
readonly
Returns the value of attribute episode_number.
-
#episode_string ⇒ Object
readonly
Returns the value of attribute episode_string.
-
#season_number ⇒ Object
readonly
Returns the value of attribute season_number.
Attributes inherited from Videoinfo::Video
Instance Method Summary collapse
Methods inherited from Videoinfo::Video
#capture_screenshots, #initialize, #read_mediainfo
Constructor Details
This class inherits a constructor from Videoinfo::Video
Instance Attribute Details
#episode_number ⇒ Object (readonly)
Returns the value of attribute episode_number.
5 6 7 |
# File 'lib/videoinfo/videos/tv.rb', line 5 def episode_number @episode_number end |
#episode_string ⇒ Object (readonly)
Returns the value of attribute episode_string.
5 6 7 |
# File 'lib/videoinfo/videos/tv.rb', line 5 def episode_string @episode_string end |
#season_number ⇒ Object (readonly)
Returns the value of attribute season_number.
5 6 7 |
# File 'lib/videoinfo/videos/tv.rb', line 5 def season_number @season_number end |
Instance Method Details
#name=(n) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/videoinfo/videos/tv.rb', line 66 def name=(n) @episode_string = n.slice!(/(\AS\d{2,3}E\d{2,3}\ |\ S\d{2,3}E\d{2,3}\z|\AS\d{2,3}\ |\ S\d{2,3}\z)/i) @name = n if @episode_string @episode_string.strip! @season_number, @episode_number = @episode_string.gsub(/[SE]/i, ' ').split end @name end |
#populate_result! ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/videoinfo/videos/tv.rb', line 11 def populate_result! result.mediainfo = read_mediainfo serie = search_imdb.first if serie result.imdb_id = serie.id result.title = serie.title result.plot = serie.plot result. = serie. result.genres = serie.genres result.country = serie.countries.first result.premiered = serie.year if season_number season = serie.season(season_number.to_i) if season result.season_number = season.season_number if episode_number episode = season.episode(episode_number.to_i) if episode result.episode_number = episode.episode result.episode_imdb_id = episode.id result.episode_title = episode.title result.episode_url = episode.url result. = episode. result.air_date = episode.air_date end end end end end result.screenshot_urls = capture_screenshots.map { |ss| Videoinfo.upload_screenshot(ss) } result end |
#result ⇒ Object
7 8 9 |
# File 'lib/videoinfo/videos/tv.rb', line 7 def result @result ||= Results::TvResult.new end |
#search_imdb ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/videoinfo/videos/tv.rb', line 48 def search_imdb series = [] begin series = Imdb::Search.new(name, :tv).movies rescue => e raise Error, "could not search IMDB. #{e.}" end return series.map { |s| Imdb::Serie.new(s.id) } unless Videoinfo.interactive? series.each do |s| STDERR.print "Is your series \"#{s.title}\" (tt#{s.id})? [Y/n] " return [Imdb::Serie.new(s.id)] if STDIN.gets.strip !~ /^(n|no)$/i end [] end |