what_to_watch 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8ab76582498e810e9b39c700e7e7a0e7a364eb82624cdefac298f6956922fed5
4
- data.tar.gz: 797a9fbe7264072c45630225cb5a42b4d29516f1a9234192d219c6df7fc1ccba
3
+ metadata.gz: 521f776ffe57dcfbe105147665f64ee75fd73a70ca238ad76f89ebf1559eb53c
4
+ data.tar.gz: f4604c401b13b9e33dcd4fbd64eb380bb3b3ab0b4378b65bf6e8e27efa31f070
5
5
  SHA512:
6
- metadata.gz: 0fdb3956132b494e1c354488ab8ddb880ff3d27c5a32c162c5f6ca9ffaa98cefa5e6a2ffe0116eb675ce13a451a7e5769034560deddc2319a8d932febe3dfbeb
7
- data.tar.gz: 997a43210c9196a1ccfae0dfb311ce0c6ed6fe0500677273e9bd0d532f11a8af3433aef621ef97d30cf86eb2547949f0ae135108c47579579bbbdf885a0d9c56
6
+ metadata.gz: 26bee8b947627793029065510a83a6b6808ef5477bb665f4723d5b6654a45bbac58f6a0f2c15344876ce0175c3ad81a33a8c6d12d50d3f182879f197378740e8
7
+ data.tar.gz: f2bfa8da7b51c7edf7726be8fab9f045c039e96180f25fdc9827d7508be45bbdb659dbe1bdc51328875ca98fc06bf973df122d2c057a5ee456f6c816943ee0bb
data/.DS_Store CHANGED
Binary file
@@ -10,9 +10,6 @@ def reload!
10
10
  puts "Reloading ..."
11
11
  load "./lib/what_to_watch.rb"
12
12
  load "./lib/what_to_watch/cli.rb"
13
- load "./lib/what_to_watch/best_movies.rb"
14
- load "./lib/what_to_watch/recently_added.rb"
15
- load "./lib/what_to_watch/best_tv.rb"
16
13
  load "./lib/what_to_watch/scraper.rb"
17
14
  load "./lib/what_to_watch/show.rb"
18
15
  end
Binary file
@@ -12,7 +12,3 @@ require "what_to_watch/version"
12
12
  require "what_to_watch/cli"
13
13
  require "what_to_watch/scraper"
14
14
  require "what_to_watch/show"
15
- require "what_to_watch/best_movies"
16
- require "what_to_watch/best_tv"
17
- require "what_to_watch/recently_added"
18
-
@@ -1,5 +1,4 @@
1
1
  class WhatToWatch::CLI
2
- attr_accessor :input, :streaming_services
3
2
 
4
3
  def initialize
5
4
  @input = ""
@@ -25,86 +24,43 @@ class WhatToWatch::CLI
25
24
 
26
25
  def start
27
26
  which_streaming_services
27
+ WhatToWatch::Scraper.scrape_vulture
28
28
  while !exit?
29
29
  catch(:main_menu) do
30
- main_commands
31
- while !exit?
32
- case @input
33
- when "1"
34
- WhatToWatch::BestMovies.add_shows
35
- WhatToWatch::BestMovies.list(@streaming_services)
36
- options
37
- while !exit?
38
- if valid_number?(WhatToWatch::BestMovies.all)
39
- WhatToWatch::BestMovies.print_item(@input)
40
- item_options
30
+ main_commands
31
+ case @input
32
+ when "1", "2", "3", "4"
33
+ print_list
41
34
  while !exit?
42
- if @input == "y"
43
35
  options
44
- break
45
- elsif @input == "n"
46
- throw(:main_menu)
47
- else
48
- invalid_command
49
- end
50
- end
51
- else
52
- invalid_command
53
- end
54
- end
55
- when "2"
56
- WhatToWatch::BestTV.add_shows
57
- WhatToWatch::BestTV.list(@streaming_services)
58
- options
59
- while !exit?
60
- if valid_number?(WhatToWatch::BestTV.all)
61
- WhatToWatch::BestTV.print_item(@input)
62
- item_options
63
- while !exit?
64
- if @input == "y"
65
- options
66
- break
67
- elsif @input == "n"
68
- throw(:main_menu)
69
- else
70
- invalid_command
71
- end
72
- end
73
- else
74
- invalid_command
75
- end
76
- end
77
- when "3"
78
- WhatToWatch::RecentlyAdded.add_shows
79
- WhatToWatch::RecentlyAdded.list(@streaming_services)
80
- options
81
- while !exit?
82
- if valid_number?(WhatToWatch::RecentlyAdded.all)
83
- WhatToWatch::RecentlyAdded.print_item(@input)
84
- item_options
85
- while !exit?
86
- if @input == "y"
87
- options
88
- break
89
- elsif @input == "n"
90
- throw(:main_menu)
91
- else
92
- invalid_command
93
- end
36
+ if valid_number?(WhatToWatch::Show.filtered)
37
+ print_item
38
+ while !exit?
39
+ item_options
40
+ if @input == "y"
41
+ break
42
+ elsif @input == "n"
43
+ throw(:main_menu)
44
+ else
45
+ invalid_command
46
+ end
47
+ end
48
+ else
49
+ invalid_command
50
+ end
94
51
  end
95
52
  else
96
- invalid_command
97
- end
53
+ invalid_command
98
54
  end
99
- else
100
- invalid_command
101
- end
102
- end
103
55
  end
104
56
  end
105
57
  exit
106
58
  end
59
+
60
+
61
+ private
107
62
 
63
+
108
64
  #CLI Dialogue Methods
109
65
 
110
66
  def main_commands
@@ -112,9 +68,10 @@ class WhatToWatch::CLI
112
68
  puts "---------"
113
69
  puts "MAIN MENU:"
114
70
  puts "---------"
115
- puts "1. Enter 1 to see the Best-Reviewed MOVIES you can stream now."
71
+ puts "1. Enter 1 to see Recently-Added MOVIES/TELEVISION you can stream now."
116
72
  puts "2. Enter 2 to see the Best-Reviewed TELEVISION you can stream now."
117
- puts "3. Enter 3 to see Recently-Added MOVIES/TELEVISION you can stream now."
73
+ puts "3. Enter 3 to see the Best-Reviewed MOVIES you can stream now."
74
+ puts "4. Enter 4 to see Leaving-Soon MOVIES/TELEVISION you can stream now."
118
75
  puts ""
119
76
  puts "Exit: Type exit"
120
77
  puts "---------------"
@@ -154,7 +111,6 @@ class WhatToWatch::CLI
154
111
  puts "I'm sorry, I don't recognize that Command."
155
112
  puts "Please Try Again"
156
113
  puts ""
157
- @input = gets.strip.downcase
158
114
  end
159
115
 
160
116
  def exit
@@ -162,6 +118,7 @@ class WhatToWatch::CLI
162
118
  puts "**********************************************************"
163
119
  puts "See You Next Time for More Great Movie/TV Recommendations!"
164
120
  puts "**********************************************************"
121
+ puts ""
165
122
  end
166
123
 
167
124
  def which_streaming_services
@@ -246,6 +203,79 @@ class WhatToWatch::CLI
246
203
  end
247
204
  end
248
205
 
206
+ #CLI Format Methods
207
+
208
+ def format_services
209
+ services = @streaming_services.collect do |service, value|
210
+ if value == "y"
211
+ service.to_s.split('_').join(' ').capitalize
212
+ end
213
+ end
214
+ services.compact!
215
+ services
216
+ end
217
+
218
+ #CLI Print Methods
219
+
220
+ def print_list
221
+ category = ""
222
+ banner = ""
223
+ case @input
224
+ when "1"
225
+ category = "added"
226
+ banner = "Recently-Added/Coming-Soon"
227
+ when "2"
228
+ category = "tv"
229
+ banner = "Best Reviewed Television"
230
+ when "3"
231
+ category = "movies"
232
+ banner = "Best Reviewed Movies"
233
+ when "4"
234
+ category = "expiring"
235
+ banner = "Leaving Soon"
236
+ end
237
+ puts ""
238
+ puts "============================"
239
+ puts " #{banner} "
240
+ puts "============================"
241
+ puts ""
242
+ WhatToWatch::Show.filter(category)
243
+ WhatToWatch::Show.filtered.each.with_index(1) do |recommendation, index|
244
+ if format_services.include?(recommendation.streaming_service)
245
+ puts ""
246
+ puts "Available! #{index}. #{recommendation.title.upcase}. Watch Now on #{recommendation.streaming_service.capitalize}."
247
+ puts ""
248
+ else
249
+ puts ""
250
+ puts "Sorry..... #{index}. #{recommendation.title.upcase}. Only on #{recommendation.streaming_service.capitalize}."
251
+ puts ""
252
+ end
253
+ end
254
+ end
255
+
256
+ def print_item
257
+ item = WhatToWatch::Show.filtered[@input.to_i-1]
258
+ WhatToWatch::Scraper.scrape_imdb(item) if item.url == nil
259
+ puts ""
260
+ puts "===================================="
261
+ puts " #{item.title.upcase}"
262
+ puts "===================================="
263
+ puts "#{item.genre_year}"
264
+ puts ""
265
+ puts "*** Available on #{item.streaming_service.upcase} ***"
266
+ puts ""
267
+ item.cast.each{|role, people| puts "#{role} #{people}"}
268
+ puts ""
269
+ puts "---Description---"
270
+ puts ""
271
+ puts "#{item.description}"
272
+ puts "[...]"
273
+ puts ""
274
+ puts "For more information"
275
+ puts ""
276
+ puts "===> #{item.url}"
277
+ end
278
+
249
279
  #CLI Logic Methods
250
280
 
251
281
  def exit?
@@ -1,17 +1,19 @@
1
1
  class WhatToWatch::Scraper
2
2
 
3
3
 
4
- def self.scrape_vulture(model)
4
+ def self.scrape_vulture
5
5
  doc = Nokogiri::HTML(open("http://vulture.com/streaming"))
6
- block = doc.css("div[data-editable='main']")[model.section]
7
- block.css("div.column-item").each do |row|
8
- row.css("section").drop(1).each do |item|
9
- model.new(
10
- item.css("div[itemprop='caption']").text.split("\n")[1].strip.gsub(" ", " "),
11
- row.css("section")[0].css("h3").text.strip.capitalize
12
- )
13
- end
14
- end
6
+ doc.css("div[data-editable='main']").each do |section|
7
+ section.css("div.column-item").each do |row|
8
+ row.css("section").drop(1).each do |item|
9
+ WhatToWatch::Show.new(
10
+ item.css("div[itemprop='caption']").text.split("\n")[1].strip.gsub(" ", " "),
11
+ row.css("section")[0].css("h3").text.strip.capitalize,
12
+ section.css("h2.clay-subheader").text.strip.downcase
13
+ )
14
+ end
15
+ end
16
+ end
15
17
  end
16
18
 
17
19
  #Scrape Search Page on imdb.com to determine the Item Page URL
@@ -1,69 +1,28 @@
1
1
  class WhatToWatch::Show
2
- attr_accessor :title, :streaming_service, :url, :description, :genre_year, :cast
2
+ attr_accessor :title, :streaming_service, :category, :url, :description, :genre_year, :cast
3
3
 
4
4
  # WhatToWatch::BestMovies.add_shows
5
5
  # WhatToWatch::BestMovies.list()
6
6
  # {netflix: "y", amazon_prime: "y", hbo_now: "y", hulu: "y", showtime: "y"}
7
7
 
8
- def initialize(title="", streaming_service="")
8
+ @@all = []
9
+ @@filtered = []
10
+
11
+
12
+ def initialize(title="", streaming_service="", category= "")
9
13
  @title = title
10
14
  @streaming_service = streaming_service
11
- self.class.all << self
15
+ @category = category
16
+ @@all << self
12
17
  end
13
18
 
14
- def self.add_shows
15
- WhatToWatch::Scraper.scrape_vulture(self) if self.all == []
19
+ def self.filter(selection)
20
+ @@filtered = @@all.select{|object| object.category.include?("#{selection}")}
16
21
  end
17
22
 
18
- #Determine Display Based On User Input Recorded in CLI.streaming_services
19
-
20
- def self.services(hash)
21
- services = hash.collect do |service, value|
22
- if value == "y"
23
- service.to_s.split('_').join(' ').capitalize
24
- end
25
- end
26
- services.compact!
27
- services
23
+ def self.filtered
24
+ @@filtered
28
25
  end
29
-
30
26
 
31
- def self.print_list(hash)
32
- self.all.each.with_index(1) do |object, index|
33
- if self.services(hash).include?(object.streaming_service)
34
- puts ""
35
- puts "Available! #{index}. #{object.title.upcase}. Watch Now on #{object.streaming_service}."
36
- puts ""
37
- else
38
- puts ""
39
- puts "Sorry..... #{index}. #{object.title.upcase}. Only on #{object.streaming_service}."
40
- puts ""
41
- end
42
- end
43
- end
44
-
45
-
46
- def self.print_item(input)
47
- object = self.all[input.to_i-1]
48
- WhatToWatch::Scraper.scrape_imdb(object) if object.url == nil
49
- puts ""
50
- puts "===================================="
51
- puts " #{object.title.upcase}"
52
- puts "===================================="
53
- puts "#{object.genre_year}"
54
- puts ""
55
- puts "*** Available on #{object.streaming_service.upcase} ***"
56
- puts ""
57
- object.cast.each{|role, people| puts "#{role} #{people}"}
58
- puts ""
59
- puts "---Description---"
60
- puts ""
61
- puts "#{object.description}"
62
- puts "[...]"
63
- puts ""
64
- puts "For more information"
65
- puts ""
66
- puts "===> #{object.url}"
67
- end
68
27
 
69
28
  end
@@ -1,3 +1,3 @@
1
1
  module WhatToWatch
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: what_to_watch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - "'George Pianka'"
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-10 00:00:00.000000000 Z
11
+ date: 2018-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -89,10 +89,7 @@ files:
89
89
  - bin/what_to_watch
90
90
  - lib/.DS_Store
91
91
  - lib/what_to_watch.rb
92
- - lib/what_to_watch/best_movies.rb
93
- - lib/what_to_watch/best_tv.rb
94
92
  - lib/what_to_watch/cli.rb
95
- - lib/what_to_watch/recently_added.rb
96
93
  - lib/what_to_watch/scraper.rb
97
94
  - lib/what_to_watch/show.rb
98
95
  - lib/what_to_watch/version.rb
@@ -1,23 +0,0 @@
1
- class WhatToWatch::BestMovies < WhatToWatch::Show
2
-
3
- @@all = []
4
-
5
- def self.all
6
- @@all
7
- end
8
-
9
- def self.section
10
- 3
11
- end
12
-
13
- def self.list(hash)
14
- puts ""
15
- puts "======================"
16
- puts " Best Reviewed Movies "
17
- puts "======================"
18
- puts ""
19
- self.print_list(hash)
20
- end
21
- end
22
-
23
-
@@ -1,22 +0,0 @@
1
- class WhatToWatch::BestTV < WhatToWatch::Show
2
-
3
- @@all = []
4
-
5
- def self.all
6
- @@all
7
- end
8
-
9
- def self.section
10
- 2
11
- end
12
-
13
- def self.list(hash)
14
- puts ""
15
- puts "=========================="
16
- puts " Best Reviewed Television "
17
- puts "=========================="
18
- puts ""
19
- self.print_list(hash)
20
- end
21
-
22
- end
@@ -1,22 +0,0 @@
1
- class WhatToWatch::RecentlyAdded < WhatToWatch::Show
2
-
3
- @@all = []
4
-
5
- def self.all
6
- @@all
7
- end
8
-
9
- def self.section
10
- 0
11
- end
12
-
13
- def self.list(hash)
14
- puts ""
15
- puts "=========================="
16
- puts " Recently Added Movies/TV "
17
- puts "=========================="
18
- puts ""
19
- self.print_list(hash)
20
- end
21
-
22
- end