bandcamp-discover 0.8.0 → 0.8.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: 4591eadf76413cf74687ca5c4233890ff1c2e96d641dd8d966c8a1336935e00d
4
- data.tar.gz: cbf6cb74fca34d127a78469106af4d89597d04f1a812cd1f748ef96e0ae186b0
3
+ metadata.gz: ecd43fd0b46fd8157743d881e513bb9a34abbf6241819a48d60f8bc1e82ca084
4
+ data.tar.gz: 3cd9fed33d330e6db6231aa8d19988405c264bc458eef6e4fd86bd3a0b1bcad1
5
5
  SHA512:
6
- metadata.gz: 9eba8a9fbb1ebf9c31195bb2c4cfda3d00601d66dc4773c9590bc3e2368585e0522734b4c6f3540e27e28b13a9314a770535d893070edfcd5444ed99b8dbb49d
7
- data.tar.gz: 6d5a34e8edd6c23cd1db88803e8c392911f96eb1a20eea31fe2fb31ed4258c423dc2e7ff14e243255a431e7f529eff3e20f2870bfe58deef6847a4f6c5f7c074
6
+ metadata.gz: 86d35206ccb8681009ab5c46dd7fef88db2122e0e0763ad99c35eef3e8ec73ca73779a77351250536b3774fe0bf80a22fa75c1290ea3ff132309e60cb2861672
7
+ data.tar.gz: a6b8bc9bfe4ea77ecbe29db09da5baa2236aa580211b2bed4e8a61a20a105eb14a01a760ca4e1e4484b8563c2864069619b29e5f583969a72219537ab65b4bf0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bandcamp-discover (0.8.0)
4
+ bandcamp-discover (0.8.1)
5
5
  async
6
6
  base64
7
7
  concurrent-ruby
@@ -23,6 +23,11 @@ module BandcampDiscover
23
23
  # "a" is albums, "s" is subscriptions.
24
24
  RESULT_TYPES = %w[a s].freeze
25
25
 
26
+ # Bandcamp renamed the response fields from snake_case to camelCase in
27
+ # November 2026 while the request stayed snake_case. Both are read in case
28
+ # it rolls back or only part of their fleet has it.
29
+ BAND_URL_KEYS = %w[bandUrl band_url].freeze
30
+
26
31
  class ResponseError < StandardError; end
27
32
 
28
33
  # browser: is unused, kept so existing callers do not break.
@@ -69,7 +74,7 @@ module BandcampDiscover
69
74
  results = body["results"]
70
75
  break if results.empty?
71
76
 
72
- urls.concat(results.map { root_url(_1["band_url"]) }.compact)
77
+ urls.concat(results.map { root_url(band_url(_1)) }.compact)
73
78
 
74
79
  cursor = body["cursor"]
75
80
  break if cursor.nil? || cursor.empty?
@@ -115,12 +120,16 @@ module BandcampDiscover
115
120
  raise ResponseError, "discover_web response has no results array (keys: #{body.is_a?(Hash) ? body.keys.inspect : body.class})"
116
121
  end
117
122
 
118
- return if body["results"].empty? || body["results"].any? { _1.is_a?(Hash) && _1.key?("band_url") }
123
+ return if body["results"].empty? || body["results"].any? { _1.is_a?(Hash) && _1.keys.intersect?(BAND_URL_KEYS) }
124
+
125
+ raise ResponseError, "discover_web results carry no band url (looked for #{BAND_URL_KEYS.join(", ")}; keys: #{body["results"].first.keys.inspect})"
126
+ end
119
127
 
120
- raise ResponseError, "discover_web results carry no band_url (keys: #{body["results"].first.keys.inspect})"
128
+ def band_url(result)
129
+ result.values_at(*BAND_URL_KEYS).compact.first
121
130
  end
122
131
 
123
- # Strips the ?from=discover_page band_url carries.
132
+ # Strips the ?from=discover_page the band url carries.
124
133
  def root_url(band_url)
125
134
  return nil if band_url.nil? || band_url.empty?
126
135
 
@@ -1,3 +1,3 @@
1
1
  module BandcampDiscover
2
- VERSION = "0.8.0"
2
+ VERSION = "0.8.1"
3
3
  end
@@ -14,7 +14,7 @@ class DiscoverTest < Minitest::Test
14
14
 
15
15
  def batch(band_urls, cursor: nil)
16
16
  {
17
- "results" => band_urls.map { {"band_url" => _1, "item_type" => "a"} },
17
+ "results" => band_urls.map { {"bandUrl" => _1, "itemType" => "a"} },
18
18
  "cursor" => cursor
19
19
  }
20
20
  end
@@ -71,11 +71,19 @@ class DiscoverTest < Minitest::Test
71
71
  assert_match(/no results array/, error.message)
72
72
  end
73
73
 
74
- def test_raises_when_results_no_longer_carry_band_url
75
- scraper = build(batches: [{"results" => [{"item_id" => 1, "band_name" => "x"}], "cursor" => nil}])
74
+ def test_raises_when_results_no_longer_carry_a_band_url
75
+ scraper = build(batches: [{"results" => [{"itemId" => 1, "bandName" => "x"}], "cursor" => nil}])
76
76
 
77
77
  error = assert_raises(Discover::ResponseError) { collect(scraper) }
78
- assert_match(/no band_url/, error.message)
78
+ assert_match(/no band url/, error.message)
79
+ assert_match(/itemId/, error.message)
80
+ end
81
+
82
+ # The spelling the API used until November 2026.
83
+ def test_still_reads_snake_case_results
84
+ scraper = build(batches: [{"results" => [{"band_url" => "https://a.bandcamp.com?from=discover_page"}], "cursor" => nil}])
85
+
86
+ assert_equal ["https://a.bandcamp.com"], collect(scraper)
79
87
  end
80
88
 
81
89
  def test_empty_results_is_not_an_error
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bandcamp-discover
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian RUbisch
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2026-09-08 00:00:00.000000000 Z
10
+ date: 2026-11-19 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rake