picturehouse_uk 3.0.14 → 5.0.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 +5 -5
- data/.github/workflows/ci.yml +26 -0
- data/.github/workflows/release.yml +26 -0
- data/.gitignore +1 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +44 -0
- data/LICENSE +617 -0
- data/README.md +5 -4
- data/Rakefile +12 -0
- data/lib/picturehouse_uk/cinema.rb +152 -127
- data/lib/picturehouse_uk/internal/api.rb +42 -0
- data/lib/picturehouse_uk/internal/parser/address.rb +36 -9
- data/lib/picturehouse_uk/internal/parser/screenings.rb +89 -95
- data/lib/picturehouse_uk/internal/title_sanitizer.rb +61 -65
- data/lib/picturehouse_uk/internal/website.rb +10 -12
- data/lib/picturehouse_uk/performance.rb +60 -0
- data/lib/picturehouse_uk/version.rb +2 -2
- data/lib/picturehouse_uk.rb +3 -4
- data/picturehouse_uk.gemspec +5 -7
- data/rake/fixture_creator.rb +62 -0
- data/test/fixtures/cinemas.html +4262 -0
- data/test/fixtures/duke-of-york-s-picturehouse/cinema.html +6187 -0
- data/test/fixtures/duke-of-york-s-picturehouse/get_movies.json +120552 -0
- data/test/fixtures/duke-of-york-s-picturehouse/information.html +3725 -0
- data/test/fixtures/duke-s-at-komedia/cinema.html +6138 -0
- data/test/fixtures/duke-s-at-komedia/get_movies.json +112 -0
- data/test/fixtures/duke-s-at-komedia/information.html +3690 -0
- data/test/fixtures/home.html +6236 -565
- data/test/fixtures/phoenix-picturehouse/cinema.html +6089 -0
- data/test/fixtures/phoenix-picturehouse/get_movies.json +120552 -0
- data/test/fixtures/phoenix-picturehouse/information.html +3630 -0
- data/test/lib/picturehouse_uk/cinema_test.rb +113 -142
- data/test/lib/picturehouse_uk/internal/api_test.rb +92 -0
- data/test/lib/picturehouse_uk/internal/parser/{address_parser_test.rb → address_test.rb} +11 -11
- data/test/lib/picturehouse_uk/internal/parser/screenings_test.rb +100 -48
- data/test/lib/picturehouse_uk/internal/title_sanitizer_test.rb +48 -48
- data/test/lib/picturehouse_uk/internal/website_test.rb +15 -31
- data/test/lib/picturehouse_uk/performance_test.rb +197 -0
- data/test/lib/picturehouse_uk/version_test.rb +1 -1
- data/test/live/integration_test.rb +15 -32
- data/test/support/fake_api.rb +16 -0
- data/test/support/fake_website.rb +24 -0
- data/test/test_helper.rb +13 -2
- metadata +52 -67
- data/.rdoc_options +0 -16
- data/.travis.yml +0 -5
- data/lib/picturehouse_uk/film.rb +0 -59
- data/lib/picturehouse_uk/screening.rb +0 -70
- data/test/fixture_updater.rb +0 -73
- data/test/fixtures/cinema/Duke_Of_Yorks.html +0 -2984
- data/test/fixtures/cinema/Dukes_At_Komedia.html +0 -5518
- data/test/fixtures/cinema/National_Media_Museum.html +0 -10266
- data/test/fixtures/cinema/Phoenix_Picturehouse.html +0 -5202
- data/test/fixtures/info/Duke_Of_Yorks.html +0 -549
- data/test/fixtures/info/Dukes_At_Komedia.html +0 -537
- data/test/fixtures/info/Phoenix_Picturehouse.html +0 -553
- data/test/fixtures/whats_on/Duke_Of_Yorks.html +0 -2737
- data/test/fixtures/whats_on/Dukes_At_Komedia.html +0 -5132
- data/test/fixtures/whats_on/National_Media_Museum.html +0 -9690
- data/test/fixtures/whats_on/Phoenix_Picturehouse.html +0 -4916
- data/test/lib/picturehouse_uk/film_test.rb +0 -141
- data/test/lib/picturehouse_uk/screening_test.rb +0 -181
- /data/{LICENSE.txt → COMM-LICENSE} +0 -0
|
@@ -2,75 +2,71 @@ module PicturehouseUk
|
|
|
2
2
|
# @api private
|
|
3
3
|
module Internal
|
|
4
4
|
# Sanitize and standardize film titles
|
|
5
|
-
class TitleSanitizer
|
|
6
|
-
#
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
/\s+\(?[23][dD]\)?/, # 2d or 3d from title
|
|
11
|
-
/\bIMAX\b/i, # imax from title
|
|
12
|
-
/\s\[NO CERT\]/, # no certificate
|
|
13
|
-
/\s\[TBC\]/, # tbc
|
|
14
|
-
/\s\[N\/A\]/i, # n/a
|
|
15
|
-
/\s\(Theatre\)/i, # (theatre)
|
|
16
|
-
/\s\[\]/, # blank certificate
|
|
17
|
-
/ourscreen\: /, # ourscreen
|
|
18
|
-
/\s\(Re(\: \d{0,4})?\)/i, # Re-release
|
|
19
|
-
/\s\[CERT TBC\]/, # certificate TBC
|
|
20
|
-
/\s?\-\s?autism.*ing\s?/i, # austim screening
|
|
21
|
-
/\s?\+\s?Q\&A\.?/i, # +Q&A
|
|
22
|
-
/KIDS CLUB\s*/i, # kids club
|
|
23
|
-
/DISCOVER TUE(sday\:)*\s*/i, # discover tue
|
|
24
|
-
/FREE Screening\s*-\s*/i, # free screening
|
|
25
|
-
/\s*-?\s*Big Scream\s*-?\s*/i, # big scream
|
|
26
|
-
/\*?HOH Subtitled\*?/i, # subtitled
|
|
27
|
-
/\s*\-?\s*Reminiscence/i, # reminiscence
|
|
28
|
-
/\s*\-?\s*\(?Re\-issue\)?/i, # reissue
|
|
29
|
-
/\s*-?\s*Kids\'? Club\s*-?\s*/, # kids club
|
|
30
|
-
/\s*plus Q\&A.*/i, # extended Q&A
|
|
31
|
-
/Cinemania\s*[\:\-]/i, # cinemania
|
|
32
|
-
/\@\s*komedia/i, # @ komedia
|
|
33
|
-
/\s*\+ panel.*/i, # panel
|
|
34
|
-
/toddler time\s*\:*\-*/i, # toddler time
|
|
35
|
-
/\(.*\d{4}\)/, # year or captured year
|
|
36
|
-
/\bsingalong\b/i, # singalong
|
|
37
|
-
/\s+\-?\s*Parents \& Babies/i, # parents and babies
|
|
38
|
-
/Subtitled\:*\s*/i, # subtitled
|
|
39
|
-
/\(?live\)?\z/i, # live
|
|
40
|
-
]
|
|
5
|
+
class TitleSanitizer < Cinebase::TitleSanitizer
|
|
6
|
+
# @!method initialize(title)
|
|
7
|
+
# Constructor
|
|
8
|
+
# @param [String] title a film title
|
|
9
|
+
# @return [CineworldUk::Internal::TitleSanitizer]
|
|
41
10
|
|
|
42
|
-
#
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
/NT Encore:\s*(.*)/ => 'NT Live: ',
|
|
48
|
-
/NT Live:\s*(.*)/ => 'NT Live: ',
|
|
49
|
-
/ROH\.? Live:\s*(.*)/ => 'Royal Opera House: ',
|
|
50
|
-
/ROH\.? Encore:\s*(.*)/ => 'Royal Opera House: ',
|
|
51
|
-
/RSC\.? Live:\s*(.*)/ => 'Royal Shakespeare Company: ',
|
|
52
|
-
/RSC\.? Encore:\s*(.*)/ => 'Royal Shakespeare Company: ',
|
|
53
|
-
/(.*) \(Bolshoi Ballet\)/ => 'Bolshoi Ballet: '
|
|
54
|
-
}
|
|
11
|
+
# @!method sanitized
|
|
12
|
+
# sanitized and standardized title
|
|
13
|
+
# @return [String] sanitised title
|
|
14
|
+
|
|
15
|
+
private
|
|
55
16
|
|
|
56
|
-
#
|
|
57
|
-
def
|
|
58
|
-
|
|
17
|
+
# strings and regex to be removed
|
|
18
|
+
def remove
|
|
19
|
+
[
|
|
20
|
+
/\s\[(AS LIVE:\s*)?[ACPGU1258]+\]/, # regular certificate
|
|
21
|
+
/\s\[R18\]/, # R18
|
|
22
|
+
/\s+\(?[23][dD]\)?/, # 2d or 3d from title
|
|
23
|
+
/\bIMAX\b/i, # imax from title
|
|
24
|
+
/\s\[NO CERT\]/, # no certificate
|
|
25
|
+
/\s\[TBC\]/, # tbc
|
|
26
|
+
/\s\[N\/A\]/i, # n/a
|
|
27
|
+
/\s\(Theatre\)/i, # (theatre)
|
|
28
|
+
/\s\[\]/, # blank certificate
|
|
29
|
+
/ourscreen\: /, # ourscreen
|
|
30
|
+
/\s\(Re(\: \d{0,4})?\)/i, # Re-release
|
|
31
|
+
/\s\[CERT TBC\]/, # certificate TBC
|
|
32
|
+
/\s?\-\s?autism.*ing\s?/i, # austim screening
|
|
33
|
+
/\s?\+\s?Q\&(amp;)*A\.?/i, # +Q&A
|
|
34
|
+
/KIDS CLUB\s*/i, # kids club
|
|
35
|
+
/DISCOVER TUE(sday\:)*\s*/i, # discover tue
|
|
36
|
+
/FREE Screening\s*-\s*/i, # free screening
|
|
37
|
+
/\s*-?\s*Big Scream\s*-?\s*/i, # big scream
|
|
38
|
+
/\*?HOH Subtitled\*?/i, # subtitled
|
|
39
|
+
/\s*\-?\s*Reminiscence/i, # reminiscence
|
|
40
|
+
/\s*\-?\s*\(?Re\-issue\)?/i, # reissue
|
|
41
|
+
/\s*-?\s*Kids\'? Club\s*-?\s*/, # kids club
|
|
42
|
+
/\s*plus Q\&A.*/i, # extended Q&A
|
|
43
|
+
/Cinemania\s*[\:\-]/i, # cinemania
|
|
44
|
+
/\@\s*komedia/i, # @ komedia
|
|
45
|
+
/\s*\+ panel.*/i, # panel
|
|
46
|
+
/toddler time\s*\:*\-*/i, # toddler time
|
|
47
|
+
/\(.*\d{4}\)/, # year or captured year
|
|
48
|
+
/\bsingalong\b/i, # singalong
|
|
49
|
+
/\s+\-?\s*Parents \& Babies/i, # parents and babies
|
|
50
|
+
/Subtitled\:*\s*/i, # subtitled
|
|
51
|
+
/\(?live\)?\z/i, # live
|
|
52
|
+
/amp\;/i
|
|
53
|
+
]
|
|
59
54
|
end
|
|
60
55
|
|
|
61
|
-
#
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
56
|
+
# regexes and their replacements
|
|
57
|
+
def replace
|
|
58
|
+
{
|
|
59
|
+
/Met\.? Encore:\s*(.*)/ => 'Met Opera: ',
|
|
60
|
+
/Met\.? Opera:\s*(.*)/ => 'Met Opera: ',
|
|
61
|
+
/National Theatre:\s*(.*)/ => 'NT Live: ',
|
|
62
|
+
/NT Encore:\s*(.*)/ => 'NT Live: ',
|
|
63
|
+
/NT Live:\s*(.*)/ => 'NT Live: ',
|
|
64
|
+
/ROH\.? Live:\s*(.*)/ => 'Royal Opera House: ',
|
|
65
|
+
/ROH\.? Encore:\s*(.*)/ => 'Royal Opera House: ',
|
|
66
|
+
/RSC\.? Live:\s*(.*)/ => 'Royal Shakespeare Company: ',
|
|
67
|
+
/RSC\.? Encore:\s*(.*)/ => 'Royal Shakespeare Company: ',
|
|
68
|
+
/(.*) \(Bolshoi Ballet\)/ => 'Bolshoi Ballet: '
|
|
69
|
+
}
|
|
74
70
|
end
|
|
75
71
|
end
|
|
76
72
|
end
|
|
@@ -12,18 +12,10 @@ module PicturehouseUk
|
|
|
12
12
|
get("cinema/#{id}")
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
-
# get the cinema screenings page for passed id
|
|
16
|
-
# @return [String]
|
|
17
|
-
def whats_on(id)
|
|
18
|
-
get("cinema/#{id}/Whats_On")
|
|
19
|
-
rescue OpenURI::HTTPError
|
|
20
|
-
''
|
|
21
|
-
end
|
|
22
|
-
|
|
23
15
|
# get the cinema contact information page for passed id
|
|
24
16
|
# @return [String]
|
|
25
|
-
def
|
|
26
|
-
get("cinema
|
|
17
|
+
def information(id)
|
|
18
|
+
get("cinema/#{id}/information")
|
|
27
19
|
rescue OpenURI::HTTPError
|
|
28
20
|
''
|
|
29
21
|
end
|
|
@@ -34,12 +26,18 @@ module PicturehouseUk
|
|
|
34
26
|
get(nil)
|
|
35
27
|
end
|
|
36
28
|
|
|
29
|
+
# get the cinemas listing page
|
|
30
|
+
# @return [String]
|
|
31
|
+
def cinemas
|
|
32
|
+
get("cinema")
|
|
33
|
+
end
|
|
34
|
+
|
|
37
35
|
private
|
|
38
36
|
|
|
39
37
|
def get(path)
|
|
40
38
|
# SSL verification doesn't work on picturehouses.com
|
|
41
|
-
open("https://www.picturehouses.com/#{path}",
|
|
42
|
-
|
|
39
|
+
URI.open("https://www.picturehouses.com/#{path}",
|
|
40
|
+
ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE).read
|
|
43
41
|
end
|
|
44
42
|
end
|
|
45
43
|
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
module PicturehouseUk
|
|
2
|
+
# A single screening of a film on the Picturehouse UK website
|
|
3
|
+
class Performance < Cinebase::Performance
|
|
4
|
+
# @!attribute [r] booking_url
|
|
5
|
+
# @return [String] the booking URL on the cinema website
|
|
6
|
+
# @!attribute [r] cinema_name
|
|
7
|
+
# @return [String] the cinema name
|
|
8
|
+
# @!attribute [r] cinema_id
|
|
9
|
+
# @return [String] the cinema id
|
|
10
|
+
# @!attribute [r] dimension
|
|
11
|
+
# @return [String] 2d or 3d
|
|
12
|
+
# @!attribute [r] film_name
|
|
13
|
+
# @return [String] the film name
|
|
14
|
+
|
|
15
|
+
# @!method initialize(options)
|
|
16
|
+
# @param [Hash] options options hash
|
|
17
|
+
# @option options [String] :booking_url (nil) buying url for the screening
|
|
18
|
+
# @option options [String] :cinema_name name of the cinema
|
|
19
|
+
# @option options [String] :cinema_id website id of the cinema
|
|
20
|
+
# @option options [String] :dimension ('2d') dimension of the screening
|
|
21
|
+
# @option options [String] :film_name name of the film
|
|
22
|
+
# @option options [Time] :starting_at listed start time of the performance
|
|
23
|
+
|
|
24
|
+
# Screenings at a single cinema
|
|
25
|
+
# @param [String] cinema_id the id of the cinema
|
|
26
|
+
# @return [Array<PicturehouseUk::Screening>]
|
|
27
|
+
def self.at(cinema_id)
|
|
28
|
+
screenings(cinema_id).map do |attributes|
|
|
29
|
+
new cinema_hash(cinema_id).merge(attributes)
|
|
30
|
+
end.uniq
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# @!method showing_on
|
|
34
|
+
# The date of the screening
|
|
35
|
+
# @return [Date]
|
|
36
|
+
|
|
37
|
+
# @!method starting_at
|
|
38
|
+
# UTC time of the screening
|
|
39
|
+
# @return [Time]
|
|
40
|
+
|
|
41
|
+
# @!method variant
|
|
42
|
+
# The kinds of screening (IMAX, kids, baby, senior)
|
|
43
|
+
# @return <Array[String]>
|
|
44
|
+
|
|
45
|
+
# private
|
|
46
|
+
|
|
47
|
+
def self.cinema_hash(cinema_id)
|
|
48
|
+
{
|
|
49
|
+
cinema_id: cinema_id,
|
|
50
|
+
cinema_name: PicturehouseUk::Cinema.new(cinema_id).name
|
|
51
|
+
}
|
|
52
|
+
end
|
|
53
|
+
private_class_method :cinema_hash
|
|
54
|
+
|
|
55
|
+
def self.screenings(cinema_id)
|
|
56
|
+
PicturehouseUk::Internal::Parser::Screenings.new(cinema_id).to_a
|
|
57
|
+
end
|
|
58
|
+
private_class_method :screenings
|
|
59
|
+
end
|
|
60
|
+
end
|
data/lib/picturehouse_uk.rb
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
|
+
require 'cinebase'
|
|
1
2
|
require 'nokogiri'
|
|
2
|
-
require 'tzinfo'
|
|
3
|
-
require 'tzinfo/data'
|
|
4
3
|
|
|
5
4
|
require_relative './picturehouse_uk/version'
|
|
6
5
|
|
|
6
|
+
require_relative './picturehouse_uk/internal/api'
|
|
7
7
|
require_relative './picturehouse_uk/internal/parser/address'
|
|
8
8
|
require_relative './picturehouse_uk/internal/parser/screenings'
|
|
9
9
|
require_relative './picturehouse_uk/internal/title_sanitizer'
|
|
10
10
|
require_relative './picturehouse_uk/internal/website'
|
|
11
11
|
|
|
12
12
|
require_relative './picturehouse_uk/cinema'
|
|
13
|
-
require_relative './picturehouse_uk/
|
|
14
|
-
require_relative './picturehouse_uk/screening'
|
|
13
|
+
require_relative './picturehouse_uk/performance'
|
|
15
14
|
|
|
16
15
|
module PicturehouseUk
|
|
17
16
|
end
|
data/picturehouse_uk.gemspec
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
# coding: utf-8
|
|
2
1
|
lib = File.expand_path('../lib', __FILE__)
|
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
3
|
require 'picturehouse_uk/version'
|
|
@@ -8,22 +7,21 @@ Gem::Specification.new do |spec|
|
|
|
8
7
|
spec.version = PicturehouseUk::VERSION
|
|
9
8
|
spec.authors = ['Andy Croll']
|
|
10
9
|
spec.email = ['andy@goodscary.com']
|
|
11
|
-
spec.description = '
|
|
10
|
+
spec.description = 'API pulling information from picturehouse.com'
|
|
12
11
|
spec.summary = "It's a scraper, but a nice one"
|
|
13
12
|
spec.homepage = ''
|
|
14
|
-
spec.
|
|
13
|
+
spec.licenses = %w(AGPL MIT)
|
|
15
14
|
|
|
16
|
-
spec.files = `git ls-files`.split(
|
|
15
|
+
spec.files = `git ls-files`.split("\n")
|
|
17
16
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
18
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
19
18
|
spec.require_paths = ['lib']
|
|
20
19
|
|
|
21
|
-
spec.add_development_dependency 'bundler', '~> 1.3'
|
|
22
20
|
spec.add_development_dependency 'minitest-reporters'
|
|
23
21
|
spec.add_development_dependency 'rake'
|
|
22
|
+
spec.add_development_dependency 'simplecov'
|
|
24
23
|
spec.add_development_dependency 'webmock'
|
|
25
24
|
|
|
25
|
+
spec.add_runtime_dependency 'cinebase', '~> 3.0'
|
|
26
26
|
spec.add_runtime_dependency 'nokogiri'
|
|
27
|
-
spec.add_runtime_dependency 'tzinfo'
|
|
28
|
-
spec.add_runtime_dependency 'tzinfo-data'
|
|
29
27
|
end
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Create fitures from the live website
|
|
2
|
+
class FixtureCreator
|
|
3
|
+
def cinema(cinema_id)
|
|
4
|
+
%i(cinema information).each do |action|
|
|
5
|
+
write_fixture_for_cinema(cinema_id, action)
|
|
6
|
+
end
|
|
7
|
+
write_api_fixture_for_cinema(cinema_id)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def home
|
|
11
|
+
write_fixture(:home)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def cinemas
|
|
15
|
+
write_fixture(:cinemas)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
private
|
|
19
|
+
|
|
20
|
+
def fixture(name)
|
|
21
|
+
File.expand_path("#{fixture_path}/#{name}.html", __FILE__)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def json_fixture(name)
|
|
25
|
+
File.expand_path("#{fixture_path}/#{name}.json", __FILE__)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def fixture_path
|
|
29
|
+
'../../test/fixtures'
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def log(message)
|
|
33
|
+
puts "Create API fixture: #{message}"
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def write_fixture_for_cinema(cinema_id, kind)
|
|
37
|
+
FileUtils.mkdir_p File.expand_path("#{fixture_path}/#{cinema_id}", __FILE__)
|
|
38
|
+
text = "#{cinema_id}/#{kind}"
|
|
39
|
+
File.open(fixture(text), 'w+') do |file|
|
|
40
|
+
log(text)
|
|
41
|
+
file.write PicturehouseUk::Internal::Website.new.send(kind, cinema_id)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def write_api_fixture_for_cinema(cinema_id)
|
|
46
|
+
require 'json'
|
|
47
|
+
FileUtils.mkdir_p File.expand_path("#{fixture_path}/#{cinema_id}", __FILE__)
|
|
48
|
+
text = "#{cinema_id}/get_movies"
|
|
49
|
+
File.open(json_fixture(text), 'w+') do |file|
|
|
50
|
+
log(text)
|
|
51
|
+
data = PicturehouseUk::Internal::Api.new.get_movies(cinema_id)
|
|
52
|
+
file.write JSON.pretty_generate(data)
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def write_fixture(kind)
|
|
57
|
+
File.open(fixture(kind), 'w+') do |file|
|
|
58
|
+
log(kind)
|
|
59
|
+
file.write PicturehouseUk::Internal::Website.new.send(kind.to_sym)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|