bootleg 0.0.4 → 0.0.5
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.
- data/Gemfile +2 -1
- data/README.md +42 -2
- data/bootleg.gemspec +1 -0
- data/lib/bootleg.rb +1 -1
- data/lib/bootleg/version.rb +1 -1
- data/lib/extractor.rb +1 -0
- data/lib/generators/bootleg/USAGE +0 -0
- data/lib/generators/bootleg/install_generator.rb +15 -0
- data/lib/generators/bootleg/movie_generator.rb +24 -0
- data/lib/generators/bootleg/showtime_generator.rb +24 -0
- data/lib/generators/bootleg/templates/movie_migration.rb +11 -0
- data/lib/generators/bootleg/templates/movie_model.rb +10 -0
- data/lib/generators/bootleg/templates/showtime_migration.rb +11 -0
- data/lib/generators/bootleg/templates/showtime_model.rb +14 -0
- data/lib/generators/bootleg/templates/theater_migration.rb +10 -0
- data/lib/generators/bootleg/templates/theater_model.rb +10 -0
- data/lib/generators/bootleg/theater_generator.rb +24 -0
- data/lib/modules/movie.rb +6 -4
- data/lib/modules/theater.rb +16 -0
- data/spec/presenter_spec.rb +0 -3
- metadata +29 -2
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# Bootleg
|
2
2
|
|
3
|
-
|
3
|
+
Bootleg is a basic scraper. It scrapes movie, theater and showtime
|
4
|
+
details from moviefone.com based on a certain zipcode for a 25 mile
|
5
|
+
radius.
|
4
6
|
|
5
7
|
## Installation
|
6
8
|
|
@@ -16,9 +18,43 @@ Or install it yourself as:
|
|
16
18
|
|
17
19
|
$ gem install bootleg
|
18
20
|
|
21
|
+
Generate models and migrations:
|
22
|
+
|
23
|
+
$ rails generate bootleg:install
|
24
|
+
|
19
25
|
## Usage
|
20
26
|
|
21
|
-
|
27
|
+
Load content for a certain zipcode:
|
28
|
+
|
29
|
+
Example:
|
30
|
+
|
31
|
+
Bootleg.load('21102')
|
32
|
+
|
33
|
+
This will load all the movies for a 25 mile radius(including their showtimes
|
34
|
+
and the theaters where they play).
|
35
|
+
|
36
|
+
Examples:
|
37
|
+
|
38
|
+
movie = BootlegMovie.where(name: 'Example').first
|
39
|
+
|
40
|
+
Get all the theaters where the movie is played:
|
41
|
+
|
42
|
+
theaters = movie.theaters
|
43
|
+
|
44
|
+
Get all the showtimes:
|
45
|
+
|
46
|
+
showtimes = movie.showtimes
|
47
|
+
|
48
|
+
Get the theater of the showtimes:
|
49
|
+
|
50
|
+
theater = showtimes.first.theater
|
51
|
+
|
52
|
+
|
53
|
+
The content is stored in 3 Active Record models BootlegMovie,
|
54
|
+
BootlegTheater and BootlegShowtime. After you load a zipcode just start
|
55
|
+
a rails console and take a look at the models to see what information is
|
56
|
+
stored inside.
|
57
|
+
|
22
58
|
|
23
59
|
## Contributing
|
24
60
|
|
@@ -27,3 +63,7 @@ TODO: Write usage instructions here
|
|
27
63
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
64
|
4. Push to the branch (`git push origin my-new-feature`)
|
29
65
|
5. Create new Pull Request
|
66
|
+
|
67
|
+
If there is other content that you would like to pull it is relatively easy
|
68
|
+
to build a new feature to extract it. If you would like to contribute
|
69
|
+
and need help feel free to shoot me an email at marius@mlpinit.com .
|
data/bootleg.gemspec
CHANGED
data/lib/bootleg.rb
CHANGED
data/lib/bootleg/version.rb
CHANGED
data/lib/extractor.rb
CHANGED
@@ -17,6 +17,7 @@ class Extractor
|
|
17
17
|
def extract_movies
|
18
18
|
theaters.each do |theater|
|
19
19
|
theater.extend Theater
|
20
|
+
BootlegTheater.create!(name: theater.name, href: theater.link)
|
20
21
|
theater_info = { name: theater.name, href: theater.link, movies: theater.movies}
|
21
22
|
@page_theaters << theater_info
|
22
23
|
end
|
File without changes
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rails/generators/migration'
|
2
|
+
|
3
|
+
module Bootleg
|
4
|
+
module Generators
|
5
|
+
class InstallGenerator < Rails::Generators::Base
|
6
|
+
source_root File.expand_path('../templates', __FILE__)
|
7
|
+
|
8
|
+
def run_generators
|
9
|
+
generate "bootleg:movie"
|
10
|
+
generate "bootleg:theater"
|
11
|
+
generate "bootleg:showtime"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'rails/generators/migration'
|
2
|
+
|
3
|
+
module Bootleg
|
4
|
+
module Generators
|
5
|
+
class MovieGenerator < Rails::Generators::Base
|
6
|
+
include Rails::Generators::Migration
|
7
|
+
|
8
|
+
source_root File.expand_path('../templates', __FILE__)
|
9
|
+
|
10
|
+
def generate_movie_migration
|
11
|
+
migration_template "movie_migration.rb", "db/migrate/create_bootleg_movies.rb"
|
12
|
+
end
|
13
|
+
|
14
|
+
def generate_movie_model
|
15
|
+
copy_file "movie_model.rb", "app/models/bootleg_movie.rb"
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.next_migration_number(path)
|
19
|
+
@migration_number = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i.to_s
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'rails/generators/migration'
|
2
|
+
|
3
|
+
module Bootleg
|
4
|
+
module Generators
|
5
|
+
class ShowtimeGenerator < Rails::Generators::Base
|
6
|
+
include Rails::Generators::Migration
|
7
|
+
|
8
|
+
source_root File.expand_path('../templates', __FILE__)
|
9
|
+
|
10
|
+
def generate_theater_movie_migration
|
11
|
+
migration_template "showtime_migration.rb", "db/migrate/create_bootleg_showtimes.rb"
|
12
|
+
end
|
13
|
+
|
14
|
+
def generate_theater_movie_model
|
15
|
+
copy_file "showtime_model.rb", "app/models/bootleg_showtime.rb"
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.next_migration_number(path)
|
19
|
+
@migration_number = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i.to_s
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class BootlegShowtime < ActiveRecord::Base
|
2
|
+
attr_accessible :bootleg_movie_id, :bootleg_theater_id, :showtimes
|
3
|
+
|
4
|
+
belongs_to :bootleg_movie
|
5
|
+
belongs_to :bootleg_theater
|
6
|
+
|
7
|
+
def theater
|
8
|
+
bootleg_theater
|
9
|
+
end
|
10
|
+
|
11
|
+
def movie
|
12
|
+
bootleg_movie
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'rails/generators/migration'
|
2
|
+
|
3
|
+
module Bootleg
|
4
|
+
module Generators
|
5
|
+
class TheaterGenerator < Rails::Generators::Base
|
6
|
+
include Rails::Generators::Migration
|
7
|
+
|
8
|
+
source_root File.expand_path('../templates', __FILE__)
|
9
|
+
|
10
|
+
def generate_theater_migration
|
11
|
+
migration_template "theater_migration.rb", "db/migrate/create_bootleg_theaters.rb"
|
12
|
+
end
|
13
|
+
|
14
|
+
def generate_theater_model
|
15
|
+
copy_file "theater_model.rb", "app/models/bootleg_theater.rb"
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.next_migration_number(path)
|
19
|
+
@migration_number = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i.to_s
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
data/lib/modules/movie.rb
CHANGED
@@ -1,8 +1,4 @@
|
|
1
1
|
module Movie
|
2
|
-
def details
|
3
|
-
self.css('div.movietitle')
|
4
|
-
end
|
5
|
-
|
6
2
|
def name
|
7
3
|
details.css('a').text.strip
|
8
4
|
end
|
@@ -19,4 +15,10 @@ module Movie
|
|
19
15
|
end
|
20
16
|
values
|
21
17
|
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def details
|
22
|
+
self.css('div.movietitle')
|
23
|
+
end
|
22
24
|
end
|
data/lib/modules/theater.rb
CHANGED
@@ -12,10 +12,12 @@ module Theater
|
|
12
12
|
def movies
|
13
13
|
movies = self.css('div.movie-listing.first')
|
14
14
|
values = []
|
15
|
+
theater = BootlegTheater.last
|
15
16
|
movies.each do |movie|
|
16
17
|
movie.extend Movie
|
17
18
|
movie_info = { name: movie.name, href: movie.link, showtimes: movie.showtimes }
|
18
19
|
values << movie_info
|
20
|
+
insert_movies(theater,movie)
|
19
21
|
end
|
20
22
|
values
|
21
23
|
end
|
@@ -24,4 +26,18 @@ module Theater
|
|
24
26
|
def details
|
25
27
|
self.css('h3.title').css('a')
|
26
28
|
end
|
29
|
+
|
30
|
+
def insert_movies(theater, movie)
|
31
|
+
existing_movie = BootlegMovie.where(name: movie.name).first
|
32
|
+
if existing_movie
|
33
|
+
showtime = theater.bootleg_showtimes.new
|
34
|
+
showtime.bootleg_movie_id = existing_movie.id
|
35
|
+
showtime.save
|
36
|
+
else
|
37
|
+
theater.movies.create!(name: movie.name, href: movie.link)
|
38
|
+
end
|
39
|
+
showtime = BootlegShowtime.last
|
40
|
+
showtime.showtimes = movie.showtimes.to_s.gsub(/-/, '').gsub(/\n/,'').strip
|
41
|
+
showtime.save
|
42
|
+
end
|
27
43
|
end
|
data/spec/presenter_spec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bootleg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-11-
|
12
|
+
date: 2012-11-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
@@ -43,6 +43,22 @@ dependencies:
|
|
43
43
|
- - ! '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: activerecord
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
46
62
|
- !ruby/object:Gem::Dependency
|
47
63
|
name: rspec
|
48
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -78,6 +94,17 @@ files:
|
|
78
94
|
- lib/bootleg/version.rb
|
79
95
|
- lib/extractor.rb
|
80
96
|
- lib/finder.rb
|
97
|
+
- lib/generators/bootleg/USAGE
|
98
|
+
- lib/generators/bootleg/install_generator.rb
|
99
|
+
- lib/generators/bootleg/movie_generator.rb
|
100
|
+
- lib/generators/bootleg/showtime_generator.rb
|
101
|
+
- lib/generators/bootleg/templates/movie_migration.rb
|
102
|
+
- lib/generators/bootleg/templates/movie_model.rb
|
103
|
+
- lib/generators/bootleg/templates/showtime_migration.rb
|
104
|
+
- lib/generators/bootleg/templates/showtime_model.rb
|
105
|
+
- lib/generators/bootleg/templates/theater_migration.rb
|
106
|
+
- lib/generators/bootleg/templates/theater_model.rb
|
107
|
+
- lib/generators/bootleg/theater_generator.rb
|
81
108
|
- lib/manager.rb
|
82
109
|
- lib/modules/href.rb
|
83
110
|
- lib/modules/movie.rb
|