gft_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 +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/gft_uk/internal/graphql.rb +7 -44
- data/lib/gft_uk/internal/parser/showing.rb +1 -2
- data/lib/gft_uk/performance.rb +1 -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: 9972f784150fbabe8ab6200f7d9489fb2732fae4f2967847eb2c3d0c9820eeb2
|
|
4
|
+
data.tar.gz: 206bcc75aa132a5e912edb173f36b0eb7c1ae735a1dd2596815a744ebcf3936d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: de8a994096f943cbb906c6ed208d1ed2da08faf2883ecb7a36fe0ed9f4129fd407ea0402a66dbcd28126256c1d3927280f66c6bda7bb4c95dbec7e69b7092d08
|
|
7
|
+
data.tar.gz: 8efae36d5423f011682f2f0e0c76f9f45efed8b75543c617e1ec0a8e3156d0bd3bad7079efa321fad8aead1563b69e576e8e630d693a59c2e034e3fcd5b77f36
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
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 www.glasgowfilm.org" in place of "Indy HTTP error 500".
|
|
10
|
+
|
|
5
11
|
## [1.0.0] - 2026-11-02
|
|
6
12
|
|
|
7
13
|
The first release, as 1.0.0.
|
|
@@ -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
|
|
@@ -127,7 +126,7 @@ module GftUk
|
|
|
127
126
|
end
|
|
128
127
|
|
|
129
128
|
def london_year
|
|
130
|
-
|
|
129
|
+
Cinebase::London.date(starting_at).year
|
|
131
130
|
end
|
|
132
131
|
|
|
133
132
|
def movie
|
data/lib/gft_uk/performance.rb
CHANGED
|
@@ -23,8 +23,6 @@ module GftUk
|
|
|
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
25
|
|
|
26
|
-
TIME_ZONE = 'Europe/London'.freeze
|
|
27
|
-
|
|
28
26
|
# Performances within an inclusive range of showing dates: one request
|
|
29
27
|
# for the dates with showings, then one for every ten of those dates.
|
|
30
28
|
# @param [Integer, String] cinema_id the cinema's Indy site id, '103'
|
|
@@ -33,7 +31,7 @@ module GftUk
|
|
|
33
31
|
# @return [Array<GftUk::Performance>]
|
|
34
32
|
def self.at(
|
|
35
33
|
cinema_id,
|
|
36
|
-
from: today,
|
|
34
|
+
from: Cinebase::London.today,
|
|
37
35
|
to: from + 13
|
|
38
36
|
)
|
|
39
37
|
raise ArgumentError, 'to must not precede from' if to < from
|
|
@@ -61,11 +59,6 @@ module GftUk
|
|
|
61
59
|
# The kinds of screening (arts, audio_described, kids, relaxed, subtitled ...)
|
|
62
60
|
# @return <Array[String]>
|
|
63
61
|
|
|
64
|
-
def self.today
|
|
65
|
-
TZInfo::Timezone.get(TIME_ZONE).now.to_date
|
|
66
|
-
end
|
|
67
|
-
private_class_method :today
|
|
68
|
-
|
|
69
62
|
def self.showings(cinema, dates)
|
|
70
63
|
indy = GftUk::Internal::Indy.new(cinema.url, site_id: cinema.id)
|
|
71
64
|
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.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.
|
|
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.
|
|
109
|
+
version: '5.8'
|
|
110
110
|
description: Pull movie & cinema information from the Glasgow Film Theatre website
|
|
111
111
|
email:
|
|
112
112
|
- andy@goodscary.com
|