Class: Ayadn::TvShow
Constant Summary collapse
- TVDB_API_KEY =
'E874ACBC542CAA53'
Instance Attribute Summary collapse
-
#banner_url ⇒ Object
Returns the value of attribute banner_url.
-
#date ⇒ Object
Returns the value of attribute date.
-
#imdb_link ⇒ Object
Returns the value of attribute imdb_link.
-
#language ⇒ Object
Returns the value of attribute language.
-
#link ⇒ Object
Returns the value of attribute link.
-
#name ⇒ Object
Returns the value of attribute name.
-
#plot ⇒ Object
Returns the value of attribute plot.
-
#poster_url ⇒ Object
Returns the value of attribute poster_url.
-
#tag ⇒ Object
Returns the value of attribute tag.
-
#text ⇒ Object
Returns the value of attribute text.
Instance Method Summary collapse
- #cancel ⇒ Object
- #create_details(show_obj) ⇒ Object
- #create_text ⇒ Object
- #find(title) ⇒ Object
- #find_alt(title) ⇒ Object
-
#initialize ⇒ TvShow
constructor
A new instance of TvShow.
- #ok ⇒ Object
- #post(options = {}) ⇒ Object
Constructor Details
Instance Attribute Details
#banner_url ⇒ Object
Returns the value of attribute banner_url.
20 21 22 |
# File 'lib/ayadn/tvshow.rb', line 20 def @banner_url end |
#date ⇒ Object
Returns the value of attribute date.
20 21 22 |
# File 'lib/ayadn/tvshow.rb', line 20 def date @date end |
#imdb_link ⇒ Object
Returns the value of attribute imdb_link.
20 21 22 |
# File 'lib/ayadn/tvshow.rb', line 20 def imdb_link @imdb_link end |
#language ⇒ Object
Returns the value of attribute language.
20 21 22 |
# File 'lib/ayadn/tvshow.rb', line 20 def language @language end |
#link ⇒ Object
Returns the value of attribute link.
20 21 22 |
# File 'lib/ayadn/tvshow.rb', line 20 def link @link end |
#name ⇒ Object
Returns the value of attribute name.
20 21 22 |
# File 'lib/ayadn/tvshow.rb', line 20 def name @name end |
#plot ⇒ Object
Returns the value of attribute plot.
20 21 22 |
# File 'lib/ayadn/tvshow.rb', line 20 def plot @plot end |
#poster_url ⇒ Object
Returns the value of attribute poster_url.
20 21 22 |
# File 'lib/ayadn/tvshow.rb', line 20 def poster_url @poster_url end |
#tag ⇒ Object
Returns the value of attribute tag.
20 21 22 |
# File 'lib/ayadn/tvshow.rb', line 20 def tag @tag end |
#text ⇒ Object
Returns the value of attribute text.
20 21 22 |
# File 'lib/ayadn/tvshow.rb', line 20 def text @text end |
Instance Method Details
#cancel ⇒ Object
126 127 128 129 |
# File 'lib/ayadn/tvshow.rb', line 126 def cancel @status.canceled exit end |
#create_details(show_obj) ⇒ Object
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/ayadn/tvshow.rb', line 59 def create_details show_obj @name = show_obj.name @poster_url = find_poster_url(show_obj) @banner_url = (show_obj) @plot = find_plot(show_obj) @date = show_obj.first_aired.year @imdb_link = "http://imdb.com/title/#{show_obj.imdb_id}/" create_text() return self end |
#create_text ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/ayadn/tvshow.rb', line 70 def create_text @link = "[IMDb](#{@imdb_link})" @tag = Settings.[:tvshow][:hashtag] @date.nil? ? date = '' : date = "(#{@date})" pre = "#{@name} #{date}\n \n" presize = pre.length + @tag.length + 4 + @plot.length max = 241 if presize > max plot_max = max - (pre.length + @tag.length) @text = "#{pre}#{@plot[0..plot_max]}...\n \n#{@link}\n \n##{@tag}" else @text = "#{pre}#{@plot}\n \n#{@link}\n \n##{@tag}" end end |
#find(title) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/ayadn/tvshow.rb', line 29 def find title res = find_all(title) if res[0].nil? @status.no_show exit end if res[0].has_key?('FirstAired') return @tvdb.get_series_by_id(res[0]['seriesid']) else return @tvdb.get_series_by_id(res[1]['seriesid']) unless res[1].nil? end @status.no_show exit end |
#find_alt(title) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/ayadn/tvshow.rb', line 44 def find_alt title res = find_all(title) if res[0].nil? @status.no_show exit end if res[0].has_key?('FirstAired') return @tvdb.get_series_by_id(res[1]['seriesid']) unless res[1].nil? else return @tvdb.get_series_by_id(res[2]['seriesid']) unless res[2].nil? end @status.no_show exit end |
#ok ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/ayadn/tvshow.rb', line 85 def ok @view.clear_screen @status.writing @status.to_be_posted thor = Thor::Shell::Basic.new puts "\n" @text.split("\n").each do |line| thor.say_status(nil, line.color(Settings.[:colors][:excerpt])) end puts "\n" @status.ok? STDIN.getch == ("y" || "Y") ? true : false end |
#post(options = {}) ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/ayadn/tvshow.rb', line 99 def post = {} = .dup reg = /[~:-;,?!\'&`^=+<>*%()\/"“”’°£$€.…]/ filename = "#{@name.downcase.strip.gsub(reg, '_').split(' ').join('_')}.jpg" if ['banner'] FileOps.download_url(filename, @banner_url) else FileOps.download_url(filename, @poster_url) end @view.clear_screen @status.info("uploading", "show poster", "yellow") [:embed] = ["#{Settings.config[:paths][:downloads]}/#{filename}"] [:tvshow] = true dic = { options: , text: @text, title: @name, source: 'TVDb' } resp = Post.new.post(dic) FileOps.save_post(resp) if Settings.[:backup][:posts] @view.clear_screen @status.yourpost puts "\n\n" @view.show_posted(resp) end |