Skip to content

Commit 7ff8a6b

Browse files
committed
Fix for ap-483
1 parent df94c22 commit 7ff8a6b

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 0.4.3 (2025-11-04)
2+
3+
- Refactor BerkeleyLibrary::AV::Util#do_get to use TIND API key if available in ENV
4+
15
# 0.4.2 (2024-10-10)
26

37
- Add TRANSCRIPTS to `AV::METADATA::FIELDS`

lib/berkeley_library/av/core/module_info.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class ModuleInfo
88
SUMMARY = 'UC Berkeley Library audio/video core code'.freeze
99
DESCRIPTION = 'Gem for UC Berkeley Library shared audio/video code'.freeze
1010
LICENSE = 'MIT'.freeze
11-
VERSION = '0.4.2'.freeze
11+
VERSION = '0.4.3'.freeze
1212
HOMEPAGE = 'https://github.com/BerkeleyLibrary/av-core'.freeze
1313

1414
private_class_method :new

lib/berkeley_library/av/metadata/readers/tind.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ def marc_uri_for(record_id)
2222
id_field = id_field_for(record_id)
2323
query_string = URI.encode_www_form(
2424
'p' => "#{id_field}:\"#{record_id}\"",
25-
'of' => 'xm'
25+
'format' => 'xml'
2626
)
27-
URIs.append(base_uri, 'search', '?', query_string)
27+
URIs.append(base_uri, 'api/v1/search', '?', query_string)
2828
end
2929

3030
protected

lib/berkeley_library/av/util.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@ module Util
1111

1212
DEFAULT_USER_AGENT = "#{Core::ModuleInfo::NAME} #{Core::ModuleInfo::VERSION} (#{Core::ModuleInfo::HOMEPAGE})".freeze
1313

14-
def do_get(uri, ignore_errors: false)
15-
body = URIs.get(uri, headers: { user_agent: DEFAULT_USER_AGENT })
14+
def do_get(uri, ignore_errors: false, headers: {})
15+
headers = { user_agent: DEFAULT_USER_AGENT }
16+
if uri.to_s.start_with?(BerkeleyLibrary::AV::Config.tind_base_uri.to_s) && ENV['LIT_TIND_API_KEY']
17+
headers[:authorization] = "Token #{ENV['LIT_TIND_API_KEY']}"
18+
end
19+
body = URIs.get(uri, headers:)
1620
body && body.scrub
1721
rescue RestClient::Exception
1822
raise unless ignore_errors

0 commit comments

Comments
 (0)