coming_soon 0.2.6 → 0.2.7
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 +4 -4
- data/lib/coming_soon/cli.rb +11 -2
- data/lib/coming_soon/movie.rb +5 -0
- data/lib/coming_soon/scraper.rb +29 -19
- data/lib/coming_soon/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 242f7827f948dbbd75f534ceaa60c661d1741731
|
|
4
|
+
data.tar.gz: 1387044856785ff15f6fa45a9f201bf3e8137f04
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 70ffb04bb8bfde73301e0f570f4254068bc67ac589e97088b549da333fb6196098339da2356869118b1127f5a9982e8fbf317b0b8181200518be70d4f720a38b
|
|
7
|
+
data.tar.gz: bdefe6ba38cf756f2e81260c9a4d5761f1c1f24a60b0b776cec30e614aecb8a8dae352239ec07bffa23535daa4be6f602c454d261530ee87f36f1ceb3c448d27
|
data/lib/coming_soon/cli.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
class ComingSoon::CLI
|
|
2
2
|
|
|
3
3
|
def call
|
|
4
|
+
|
|
4
5
|
puts ''
|
|
5
6
|
puts ' **************************'
|
|
6
7
|
puts ' * Movies Coming Soon *'
|
|
@@ -9,9 +10,10 @@ class ComingSoon::CLI
|
|
|
9
10
|
puts ' **************************'
|
|
10
11
|
puts ''
|
|
11
12
|
|
|
12
|
-
ComingSoon::Scraper.scrape_movies
|
|
13
|
+
ComingSoon::Scraper.new.scrape_movies
|
|
13
14
|
get_and_list_movies
|
|
14
15
|
menu_selection
|
|
16
|
+
|
|
15
17
|
end
|
|
16
18
|
|
|
17
19
|
def get_and_list_movies
|
|
@@ -19,9 +21,11 @@ class ComingSoon::CLI
|
|
|
19
21
|
ComingSoon::Movie.movies.each.with_index(1) do |movie, i| # set the first index to 1 and use the index number for the movie number
|
|
20
22
|
puts "#{i}. #{movie.name} - #{movie.start_date}"
|
|
21
23
|
end
|
|
24
|
+
|
|
22
25
|
end
|
|
23
26
|
|
|
24
27
|
def list_saved_movies
|
|
28
|
+
|
|
25
29
|
puts ''
|
|
26
30
|
puts ' **************************'
|
|
27
31
|
puts ' * Movies Coming Soon *'
|
|
@@ -31,9 +35,11 @@ class ComingSoon::CLI
|
|
|
31
35
|
ComingSoon::Movie.movies.each.with_index(1) do |movie, i| # set the first index to 1 and use the index number for the movie number
|
|
32
36
|
puts "#{i}. #{movie.name} - #{movie.start_date}"
|
|
33
37
|
end
|
|
38
|
+
|
|
34
39
|
end
|
|
35
40
|
|
|
36
41
|
def menu_selection
|
|
42
|
+
|
|
37
43
|
input = ''
|
|
38
44
|
|
|
39
45
|
while input != 'exit'
|
|
@@ -53,10 +59,12 @@ class ComingSoon::CLI
|
|
|
53
59
|
puts 'Invalid selection!'
|
|
54
60
|
menu_selection
|
|
55
61
|
end
|
|
56
|
-
end
|
|
62
|
+
end
|
|
63
|
+
|
|
57
64
|
end
|
|
58
65
|
|
|
59
66
|
def goodbye
|
|
67
|
+
|
|
60
68
|
puts ''
|
|
61
69
|
puts ' ***************************'
|
|
62
70
|
puts ' * Thank you and goodbye *'
|
|
@@ -66,6 +74,7 @@ class ComingSoon::CLI
|
|
|
66
74
|
puts ''
|
|
67
75
|
|
|
68
76
|
exit
|
|
77
|
+
|
|
69
78
|
end
|
|
70
79
|
|
|
71
80
|
end
|
data/lib/coming_soon/movie.rb
CHANGED
data/lib/coming_soon/scraper.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
class ComingSoon::Scraper
|
|
2
2
|
|
|
3
|
-
def
|
|
3
|
+
def scrape_movies
|
|
4
4
|
|
|
5
5
|
doc = Nokogiri::HTML(open("http://www.fandango.com/moviescomingsoon"))
|
|
6
6
|
# name: doc.css("li.visual-item a.visual-title").text.strip
|
|
@@ -17,38 +17,48 @@ class ComingSoon::Scraper
|
|
|
17
17
|
soon.start_date = movie.css("span").text
|
|
18
18
|
soon.url = movie.css("a").attribute("href").value
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
scrape_details(soon)
|
|
21
21
|
|
|
22
22
|
count+=1
|
|
23
|
-
if count > 19 #
|
|
23
|
+
if count > 19 # Scrapes only 20 movies
|
|
24
24
|
break
|
|
25
25
|
end
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
-
def
|
|
31
|
-
|
|
30
|
+
def scrape_details(soon)
|
|
31
|
+
|
|
32
32
|
redirect_failed = false
|
|
33
33
|
|
|
34
34
|
begin
|
|
35
|
-
|
|
35
|
+
doc_synop1 = Nokogiri::HTML(open(soon.url)) # Uses the HTTP 'movieoverview' url
|
|
36
36
|
rescue
|
|
37
|
-
redirect_failed = true #
|
|
37
|
+
redirect_failed = true # A HTTP to HTTPS redirect failed
|
|
38
38
|
end
|
|
39
|
-
|
|
40
|
-
if
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
39
|
+
|
|
40
|
+
if !redirect_failed
|
|
41
|
+
if !doc_synop1.css("a.movie-synopsis-link").any? &&
|
|
42
|
+
doc_synop1.css("span#SynopsisTextLabel").any?
|
|
43
|
+
# If a READ FULL SYNOPSIS link is not present and any
|
|
44
|
+
# text is available, use that text for the synopsis
|
|
45
|
+
soon.synopsis = doc_synop1.css("span#SynopsisTextLabel").text
|
|
46
|
+
else
|
|
47
|
+
scrape_plotsummary(soon)
|
|
48
|
+
end
|
|
45
49
|
else
|
|
46
|
-
|
|
47
|
-
# This is also executed after an HTTP to HTTPS redirect failed
|
|
48
|
-
synop_url = soon.url.sub(/movieoverview/, 'plotsummary')
|
|
49
|
-
doc_synop2 = Nokogiri::HTML(open(synop_url))
|
|
50
|
-
soon.synopsis = doc_synop2.css("p.subpage-descriptive-content").text
|
|
50
|
+
scrape_plotsummary(soon)
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
end
|
|
54
|
-
|
|
54
|
+
|
|
55
|
+
def scrape_plotsummary(soon)
|
|
56
|
+
# Scrape the synopsis using the HTTP 'plotsummary' url
|
|
57
|
+
# This is also executed after an HTTP to HTTPS redirect failed
|
|
58
|
+
synop_url = soon.url.sub(/movieoverview/, 'plotsummary')
|
|
59
|
+
doc_synop2 = Nokogiri::HTML(open(synop_url))
|
|
60
|
+
soon.synopsis = doc_synop2.css("p.subpage-descriptive-content").text
|
|
61
|
+
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
end
|
data/lib/coming_soon/version.rb
CHANGED