class Nokaya::TVShow
Constants
- NOKAYA_TVDB_API_KEY
Attributes
language[RW]
plot[RW]
poster_url[RW]
title[RW]
Public Class Methods
new(args, options = {})
click to toggle source
Calls superclass method
Nokaya::Basic::new
# File lib/nokaya/tvshow.rb, line 12 def initialize(args, options = {}) super(args, options) @type = :tvshow @language = 'en' begin @tvdb = TvdbParty::Search.new(NOKAYA_TVDB_API_KEY) rescue SocketError Logs.rec.error Status.no_cnx return nil end terms = args.join(' ') show_obj = find(terms, options) return nil if show_obj.nil? create_details(show_obj) @urls = [@poster_url, @banner_url] @filenames = name_files() end
Private Instance Methods
create_details(show_obj)
click to toggle source
# File lib/nokaya/tvshow.rb, line 56 def create_details(show_obj) @title = show_obj.name @name = @workers.sanitize(@title) @poster_url = find_poster_url(show_obj) @banner_url = find_banner_url(show_obj) @plot = find_plot(show_obj) @year = show_obj.first_aired.year @ref_url = "http://imdb.com/title/#{show_obj.imdb_id}/" end
find(title, options)
click to toggle source
# File lib/nokaya/tvshow.rb, line 38 def find(title, options) res = @tvdb.search(title) unless options[:alt] if !res[0].nil? return @tvdb.get_series_by_id(res[0]['seriesid']) elsif !res[1].nil? return @tvdb.get_series_by_id(res[1]['seriesid']) end else if !res[1].nil? return @tvdb.get_series_by_id(res[1]['seriesid']) elsif !res[2].nil? return @tvdb.get_series_by_id(res[2]['seriesid']) end end return nil end
find_plot(show_obj)
click to toggle source
# File lib/nokaya/tvshow.rb, line 76 def find_plot(show_obj) show_obj.overview end
find_poster_url(show_obj)
click to toggle source
# File lib/nokaya/tvshow.rb, line 66 def find_poster_url(show_obj) poster = show_obj.posters(@language).first return poster.url end
name_files()
click to toggle source
# File lib/nokaya/tvshow.rb, line 32 def name_files @urls.map do |url| "#{@type.to_s}-#{name}-#{File.basename(url)}" end end