gft_uk 1.0.0 → 1.1.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 +4 -4
- data/CHANGELOG.md +11 -0
- data/README.md +2 -1
- data/lib/gft_uk/internal/graphql.rb +7 -44
- data/lib/gft_uk/internal/parser/showing.rb +3 -3
- data/lib/gft_uk/performance.rb +2 -8
- data/lib/gft_uk/version.rb +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3ac986d109ce14f592d90da5095b4cb399068ac89e09fe3987137863b7c3ce96
|
|
4
|
+
data.tar.gz: 353a6aacc32a4fcd3de1585e92df2e6e4057d3e40e748d93861719168424c691
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 67fbf2fd355940b3dd66f8399a90e7c3a68d86c2e44dde025e5da0f90523e3d3af66822be928e045955d704e1e33b99d6b1c7e58ea50aba4e0f79eb4b0d8efe3
|
|
7
|
+
data.tar.gz: 4112af4325eff401a436a3d34a004953b7bbe0bf2b76da6f2341a861a8fc83acabb6e729355a998b901fa53c91c70daec074b3c59453bf56f7506c788283b647
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
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.1.0] - 2026-11-03
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
- Uses cinebase 5.9: performances take the raw `title:`, so audience labels become variants, and series prefixes such as `Met Opera:` become the performance's `event`.
|
|
9
|
+
|
|
10
|
+
## [1.0.1] - 2026-11-02
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
- Requests and London times use cinebase 5.8's `Cinebase::Http` and `Cinebase::London`.
|
|
14
|
+
- HTTP errors read "HTTP error 500 from www.glasgowfilm.org" in place of "Indy HTTP error 500".
|
|
15
|
+
|
|
5
16
|
## [1.0.0] - 2026-11-02
|
|
6
17
|
|
|
7
18
|
The first release, as 1.0.0.
|
data/README.md
CHANGED
|
@@ -136,7 +136,8 @@ Titles are cleaned up:
|
|
|
136
136
|
- Anniversaries, restorations and prints go: 'Marie Antoinette - 20th
|
|
137
137
|
Anniversary - 4K', 'Short Cuts - 35mm', 'A Silent Voice (10th Anniversary)'.
|
|
138
138
|
- Add-ons go: '+ Q&A', '+ discussion', '+ introduction'.
|
|
139
|
-
- 'NT Live:'
|
|
139
|
+
- Series prefixes such as 'NT Live:' go, and the performance's `event` names
|
|
140
|
+
the series, here National Theatre Live.
|
|
140
141
|
|
|
141
142
|
## Tests
|
|
142
143
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'json'
|
|
4
|
-
require 'net/http'
|
|
5
4
|
|
|
6
5
|
module GftUk
|
|
7
6
|
# Internal utility classes: Do not use
|
|
@@ -10,23 +9,23 @@ module GftUk
|
|
|
10
9
|
# Posts queries to the consumer GraphQL API of a website built on Indy
|
|
11
10
|
# Systems, the Indy Cinema Group's platform
|
|
12
11
|
class Graphql
|
|
13
|
-
|
|
14
|
-
TRANSIENT_ERRORS = [
|
|
15
|
-
EOFError, Errno::ECONNRESET, Errno::ECONNREFUSED, Net::OpenTimeout, Net::ReadTimeout, OpenSSL::SSL::SSLError
|
|
16
|
-
].freeze
|
|
12
|
+
READ_TIMEOUT = 60
|
|
17
13
|
|
|
18
14
|
# @param [String] url the website's GraphQL endpoint
|
|
19
15
|
# @param [String] site_id the venue's Indy site id
|
|
20
16
|
def initialize(url, site_id:)
|
|
21
|
-
@
|
|
22
|
-
|
|
17
|
+
@url = url
|
|
18
|
+
# Indy refuses consumer queries that name no site
|
|
19
|
+
@headers = { 'Client-Type' => 'consumer', 'Site-Id' => site_id }
|
|
20
|
+
# One connection for all of an import's requests
|
|
21
|
+
@http = Cinebase::Http.new(read_timeout: READ_TIMEOUT, keep_alive: true)
|
|
23
22
|
end
|
|
24
23
|
|
|
25
24
|
# @param [String] document a GraphQL query
|
|
26
25
|
# @param [Hash] variables the query's variables
|
|
27
26
|
# @return [Hash] the response's data
|
|
28
27
|
def query(document, variables = {})
|
|
29
|
-
body = JSON.parse(post(
|
|
28
|
+
body = JSON.parse(@http.post(@url, json: { query: document, variables: variables }, headers: @headers))
|
|
30
29
|
# Indy reports a failed query in one 'error' object, not an 'errors' list
|
|
31
30
|
error = body['error'] || Array(body['errors']).first
|
|
32
31
|
if error
|
|
@@ -35,42 +34,6 @@ module GftUk
|
|
|
35
34
|
body.fetch('data')
|
|
36
35
|
end
|
|
37
36
|
end
|
|
38
|
-
|
|
39
|
-
private
|
|
40
|
-
|
|
41
|
-
# Indy refuses consumer queries that name no site
|
|
42
|
-
def post(body)
|
|
43
|
-
request = Net::HTTP::Post.new(@uri)
|
|
44
|
-
request['Content-Type'] = 'application/json'
|
|
45
|
-
request['Client-Type'] = 'consumer'
|
|
46
|
-
request['Site-Id'] = @site_id
|
|
47
|
-
request.body = body
|
|
48
|
-
response = with_retries { connection.request(request) }
|
|
49
|
-
# Omit response bodies from errors, and never follow redirects.
|
|
50
|
-
raise "Indy HTTP error #{response.code}" unless response.is_a?(Net::HTTPSuccess)
|
|
51
|
-
|
|
52
|
-
String.new(response.body, encoding: Encoding::UTF_8)
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
# Net::HTTP never retries a POST itself
|
|
56
|
-
def with_retries
|
|
57
|
-
attempts = 0
|
|
58
|
-
begin
|
|
59
|
-
yield
|
|
60
|
-
rescue *TRANSIENT_ERRORS
|
|
61
|
-
attempts += 1
|
|
62
|
-
raise if attempts > RETRIES
|
|
63
|
-
|
|
64
|
-
@connection = nil
|
|
65
|
-
sleep(attempts)
|
|
66
|
-
retry
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
# One connection for all of an import's requests
|
|
71
|
-
def connection
|
|
72
|
-
@connection ||= Net::HTTP.start(@uri.host, @uri.port, use_ssl: true, open_timeout: 10, read_timeout: 60)
|
|
73
|
-
end
|
|
74
37
|
end
|
|
75
38
|
end
|
|
76
39
|
end
|
|
@@ -65,7 +65,6 @@ module GftUk
|
|
|
65
65
|
NON_FILM_TITLES = /\b(?:Pass|Gift Card|Voucher|Membership)\z/i
|
|
66
66
|
|
|
67
67
|
THREE_D = /\b3D\b/i
|
|
68
|
-
TIME_ZONE = 'Europe/London'
|
|
69
68
|
|
|
70
69
|
# @param [Hash] showing one showing, with its movie
|
|
71
70
|
# @param [String] url the website's home page
|
|
@@ -90,6 +89,7 @@ module GftUk
|
|
|
90
89
|
film_name: TitleSanitizer.new(title).sanitized,
|
|
91
90
|
film_year: Cinebase::TitleSanitizer.film_year(title) || release_year,
|
|
92
91
|
starting_at: starting_at,
|
|
92
|
+
title: title,
|
|
93
93
|
variant: variant
|
|
94
94
|
}
|
|
95
95
|
end
|
|
@@ -108,7 +108,7 @@ module GftUk
|
|
|
108
108
|
end
|
|
109
109
|
|
|
110
110
|
def festival
|
|
111
|
-
Cinebase::Festival.from_title(title, year: london_year) || badge_festival
|
|
111
|
+
title_festival || Cinebase::Festival.from_title(title, year: london_year) || badge_festival
|
|
112
112
|
end
|
|
113
113
|
|
|
114
114
|
def badge_festival
|
|
@@ -127,7 +127,7 @@ module GftUk
|
|
|
127
127
|
end
|
|
128
128
|
|
|
129
129
|
def london_year
|
|
130
|
-
|
|
130
|
+
Cinebase::London.date(starting_at).year
|
|
131
131
|
end
|
|
132
132
|
|
|
133
133
|
def movie
|
data/lib/gft_uk/performance.rb
CHANGED
|
@@ -22,8 +22,7 @@ module GftUk
|
|
|
22
22
|
# @option options [String] :film_name name of the film
|
|
23
23
|
# @option options [Integer] :film_year (nil) year of the film
|
|
24
24
|
# @option options [Time] :starting_at listed start time of the performance
|
|
25
|
-
|
|
26
|
-
TIME_ZONE = 'Europe/London'.freeze
|
|
25
|
+
# @option options [String] :title (nil) raw title, for audience variants
|
|
27
26
|
|
|
28
27
|
# Performances within an inclusive range of showing dates: one request
|
|
29
28
|
# for the dates with showings, then one for every ten of those dates.
|
|
@@ -33,7 +32,7 @@ module GftUk
|
|
|
33
32
|
# @return [Array<GftUk::Performance>]
|
|
34
33
|
def self.at(
|
|
35
34
|
cinema_id,
|
|
36
|
-
from: today,
|
|
35
|
+
from: Cinebase::London.today,
|
|
37
36
|
to: from + 13
|
|
38
37
|
)
|
|
39
38
|
raise ArgumentError, 'to must not precede from' if to < from
|
|
@@ -61,11 +60,6 @@ module GftUk
|
|
|
61
60
|
# The kinds of screening (arts, audio_described, kids, relaxed, subtitled ...)
|
|
62
61
|
# @return <Array[String]>
|
|
63
62
|
|
|
64
|
-
def self.today
|
|
65
|
-
TZInfo::Timezone.get(TIME_ZONE).now.to_date
|
|
66
|
-
end
|
|
67
|
-
private_class_method :today
|
|
68
|
-
|
|
69
63
|
def self.showings(cinema, dates)
|
|
70
64
|
indy = GftUk::Internal::Indy.new(cinema.url, site_id: cinema.id)
|
|
71
65
|
indy.showings(indy.dates.select { |date| dates.cover?(date) })
|
data/lib/gft_uk/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: gft_uk
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.1.0
|
|
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.
|
|
102
|
+
version: '5.9'
|
|
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.
|
|
109
|
+
version: '5.9'
|
|
110
110
|
description: Pull movie & cinema information from the Glasgow Film Theatre website
|
|
111
111
|
email:
|
|
112
112
|
- andy@goodscary.com
|