cinebase 5.8.0 → 5.9.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d3391ceb2ce2a381b5309a15b3a0fa381473715b64ea5beace6ec2b3ad78b539
4
- data.tar.gz: c42a345d442e3ac08927f4bf62a2a9643fbfb7968bc8ce1dff4f67f044477b15
3
+ metadata.gz: 7eff40769f29794d20f66b87e8d78a5295e6efb32acd0b59d7c2189456c1d98a
4
+ data.tar.gz: fabfa47d703f1aa2b4d8c6a06773a6435a36c974fd8775367ad844b7fec6f254
5
5
  SHA512:
6
- metadata.gz: 9239e384416cd3f879076fa276f70dc0156daf58ca3c603e5d114d5fa0c2c9bb2a67143648591811987a072a17034dac2e3cc3989ee5b1a7b82b0a4e7a05ed89
7
- data.tar.gz: 0d608521b1be86249fc9beb78e2ddfe236f5be565ace247579f2bed487b066891ae7686e34d77e5aa56e8812f9fc4403e1547f8d61cba4ce22fb88198404b879
6
+ metadata.gz: 429d9f452ab938b0c1e8e353c18efcc52c374698a9c38d27e60d09ef3001d0ae1226aff4015f28b60ed1c915e2af59389701fd1ecb515f7e30d689b54bcbe1ca
7
+ data.tar.gz: b9c3e3a3834facd2f41448c3788c76a693d57081fa844266706415df4bfd4bbeb1a178aeb3e159da1d6b44d19bd6524d6d06094b383e686f6a05de750e46c983
data/CHANGELOG.md CHANGED
@@ -2,6 +2,19 @@
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
+ ## [5.9.0] - 2026-11-03
6
+ ### Added
7
+ - `Cinebase::Event` for opera, ballet, theatre and exhibition screenings. `Performance#event` names the series from the `film_name` prefix the title sanitizer gives, such as `Met Opera: `, and `Performance#film_name` leaves it out.
8
+ - `Cinebase::Audience` reads relaxed, kids, baby, dog-friendly, members and preview labels from a raw title.
9
+ - `Performance` takes the raw `title:`. With it, `#variant` adds audience variants and `#festival` falls back to one named in the title.
10
+ - Festival prefixes for Cinecity, FFF, French Film Fest UK, IFF, Into Film Festival, JFF, LDNDOCS, London Palestine Film Festival, LPFF, NFF, Queer East, RFF, SLA and Women and the World Festival, with or without a year, which may have two digits.
11
+ - Bengali, Gujarati, Japanese, Romanian and Vietnamese language versions.
12
+
13
+ ### Changed
14
+ - `COMMON_REPLACE` names every spelling of a Met Opera, Royal Ballet and Opera, National Theatre Live, Exhibition on Screen or Bolshoi season with one prefix, including Met operas listed in an RBO season.
15
+ - `COMMON_REMOVE` also strips audience labels, festival gala labels, bracketed 3D and 4K, `4K Restoration`, restorations after an anniversary, square-bracketed anniversaries, bracketed encores, `(Recorded)`, `(English Dubbed)`, `- Live On Stage`, and `+ ScreenTalk`, `+ Intro` and `+ Short Film` add-ons.
16
+ - Titles listed in capitals are title cased.
17
+
5
18
  ## [5.8.0] - 2026-11-02
6
19
  ### Added
7
20
  - `Cinebase::Http` for chain gems' requests: `get`, and `post` with a form or JSON body, over HTTPS. It retries dropped connections twice, never follows redirects, raises errors that name the status and host but leave out the body, and returns bodies as UTF-8. `keep_alive: true` reuses one connection per host until `close`. Tests stub `Cinebase::Http.pause` to skip the waits between attempts.
data/README.md CHANGED
@@ -53,7 +53,8 @@ module CinemaChainName
53
53
  def self.at(cinema_id)
54
54
  # parse webpages or apis to get performances for a cinema, built with
55
55
  # booking_url:, cinema_id:, cinema_name:, dimension:, festival:,
56
- # film_name:, film_year:, language:, starting_at: and variant:
56
+ # film_name:, film_year:, language:, starting_at:, title: (the raw
57
+ # title) and variant:
57
58
  end
58
59
  end
59
60
  end
@@ -93,6 +94,38 @@ Cinebase::Festival.from_title('UKJFF - From Cable Street To Brick Lane', year: 2
93
94
 
94
95
  `COMMON_REMOVE` strips the same prefixes from titles.
95
96
 
97
+ ### Stage shows
98
+
99
+ The common rules name opera, ballet, theatre and exhibition screenings with
100
+ one prefix per series, such as `Met Opera: Tosca`. A performance strips it
101
+ from `film_name` and names the series as its `event`, with an `arts` variant:
102
+
103
+ ```ruby
104
+ performance = CinemaChainName::Performance.new(film_name: 'Met Opera: Tosca', ...)
105
+ performance.film_name #=> "Tosca"
106
+ performance.event #=> #<data Cinebase::Event name="Met Opera">
107
+ ```
108
+
109
+ A chain's own `replace` rules should produce the same prefixes.
110
+
111
+ ### Audiences
112
+
113
+ Some chains name relaxed, toddler, parent and baby, dog-friendly, members'
114
+ or preview screenings in the title. `COMMON_REMOVE` strips the label, and a
115
+ performance given `title:` adds the variant:
116
+
117
+ ```ruby
118
+ Cinebase::Audience.variants('Relaxed Screening: Wicked') #=> ["relaxed"]
119
+ ```
120
+
121
+ A performance given `title:` also finds its festival when not given one.
122
+
123
+ ### Titles in capitals
124
+
125
+ A title listed in capitals is title cased, keeping acronyms without vowels,
126
+ Roman numerals and words with digits: `ROCKY IV` reads `Rocky IV`, and
127
+ `BTS 'ARIRANG'` reads `BTS 'Arirang'`.
128
+
96
129
  ### Film years
97
130
 
98
131
  Titles often end with the film's year. `COMMON_REMOVE` strips it, and
@@ -76,6 +76,7 @@ module Cinebase
76
76
  film_year: TitleSanitizer.film_year(title),
77
77
  language: title[LANGUAGE, 1],
78
78
  starting_at: showing.starting_at,
79
+ title: title,
79
80
  variant: variant(showing)
80
81
  }
81
82
  end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cinebase
4
+ # Screenings for a particular audience, which some chains name in the title
5
+ module Audience
6
+ SEPARATOR = /\s*[-–:]?\s*/
7
+
8
+ # Title labels, keyed by the variant they mark
9
+ LABELS = {
10
+ 'kids' => [/\A(?:Toddler (?:Club|Kino)|Kids'? Club)\s*:\s*/i],
11
+ 'relaxed' => [/\ARelaxed(?: Screening)?\s*:\s*/i, /#{SEPARATOR}(?:Sensory|Autism) Friendly Screening\z/i],
12
+ 'dog_friendly' => [/\ADog-Friendly Screening\s*:\s*/i],
13
+ 'baby' => [/\s*\(Parent (?:&|and) Baby(?: Only Show)?\)/i],
14
+ 'members' => [/#{SEPARATOR}(?:Unlimited|MyOmnipass Member) Screening\z/i],
15
+ 'preview' => [/\s*[-–]\s*(?:Special )?Preview\z/i]
16
+ }.freeze
17
+
18
+ PATTERNS = LABELS.values.flatten.freeze
19
+
20
+ # @param [String] title raw film title
21
+ # @return [Array<String>] variants the title's labels mark
22
+ def self.variants(title)
23
+ LABELS.select { |_, patterns| patterns.any? { |pattern| title.match?(pattern) } }.keys
24
+ end
25
+ end
26
+ end
@@ -62,6 +62,7 @@ module Cinebase
62
62
  film_year: TitleSanitizer.film_year(title),
63
63
  language: showtime.language || title[/\((#{TitleSanitizer::LANGUAGES.join('|')})\)/i, 1],
64
64
  starting_at: starting_at,
65
+ title: title,
65
66
  variant: showtime.variant
66
67
  }
67
68
  end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cinebase
4
+ Event = Data.define(:name)
5
+
6
+ # A stage show or exhibition screened in cinemas rather than a film
7
+ class Event
8
+ # Prefixes title sanitizers give these shows, keyed by the series
9
+ PREFIXES = {
10
+ 'Met Opera' => /\AMet Opera: /,
11
+ 'Royal Ballet and Opera' => /\A(?:Royal Ballet and Opera|The Royal Ballet|The Royal Opera): /,
12
+ 'National Theatre Live' => /\A(?:National Theatre Live|National Theatre|NT Live): /,
13
+ 'Exhibition on Screen' => /\AExhibition on Screen: /,
14
+ 'Bolshoi Ballet' => /\ABolshoi(?: Ballet)?: /
15
+ }.freeze
16
+
17
+ PREFIX = Regexp.union(PREFIXES.values)
18
+
19
+ # @param [String] film_name sanitized film name, e.g. "Met Opera: Tosca"
20
+ # @return [Cinebase::Event, nil]
21
+ def self.from_name(film_name)
22
+ name, = PREFIXES.find { |_, prefix| film_name.match?(prefix) }
23
+ new(name: name) if name
24
+ end
25
+
26
+ # @param [String] film_name sanitized film name, e.g. "Met Opera: Tosca"
27
+ # @return [String] the show's own name, e.g. "Tosca"
28
+ def self.strip(film_name)
29
+ film_name.sub(PREFIX, '')
30
+ end
31
+ end
32
+ end
@@ -5,15 +5,22 @@ module Cinebase
5
5
 
6
6
  # An annual festival edition a film is screened in
7
7
  class Festival
8
+ NAMES = [
9
+ 'CFF', 'Cinecity', 'FFF', 'French Film Fest UK', 'IFF', 'Into Film Festival', 'JFF', 'LDNDOCS',
10
+ 'London Palestine Film Festival', 'LPFF', 'NFF', 'Queer East', 'RFF', 'SLA', 'UKJFF',
11
+ 'Women and the World Festival'
12
+ ].freeze
13
+
8
14
  # Title prefixes naming a festival: the name, then the year when given
9
15
  PREFIXES = [
10
16
  /\A(Cine-Excess) (20\d{2}): /,
11
17
  /\A(Cinemagic) (\d{4}) -/,
12
- /\A(UKJFF) -/,
13
- /\A(CFF): /,
14
- /\A(Horror Season) (20\d{2}) /
18
+ /\A(Horror Season) (20\d{2}) /,
19
+ /\A(#{NAMES.map { |name| Regexp.escape(name) }.join('|')})(?: ((?:20)?\d{2}))?\s*[:–-]\s*/
15
20
  ].freeze
16
21
 
22
+ CENTURY = 2000
23
+
17
24
  # @param [String] title raw film title
18
25
  # @param [Integer] year the edition when the title gives none, usually the
19
26
  # screening's year
@@ -21,9 +28,18 @@ module Cinebase
21
28
  def self.from_title(title, year:)
22
29
  PREFIXES.each do |prefix|
23
30
  match = title.match(prefix)
24
- return new(name: match[1], year: Integer(match[2] || year)) if match
31
+ return new(name: match[1], year: edition(match[2]) || year) if match
25
32
  end
26
33
  nil
27
34
  end
35
+
36
+ # "26" in "Queer East 26:" is 2026
37
+ def self.edition(year)
38
+ return unless year
39
+
40
+ year = Integer(year, 10)
41
+ year < 100 ? CENTURY + year : year
42
+ end
43
+ private_class_method :edition
28
44
  end
29
45
  end
@@ -7,10 +7,9 @@ module Cinebase
7
7
  attr_reader :dimension
8
8
  attr_reader :cinema_id
9
9
  attr_reader :cinema_name
10
- attr_reader :festival
11
- attr_reader :film_name
12
10
  attr_reader :film_year
13
11
  attr_reader :language
12
+ attr_reader :title
14
13
 
15
14
  def initialize(options)
16
15
  @booking_url = options.fetch(:booking_url, nil)
@@ -22,6 +21,7 @@ module Cinebase
22
21
  @film_year = options.fetch(:film_year, nil)
23
22
  @language = options.fetch(:language, nil)
24
23
  @time = options.fetch(:starting_at)
24
+ @title = options.fetch(:title, nil)
25
25
  @variant = options.fetch(:variant, [])
26
26
  end
27
27
 
@@ -43,14 +43,36 @@ module Cinebase
43
43
  starting_at.to_date
44
44
  end
45
45
 
46
+ # Given, or named by the raw title
47
+ def festival
48
+ @festival || (title && Festival.from_title(title, year: starting_at.year))
49
+ end
50
+
51
+ # The show's own name when it is an Event, e.g. "Tosca"
52
+ def film_name
53
+ Event.strip(@film_name)
54
+ end
55
+
56
+ # A stage show or exhibition, which title sanitizers name as a prefix
57
+ def event
58
+ Event.from_name(@film_name)
59
+ end
60
+
46
61
  def variant
47
62
  @variant = @variant.split(' ') if @variant.is_a?(String)
48
- @variant.map(&:downcase).sort.uniq
63
+ (@variant + title_variants).map(&:downcase).sort.uniq
49
64
  end
50
65
 
51
66
  # English subtitles or open captions
52
67
  def subtitled?
53
68
  variant.include?('subtitled')
54
69
  end
70
+
71
+ private
72
+
73
+ def title_variants
74
+ audiences = title ? Audience.variants(title) : []
75
+ event ? audiences + %w(arts) : audiences
76
+ end
55
77
  end
56
78
  end
@@ -12,7 +12,9 @@ module Cinebase
12
12
  replace.each do |pattern, prefix|
13
13
  sanitized.gsub!(pattern) { |_| prefix + $1 }
14
14
  end
15
- sanitized.squeeze(' ').strip
15
+ sanitized = sanitized.squeeze(' ').strip
16
+ series = sanitized[Event::PREFIX].to_s
17
+ series + title_case(sanitized.delete_prefix(series))
16
18
  end
17
19
  end
18
20
 
@@ -32,25 +34,33 @@ module Cinebase
32
34
  # Rules every chain can share; subclasses opt in after their own patterns,
33
35
  # e.g. `[...] + COMMON_REMOVE` in #remove
34
36
  class TitleSanitizer
35
- LANGUAGES = %w(Arabic Cantonese French Hindi Kannada Korean Lithuanian
36
- Malayalam Mandarin Marathi Polish Punjabi Tamil Telugu
37
- Turkish).freeze
37
+ LANGUAGES = %w(Arabic Bengali Cantonese French Gujarati Hindi Japanese
38
+ Kannada Korean Lithuanian Malayalam Mandarin Marathi Polish
39
+ Punjabi Romanian Tamil Telugu Turkish Vietnamese).freeze
38
40
 
39
41
  # A trailing "(1996)", allowing other bracketed markers after it
40
42
  FILM_YEAR = /\s*\((1[89]\d{2}|20\d{2})\)(?=(?:\s*\([^)]*\))*\s*\z)/
41
43
 
42
44
  COMMON_REMOVE = [
43
45
  *Festival::PREFIXES, # festival prefix
46
+ *Audience::PATTERNS, # audience label
47
+ /\A(?:Opening|Closing|Centrepiece|Documentary)(?: Night)? Gala:\s*/i, # festival gala
44
48
  /\s+[23]d\b/i, # dimension
49
+ /\s*\([23]D\)/i, # bracketed dimension
45
50
  /\((#{LANGUAGES.join('|')})\)/i, # language version
46
- /\((Dubbed|Subbed|English Dub|[^)]*subtitles)\)/i, # dub or subtitle version
47
- /\(\d+(st|nd|rd|th) Anniversary\)/i, # anniversary re-release
51
+ /\((Dubbed|Subbed|English Dub(?:bed)?|[^)]*subtitles)\)/i, # dub or subtitle version
52
+ /\s*[(\[]\d+(st|nd|rd|th) Anniversary(?: 4K)?(?: Restoration)?[)\]]/i, # anniversary re-release
53
+ /\s*\(4K(?: Restoration)?\)/i, # bracketed 4K restoration
54
+ /\s*\((?:20\d{2} )?Encore\)/i, # bracketed encore
55
+ /\s*\(Recorded\)/i, # recorded, not live
56
+ /\s+-\s+Live On Stage\z/i, # filmed stage show
48
57
  /\(Re-release\)/i, # re-release
49
58
  FILM_YEAR, # film year, see .film_year
50
59
  /\s*\+\s*(?:[\w-]+\s+)*Q(?:&|\+)A\z/i, # Q&A add-on
51
60
  /\s*\+\s*Discussion\z/i, # discussion add-on
61
+ /\s*\+\s*(?:ScreenTalk|Intro(?:duction)?|Short Film)\z/i, # talk or short add-on
52
62
  /\s*\((35|70)mm\)/i, # film gauge
53
- /\s+4K\b/, # 4K restoration
63
+ /\s+4K(?: Restoration)?\b/i, # 4K restoration
54
64
  /:\s*Encore\z/i, # encore
55
65
  /\bsing-?a-?long\z/i, # singalong
56
66
  'amp;' # html ampersands
@@ -62,10 +72,54 @@ module Cinebase
62
72
  title[FILM_YEAR, 1]&.to_i
63
73
  end
64
74
 
75
+ ARTS_SEASON = %r{\s*(?:(?:20)?\d{2}[-/]\d{2})?}
76
+ ARTS_SEPARATOR = %r{(?:\s*[:/]\s*|\s+[-–]\s+)}
77
+
78
+ # Arts series named the way Event::PREFIXES expects; Met Opera first, as
79
+ # some chains list it inside an RBO season
65
80
  COMMON_REPLACE = {
66
- /Met Opera (?:Encore )?20\d{2}-\d{2}: (.*)/ => 'Met Opera: ',
67
- /RBO (?:Cinema Season )?20\d{2}-\d{2}: (.*)/ => 'Royal Ballet and Opera: ',
68
- /WORLD TOUR(.*)/ => 'World Tour'
81
+ /\A(?:RBO[^:]*:\s*)?(?:The )?Met\.?(?: Opera)?(?:\s+(?:Live|Encore))?#{ARTS_SEASON}#{ARTS_SEPARATOR}(.*)/i =>
82
+ 'Met Opera: ',
83
+ /\A(?:RBO|Royal Ballet (?:and|&) Opera|(?:The )?Royal (?:Ballet|Opera))(?:\s+(?:Live|Encore|Cinema Season))?#{ARTS_SEASON}#{ARTS_SEPARATOR}(?:The Royal (?:Ballet|Opera)\s+[-–]\s+)?(.*)/i =>
84
+ 'Royal Ballet and Opera: ',
85
+ /\A(?:NT (?:Live|Encore)(?: Encore)?|NTL|National Theatre(?: Live)?)#{ARTS_SEPARATOR}(.*)/i => 'National Theatre Live: ',
86
+ /\AExhibition on Screen#{ARTS_SEPARATOR}(.*)/i => 'Exhibition on Screen: ',
87
+ /\ABolshoi(?: Ballet)?#{ARTS_SEPARATOR}(.*)/i => 'Bolshoi Ballet: ',
88
+ /WORLD TOUR(.*)/ => 'World Tour'
69
89
  }.freeze
90
+
91
+ SMALL_WORDS = %w(a an and as at but by for from in into nor of on or the to v vs with).freeze
92
+ HONORIFICS = %w(dr mr mrs ms st).freeze
93
+ ROMAN_NUMERAL = /\A(?=[IVX])X{0,3}(?:IX|IV|V?I{0,3})\z/
94
+ VOWEL = /[AEIOUYÀ-Ý]/
95
+ OPENS_PHRASE = /[:\-–]\z/
96
+
97
+ private
98
+
99
+ # A title listed in capitals, such as "ROCKY IV", reads "Rocky IV"
100
+ def title_case(text)
101
+ if text.match?(/\p{Ll}/)
102
+ text
103
+ else
104
+ words = text.split(' ')
105
+ words.each_with_index.map do |word, index|
106
+ title_case_word(word, opens_phrase: index.zero? || words[index - 1].match?(OPENS_PHRASE))
107
+ end.join(' ')
108
+ end
109
+ end
110
+
111
+ # Acronyms such as "BTS", numerals and words with digits keep capitals
112
+ def title_case_word(word, opens_phrase:)
113
+ letters = word.gsub(/\P{L}/, '').downcase
114
+ if word.match?(/\d/) || word.match?(ROMAN_NUMERAL)
115
+ word
116
+ elsif !opens_phrase && SMALL_WORDS.include?(letters)
117
+ word.downcase
118
+ elsif !word.match?(VOWEL) && !HONORIFICS.include?(letters)
119
+ word
120
+ else
121
+ word.split('-').map { |part| part.downcase.sub(/\p{L}/, &:upcase) }.join('-')
122
+ end
123
+ end
70
124
  end
71
125
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Cinebase version
4
4
  module Cinebase
5
- VERSION = '5.8.0'
5
+ VERSION = '5.9.0'
6
6
  end
data/lib/cinebase.rb CHANGED
@@ -5,7 +5,9 @@ require 'tzinfo/data'
5
5
 
6
6
  require 'cinebase/version'
7
7
 
8
+ require 'cinebase/audience'
8
9
  require 'cinebase/cinema'
10
+ require 'cinebase/event'
9
11
  require 'cinebase/festival'
10
12
  require 'cinebase/http'
11
13
  require 'cinebase/london'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cinebase
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.8.0
4
+ version: 5.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Croll
@@ -163,12 +163,14 @@ files:
163
163
  - lib/cinebase/a1web/listings.rb
164
164
  - lib/cinebase/a1web/performance.rb
165
165
  - lib/cinebase/a1web/showing.rb
166
+ - lib/cinebase/audience.rb
166
167
  - lib/cinebase/boxoffice.rb
167
168
  - lib/cinebase/boxoffice/cinema.rb
168
169
  - lib/cinebase/boxoffice/client.rb
169
170
  - lib/cinebase/boxoffice/performance.rb
170
171
  - lib/cinebase/boxoffice/showtime.rb
171
172
  - lib/cinebase/cinema.rb
173
+ - lib/cinebase/event.rb
172
174
  - lib/cinebase/festival.rb
173
175
  - lib/cinebase/http.rb
174
176
  - lib/cinebase/london.rb