omniplex_uk 1.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 +7 -0
- data/CHANGELOG.md +10 -0
- data/COMM-LICENSE +22 -0
- data/LICENSE +617 -0
- data/README.md +168 -0
- data/lib/omniplex_uk/cinema.rb +172 -0
- data/lib/omniplex_uk/internal/client.rb +108 -0
- data/lib/omniplex_uk/internal/listings.rb +100 -0
- data/lib/omniplex_uk/internal/title_sanitizer.rb +43 -0
- data/lib/omniplex_uk/performance.rb +131 -0
- data/lib/omniplex_uk/version.rb +6 -0
- data/lib/omniplex_uk.rb +15 -0
- metadata +150 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
module OmniplexUk
|
|
2
|
+
# A single screening of a film on the Omniplex Cinemas website
|
|
3
|
+
class Performance < Cinebase::A1web::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 [Cinebase::Festival] :festival (nil) festival edition
|
|
22
|
+
# @option options [String] :film_name name of the film
|
|
23
|
+
# @option options [Integer] :film_year (nil) year from the film's title
|
|
24
|
+
# @option options [String] :language (nil) audio language, e.g. 'Polish'
|
|
25
|
+
# @option options [Time] :starting_at listed start time of the performance
|
|
26
|
+
|
|
27
|
+
# @!method showing_on
|
|
28
|
+
# The date of the screening
|
|
29
|
+
# @return [Date]
|
|
30
|
+
|
|
31
|
+
# @!method starting_at
|
|
32
|
+
# UTC time of the screening
|
|
33
|
+
# @return [Time]
|
|
34
|
+
|
|
35
|
+
# @!method variant
|
|
36
|
+
# The kinds of screening (arts, audio_described, maxx, senior ...)
|
|
37
|
+
# @return <Array[String]>
|
|
38
|
+
|
|
39
|
+
# Omniplex's hall icons and showtime tags, beyond those A1Web chains
|
|
40
|
+
# share. Avenue, D-BOX, 4D E-Motion, MAXX and Sofa Bed are Omniplex's
|
|
41
|
+
# premium screens and seats.
|
|
42
|
+
VARIANTS = {
|
|
43
|
+
'4D E-Motion' => '4d',
|
|
44
|
+
'Audio Described' => 'audio_described',
|
|
45
|
+
'Avenue' => 'avenue',
|
|
46
|
+
'D-BOX' => 'dbox',
|
|
47
|
+
'Event' => 'arts',
|
|
48
|
+
'Infinity Vision' => 'infinity_vision',
|
|
49
|
+
'Infinity Vision 3D' => 'infinity_vision',
|
|
50
|
+
'MAXX' => 'maxx',
|
|
51
|
+
'Seniors Club' => 'senior',
|
|
52
|
+
'Sensory Friendly' => 'relaxed',
|
|
53
|
+
'Sofa Bed' => 'sofabed'
|
|
54
|
+
}.freeze
|
|
55
|
+
|
|
56
|
+
# Broadcasts the website gives no Event genre
|
|
57
|
+
LIVE_EVENT = /\bLIVE\b|\ANT Live\b|\bThe Met Opera\b/
|
|
58
|
+
COUNTRY_LANGUAGES = { 'Poland' => 'Polish' }.freeze
|
|
59
|
+
COUNTRY = /\((#{COUNTRY_LANGUAGES.keys.join('|')})\)/
|
|
60
|
+
|
|
61
|
+
# Performances within an inclusive range of showing dates. The website
|
|
62
|
+
# lists one day per page, so this reads the venue's advertised dates
|
|
63
|
+
# from its first page, then one page for each other date in the range.
|
|
64
|
+
# @param [String] cinema_id id of the cinema, e.g. 'OMP_KENN'
|
|
65
|
+
# @param [Date] from first date (defaults to today in London)
|
|
66
|
+
# @param [Date] to last date (defaults to 13 days after from)
|
|
67
|
+
# @return [Array<OmniplexUk::Performance>]
|
|
68
|
+
def self.at(
|
|
69
|
+
cinema_id,
|
|
70
|
+
from: TZInfo::Timezone.get(TIME_ZONE).now.to_date,
|
|
71
|
+
to: from + 13
|
|
72
|
+
)
|
|
73
|
+
raise ArgumentError, 'to must not precede from' if to < from
|
|
74
|
+
|
|
75
|
+
cinema = cinema_class.new(cinema_id)
|
|
76
|
+
if cinema.url.empty?
|
|
77
|
+
[]
|
|
78
|
+
else
|
|
79
|
+
showings = listings(cinema.id, from..to).flat_map(&:showings)
|
|
80
|
+
performances = showings.map do |showing|
|
|
81
|
+
new(attributes(showing).merge(cinema_id: cinema.id, cinema_name: cinema.name))
|
|
82
|
+
end
|
|
83
|
+
performances.sort_by(&:starting_at)
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# @api private
|
|
88
|
+
def self.cinema_class
|
|
89
|
+
Cinema
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# @api private
|
|
93
|
+
def self.title_sanitizer
|
|
94
|
+
Internal::TitleSanitizer
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
# @api private
|
|
98
|
+
def self.variants
|
|
99
|
+
super.merge(VARIANTS)
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def self.listings(site_code, dates)
|
|
103
|
+
client = cinema_class.client
|
|
104
|
+
first = Internal::Listings.new(client.showtimes(site_code))
|
|
105
|
+
first.dates.select { |date| dates.cover?(date) }.map do |date|
|
|
106
|
+
if date == first.date
|
|
107
|
+
first
|
|
108
|
+
else
|
|
109
|
+
Internal::Listings.new(client.showtimes(site_code, date))
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
ensure
|
|
113
|
+
client&.close
|
|
114
|
+
end
|
|
115
|
+
private_class_method :listings
|
|
116
|
+
|
|
117
|
+
def self.attributes(showing)
|
|
118
|
+
attributes = super
|
|
119
|
+
attributes[:language] ||= COUNTRY_LANGUAGES[showing.title[COUNTRY, 1]]
|
|
120
|
+
attributes
|
|
121
|
+
end
|
|
122
|
+
private_class_method :attributes
|
|
123
|
+
|
|
124
|
+
def self.variant(showing)
|
|
125
|
+
variant = super
|
|
126
|
+
variant << 'arts' if showing.title.match?(LIVE_EVENT)
|
|
127
|
+
variant.uniq
|
|
128
|
+
end
|
|
129
|
+
private_class_method :variant
|
|
130
|
+
end
|
|
131
|
+
end
|
data/lib/omniplex_uk.rb
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require 'cinebase'
|
|
2
|
+
require 'cinebase/a1web'
|
|
3
|
+
|
|
4
|
+
require_relative './omniplex_uk/version'
|
|
5
|
+
|
|
6
|
+
require_relative './omniplex_uk/internal/client'
|
|
7
|
+
require_relative './omniplex_uk/internal/listings'
|
|
8
|
+
require_relative './omniplex_uk/internal/title_sanitizer'
|
|
9
|
+
|
|
10
|
+
require_relative './omniplex_uk/cinema'
|
|
11
|
+
require_relative './omniplex_uk/performance'
|
|
12
|
+
|
|
13
|
+
# omniplex_uk gem
|
|
14
|
+
module OmniplexUk
|
|
15
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: omniplex_uk
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Andy Croll
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: bundler
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - ">="
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '2.0'
|
|
19
|
+
type: :development
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - ">="
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '2.0'
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: minitest-mock
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - ">="
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '0'
|
|
33
|
+
type: :development
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - ">="
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '0'
|
|
40
|
+
- !ruby/object:Gem::Dependency
|
|
41
|
+
name: minitest-reporters
|
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - ">="
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '0'
|
|
47
|
+
type: :development
|
|
48
|
+
prerelease: false
|
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - ">="
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '0'
|
|
54
|
+
- !ruby/object:Gem::Dependency
|
|
55
|
+
name: rake
|
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
|
57
|
+
requirements:
|
|
58
|
+
- - ">="
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: '0'
|
|
61
|
+
type: :development
|
|
62
|
+
prerelease: false
|
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
64
|
+
requirements:
|
|
65
|
+
- - ">="
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: '0'
|
|
68
|
+
- !ruby/object:Gem::Dependency
|
|
69
|
+
name: simplecov
|
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
|
71
|
+
requirements:
|
|
72
|
+
- - "<"
|
|
73
|
+
- !ruby/object:Gem::Version
|
|
74
|
+
version: '2'
|
|
75
|
+
type: :development
|
|
76
|
+
prerelease: false
|
|
77
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
78
|
+
requirements:
|
|
79
|
+
- - "<"
|
|
80
|
+
- !ruby/object:Gem::Version
|
|
81
|
+
version: '2'
|
|
82
|
+
- !ruby/object:Gem::Dependency
|
|
83
|
+
name: webmock
|
|
84
|
+
requirement: !ruby/object:Gem::Requirement
|
|
85
|
+
requirements:
|
|
86
|
+
- - ">="
|
|
87
|
+
- !ruby/object:Gem::Version
|
|
88
|
+
version: '0'
|
|
89
|
+
type: :development
|
|
90
|
+
prerelease: false
|
|
91
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
92
|
+
requirements:
|
|
93
|
+
- - ">="
|
|
94
|
+
- !ruby/object:Gem::Version
|
|
95
|
+
version: '0'
|
|
96
|
+
- !ruby/object:Gem::Dependency
|
|
97
|
+
name: cinebase
|
|
98
|
+
requirement: !ruby/object:Gem::Requirement
|
|
99
|
+
requirements:
|
|
100
|
+
- - "~>"
|
|
101
|
+
- !ruby/object:Gem::Version
|
|
102
|
+
version: '5.7'
|
|
103
|
+
type: :runtime
|
|
104
|
+
prerelease: false
|
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
106
|
+
requirements:
|
|
107
|
+
- - "~>"
|
|
108
|
+
- !ruby/object:Gem::Version
|
|
109
|
+
version: '5.7'
|
|
110
|
+
description: Pull movie & cinema information from the Omniplex Cinemas website
|
|
111
|
+
email:
|
|
112
|
+
- andy@goodscary.com
|
|
113
|
+
executables: []
|
|
114
|
+
extensions: []
|
|
115
|
+
extra_rdoc_files: []
|
|
116
|
+
files:
|
|
117
|
+
- CHANGELOG.md
|
|
118
|
+
- COMM-LICENSE
|
|
119
|
+
- LICENSE
|
|
120
|
+
- README.md
|
|
121
|
+
- lib/omniplex_uk.rb
|
|
122
|
+
- lib/omniplex_uk/cinema.rb
|
|
123
|
+
- lib/omniplex_uk/internal/client.rb
|
|
124
|
+
- lib/omniplex_uk/internal/listings.rb
|
|
125
|
+
- lib/omniplex_uk/internal/title_sanitizer.rb
|
|
126
|
+
- lib/omniplex_uk/performance.rb
|
|
127
|
+
- lib/omniplex_uk/version.rb
|
|
128
|
+
homepage: https://github.com/andycroll/omniplex_uk
|
|
129
|
+
licenses:
|
|
130
|
+
- AGPL
|
|
131
|
+
- MIT
|
|
132
|
+
metadata: {}
|
|
133
|
+
rdoc_options: []
|
|
134
|
+
require_paths:
|
|
135
|
+
- lib
|
|
136
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
137
|
+
requirements:
|
|
138
|
+
- - ">="
|
|
139
|
+
- !ruby/object:Gem::Version
|
|
140
|
+
version: '3.4'
|
|
141
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
142
|
+
requirements:
|
|
143
|
+
- - ">="
|
|
144
|
+
- !ruby/object:Gem::Version
|
|
145
|
+
version: '0'
|
|
146
|
+
requirements: []
|
|
147
|
+
rubygems_version: 4.0.20
|
|
148
|
+
specification_version: 4
|
|
149
|
+
summary: It's a scraper, but a nice one
|
|
150
|
+
test_files: []
|