reel_uk 1.0.0 → 1.0.1

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: b6f1209b04f84c1c66a844ff4dd3c9b6212372a7a7281cbf1be4fb46bc2db02e
4
- data.tar.gz: 7b92797f151c402671b8a87660149f1977bf1207383d1558acc191e20a50a07f
3
+ metadata.gz: 88a832fdb71a6d3f7052fa863d53e97eecdd5c63a54489990fe7bd496c1a796c
4
+ data.tar.gz: 9440fb29505233a09a86fda618d42c96eab815e7f916ea23754b056c0c8bcfbe
5
5
  SHA512:
6
- metadata.gz: a08041ba47ce4fa230fdbda0f9b5bcfaf968b582c23ed52600da1bd33cdf29180fb568e0ba971770bd67d2cd1fbce2afd8343527dd1999085b2a045934f9b6a9
7
- data.tar.gz: 0cdd9454883ab8982efd2f89f520464bc3f468d3fbd3749484f09777d5e012c06df4d38ba9df82a8f81420ee9def30c13c1c281224790f84316adfbf556ff2e5
6
+ metadata.gz: 2740ef677d0b13d77f76edc09360775760ab51216dfbeef4dc639e2e7f5a9c223c39b7a253ae3685de23179f7ad9e75bb712603b8db14043d348455c2b562300
7
+ data.tar.gz: 0cfb73b6944cf0c2eb57cf44f7d459668af008e2891cfb103d43d129c3e46060fd52ef2cbc673e52fcbb9555ea4cf7078a344e31226e3f78814f092d68e6b72a
data/CHANGELOG.md CHANGED
@@ -2,6 +2,15 @@
2
2
  All notable changes to this project will be documented in this file.
3
3
  This project adheres to [Semantic Versioning](http://semver.org/).
4
4
 
5
+ ## [1.0.1] - 2026-11-02
6
+
7
+ ### Changed
8
+ - Requests and London times use cinebase 5.8's `Cinebase::Http` and `Cinebase::London`.
9
+ - HTTP errors read "HTTP error 500 from reel-cinemas.co.uk" instead of "Reel HTTP error 500 from reel-cinemas.co.uk".
10
+
11
+ ### Removed
12
+ - `ReelUk::Performance::TIME_ZONE`, now unused.
13
+
5
14
  ## [1.0.0] - 2026-11-01
6
15
 
7
16
  ### Added
@@ -8,7 +8,6 @@ module ReelUk
8
8
  # such as '16 Dec 2026 @ 09:30', which name every showtime on sale
9
9
  class Showtimes
10
10
  OPTION = %r{<option value="[^"]*/booknow/(\d+)/?">(\d{1,2} [A-Z][a-z]{2} \d{4}) @ (\d{1,2}):(\d{2})</option>}
11
- TIME_ZONE = 'Europe/London'
12
11
 
13
12
  # @param [String] html the menu's options
14
13
  # @param [String] film_id Jacro's film id
@@ -38,7 +37,7 @@ module ReelUk
38
37
 
39
38
  def starting_at(date, hour, minute)
40
39
  local = Time.utc(date.year, date.month, date.day, hour.to_i, minute.to_i)
41
- TZInfo::Timezone.get(TIME_ZONE).local_to_utc(local) { |periods| periods.first }.utc
40
+ Cinebase::London.utc(local)
42
41
  end
43
42
  end
44
43
  end
@@ -14,7 +14,6 @@ module ReelUk
14
14
  <a\shref="[^"]*/booknow/(\d+)/?"[^>]*>\s*(\d{1,2}:\d{2})\s*</a>
15
15
  (?:<div\sclass="show_time_label">([^<]*)</div>)?
16
16
  }x
17
- TIME_ZONE = 'Europe/London'
18
17
 
19
18
  # @param [String] html a what's on page
20
19
  # @param [String] venue_url e.g. 'https://reel-cinemas.co.uk/chorley'
@@ -54,7 +53,7 @@ module ReelUk
54
53
  def starting_at(date, time)
55
54
  hour, minute = time.split(':').map(&:to_i)
56
55
  local = Time.utc(date.year, date.month, date.day, hour, minute)
57
- TZInfo::Timezone.get(TIME_ZONE).local_to_utc(local) { |periods| periods.first }.utc
56
+ Cinebase::London.utc(local)
58
57
  end
59
58
  end
60
59
  end
@@ -7,35 +7,37 @@ module ReelUk
7
7
  # Reads pages from Reel's WordPress website, built on Jacro's cinema
8
8
  # plugin. No token is needed.
9
9
  class Website
10
- include Http
11
-
12
10
  HOME = 'https://reel-cinemas.co.uk/'
13
11
  AJAX = 'https://reel-cinemas.co.uk/wp-admin/admin-ajax.php'
14
12
  # The quick booking menu's request for every showtime of a film
15
13
  SHOWTIMES_ACTION = 'display_showtime_byfilmid'
16
14
 
15
+ def initialize
16
+ @http = Cinebase::Http.new
17
+ end
18
+
17
19
  # @return [String] the home page, whose cinema menu lists every venue
18
20
  def home
19
- get(HOME)
21
+ @http.get(HOME)
20
22
  end
21
23
 
22
24
  # @param [String] venue_url e.g. 'https://reel-cinemas.co.uk/chorley'
23
25
  # @return [String] the venue's page, whose quick booking menu names
24
26
  # the venue's Jacro location id
25
27
  def venue(venue_url)
26
- get("#{venue_url}/")
28
+ @http.get("#{venue_url}/")
27
29
  end
28
30
 
29
31
  # @param [String] venue_url e.g. 'https://reel-cinemas.co.uk/chorley'
30
32
  # @return [String] the next three weeks of showtimes, with labels
31
33
  def whats_on(venue_url)
32
- get("#{venue_url}/whatson/")
34
+ @http.get("#{venue_url}/whatson/")
33
35
  end
34
36
 
35
37
  # @param [String] venue_url e.g. 'https://reel-cinemas.co.uk/chorley'
36
38
  # @return [String] films not yet showing, with up to three showtimes each
37
39
  def coming_soon(venue_url)
38
- get("#{venue_url}/comingsoon/")
40
+ @http.get("#{venue_url}/comingsoon/")
39
41
  end
40
42
 
41
43
  # @param [String] film_id Jacro's film id, the same at every venue
@@ -43,7 +45,8 @@ module ReelUk
43
45
  # @return [String] options naming every showtime of the film at the
44
46
  # venue, however far ahead
45
47
  def showtimes(film_id, location)
46
- response = post(AJAX, 'action' => SHOWTIMES_ACTION, 'select_movie' => film_id, 'movie_loc' => location)
48
+ form = { 'action' => SHOWTIMES_ACTION, 'select_movie' => film_id, 'movie_loc' => location }
49
+ response = @http.post(AJAX, form: form)
47
50
  JSON.parse(response).fetch('html', '').to_s
48
51
  end
49
52
  end
@@ -37,7 +37,6 @@ module ReelUk
37
37
  THREE_D = Cinebase::A1web::Performance::THREE_D
38
38
  IMAX = Cinebase::A1web::Performance::IMAX
39
39
  LANGUAGE = Cinebase::A1web::Performance::LANGUAGE
40
- TIME_ZONE = 'Europe/London'.freeze
41
40
 
42
41
  # The old website's own booking links only work in a browser that has
43
42
  # just visited the venue's pages, so link to the venue's Admit One
@@ -54,7 +53,7 @@ module ReelUk
54
53
  # @return [Array<ReelUk::Performance>]
55
54
  def self.at(
56
55
  cinema_id,
57
- from: TZInfo::Timezone.get(TIME_ZONE).now.to_date,
56
+ from: Cinebase::London.today,
58
57
  to: from + 13
59
58
  )
60
59
  raise ArgumentError, 'to must not precede from' if to < from
@@ -82,9 +81,8 @@ module ReelUk
82
81
  if cinema.url.empty?
83
82
  []
84
83
  elsif cinema.a1web?
85
- today = TZInfo::Timezone.get(TIME_ZONE).now.to_date
86
84
  html = Cinema.a1web_client.whats_on(cinema.url)
87
- Cinebase::A1web::Listings.new(html, venue_url: cinema.url, today: today).showings
85
+ Cinebase::A1web::Listings.new(html, venue_url: cinema.url, today: Cinebase::London.today).showings
88
86
  else
89
87
  ReelUk::Internal::Listings.new(cinema.url).showings
90
88
  end
@@ -1,6 +1,6 @@
1
1
  # Ruby interface for https://reel-cinemas.co.uk
2
- # @version 1.0.0
2
+ # @version 1.0.1
3
3
  module ReelUk
4
4
  # Gem version
5
- VERSION = '1.0.0'.freeze
5
+ VERSION = '1.0.1'.freeze
6
6
  end
data/lib/reel_uk.rb CHANGED
@@ -6,7 +6,6 @@ require 'cinebase/a1web'
6
6
 
7
7
  require_relative './reel_uk/version'
8
8
 
9
- require_relative './reel_uk/internal/http'
10
9
  require_relative './reel_uk/internal/website'
11
10
  require_relative './reel_uk/internal/title_sanitizer'
12
11
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reel_uk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Croll
@@ -99,14 +99,14 @@ dependencies:
99
99
  requirements:
100
100
  - - "~>"
101
101
  - !ruby/object:Gem::Version
102
- version: '5.7'
102
+ version: '5.8'
103
103
  type: :runtime
104
104
  prerelease: false
105
105
  version_requirements: !ruby/object:Gem::Requirement
106
106
  requirements:
107
107
  - - "~>"
108
108
  - !ruby/object:Gem::Version
109
- version: '5.7'
109
+ version: '5.8'
110
110
  description: Pull movie & cinema information from the Reel Cinemas website
111
111
  email:
112
112
  - andy@goodscary.com
@@ -120,7 +120,6 @@ files:
120
120
  - README.md
121
121
  - lib/reel_uk.rb
122
122
  - lib/reel_uk/cinema.rb
123
- - lib/reel_uk/internal/http.rb
124
123
  - lib/reel_uk/internal/listings.rb
125
124
  - lib/reel_uk/internal/parser/coming_soon.rb
126
125
  - lib/reel_uk/internal/parser/showtimes.rb
@@ -1,49 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'net/http'
4
-
5
- module ReelUk
6
- # Internal utility classes: Do not use
7
- # @api private
8
- module Internal
9
- # Requests to reel-cinemas.co.uk
10
- module Http
11
- RETRIES = 2
12
- TRANSIENT_ERRORS = [
13
- EOFError, Errno::ECONNRESET, Errno::ECONNREFUSED, Net::OpenTimeout, Net::ReadTimeout, OpenSSL::SSL::SSLError
14
- ].freeze
15
-
16
- private
17
-
18
- def get(url)
19
- perform(Net::HTTP::Get.new(URI(url)))
20
- end
21
-
22
- def post(url, form)
23
- post = Net::HTTP::Post.new(URI(url))
24
- post.set_form_data(form)
25
- perform(post)
26
- end
27
-
28
- def perform(request)
29
- uri = request.uri
30
- attempts = 0
31
- begin
32
- response = Net::HTTP.start(uri.host, uri.port, use_ssl: true, open_timeout: 10, read_timeout: 30) do |http|
33
- http.request(request)
34
- end
35
- rescue *TRANSIENT_ERRORS
36
- attempts += 1
37
- raise if attempts > RETRIES
38
-
39
- sleep(attempts)
40
- retry
41
- end
42
- # Omit response bodies from errors, and never follow redirects.
43
- raise "Reel HTTP error #{response.code} from #{uri.host}" unless response.is_a?(Net::HTTPSuccess)
44
-
45
- String.new(response.body, encoding: Encoding::UTF_8)
46
- end
47
- end
48
- end
49
- end