alexandria-book-collection-manager 0.7.8 → 0.7.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +45 -50
- data/.rubocop.yml +18 -5
- data/.rubocop_todo.yml +29 -22
- data/CHANGELOG.md +29 -0
- data/ChangeLog.0 +19 -19
- data/INSTALL.md +3 -5
- data/README.md +0 -5
- data/Rakefile +11 -11
- data/alexandria-book-collection-manager.gemspec +35 -34
- data/doc/FAQ +2 -2
- data/lib/alexandria/about.rb +1 -1
- data/lib/alexandria/book_providers/bl_provider.rb +88 -0
- data/lib/alexandria/book_providers/loc_provider.rb +38 -0
- data/lib/alexandria/book_providers/pseudomarc.rb +1 -1
- data/lib/alexandria/book_providers/sbn_provider.rb +108 -0
- data/lib/alexandria/book_providers/thalia_provider.rb +1 -1
- data/lib/alexandria/book_providers/web.rb +2 -2
- data/lib/alexandria/book_providers/worldcat.rb +9 -7
- data/lib/alexandria/book_providers/z3950_provider.rb +199 -0
- data/lib/alexandria/book_providers.rb +10 -25
- data/lib/alexandria/default_preferences.rb +1 -1
- data/lib/alexandria/export_library.rb +10 -10
- data/lib/alexandria/image_fetcher.rb +25 -0
- data/lib/alexandria/import_library.rb +9 -9
- data/lib/alexandria/library_store.rb +3 -4
- data/lib/alexandria/models/book.rb +13 -0
- data/lib/alexandria/models/library.rb +13 -21
- data/lib/alexandria/preferences.rb +4 -6
- data/lib/alexandria/scanners/cue_cat.rb +1 -1
- data/lib/alexandria/ui/about_dialog.rb +1 -1
- data/lib/alexandria/ui/acquire_dialog.rb +6 -9
- data/lib/alexandria/ui/barcode_animation.rb +1 -1
- data/lib/alexandria/ui/book_properties_dialog_base.rb +2 -6
- data/lib/alexandria/ui/completion_models.rb +1 -5
- data/lib/alexandria/ui/conflict_while_copying_dialog.rb +1 -1
- data/lib/alexandria/ui/listview.rb +1 -1
- data/lib/alexandria/ui/multi_drag_treeview.rb +1 -1
- data/lib/alexandria/ui/new_book_dialog.rb +11 -13
- data/lib/alexandria/ui/new_book_dialog_manual.rb +1 -1
- data/lib/alexandria/ui/preferences_dialog.rb +2 -2
- data/lib/alexandria/ui/provider_preferences_base_dialog.rb +1 -1
- data/lib/alexandria/ui/really_delete_dialog.rb +1 -1
- data/lib/alexandria/ui/ui_manager.rb +14 -22
- data/lib/alexandria/version.rb +1 -1
- data/po/cs.po +90 -125
- data/po/cy.po +87 -125
- data/po/de.po +96 -125
- data/po/el.po +96 -125
- data/po/es.po +96 -125
- data/po/fr.po +90 -125
- data/po/ga.po +83 -124
- data/po/gl.po +90 -125
- data/po/it.po +90 -125
- data/po/ja.po +90 -125
- data/po/mk.po +96 -125
- data/po/nb.po +90 -125
- data/po/nl.po +107 -124
- data/po/pl.po +113 -124
- data/po/pt.po +90 -125
- data/po/pt_BR.po +90 -125
- data/po/ru.po +92 -124
- data/po/sk.po +90 -125
- data/po/sv.po +90 -125
- data/po/uk.po +90 -125
- data/po/zh_TW.po +90 -125
- data/schemas/alexandria.schemas +1 -1
- data/share/gnome/help/alexandria/C/adding-books.xml +3 -4
- data/share/gnome/help/alexandria/C/introduction.xml +0 -16
- data/share/gnome/help/alexandria/C/searching.xml +1 -4
- data/share/gnome/help/alexandria/C/settings.xml +0 -30
- data/share/gnome/help/alexandria/fr/alexandria.xml +4 -159
- data/share/gnome/help/alexandria/ja/adding-books.xml +1 -1
- data/share/gnome/help/alexandria/ja/introduction.xml +0 -15
- data/share/gnome/help/alexandria/ja/searching.xml +3 -7
- data/share/gnome/help/alexandria/ja/settings.xml +0 -27
- data/spec/alexandria/book_providers/bl_provider_spec.rb +13 -0
- data/spec/alexandria/book_providers/loc_provider_spec.rb +17 -0
- data/spec/alexandria/book_providers/sbn_provider_spec.rb +13 -0
- data/spec/alexandria/book_providers_spec.rb +0 -81
- data/spec/alexandria/library_spec.rb +20 -2
- data/spec/alexandria/ui/import_dialog_spec.rb +1 -1
- data/spec/alexandria/ui/new_smart_library_dialog_spec.rb +1 -1
- data/spec/alexandria/ui/preferences_dialog_spec.rb +1 -1
- data/spec/alexandria/ui/ui_manager_spec.rb +78 -2
- data/spec/data/libraries/0.6.2/My Library/9780571147168.yaml +2 -0
- data/util/rake/fileinstall.rb +4 -4
- data/util/rake/omfgenerate.rb +1 -1
- metadata +69 -55
- data/lib/alexandria/book_providers/adlibris.rb +0 -191
- data/lib/alexandria/book_providers/amazon_aws.rb +0 -239
- data/lib/alexandria/book_providers/amazon_ecs_util.rb +0 -373
- data/lib/alexandria/book_providers/barnes_and_noble.rb +0 -209
- data/lib/alexandria/book_providers/proxis.rb +0 -176
- data/lib/alexandria/book_providers/siciliano.rb +0 -256
- data/lib/alexandria/book_providers/z3950.rb +0 -408
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alexandria-book-collection-manager
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander McCormmach
|
@@ -28,7 +28,7 @@ authors:
|
|
28
28
|
autorequire:
|
29
29
|
bindir: bin
|
30
30
|
cert_chain: []
|
31
|
-
date:
|
31
|
+
date: 2022-02-04 00:00:00.000000000 Z
|
32
32
|
dependencies:
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: gettext
|
@@ -50,98 +50,110 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: 3.
|
53
|
+
version: 3.5.0
|
54
54
|
type: :runtime
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
58
|
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: 3.
|
60
|
+
version: 3.5.0
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: gtk3
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
64
64
|
requirements:
|
65
65
|
- - "~>"
|
66
66
|
- !ruby/object:Gem::Version
|
67
|
-
version: 3.
|
67
|
+
version: 3.5.0
|
68
68
|
type: :runtime
|
69
69
|
prerelease: false
|
70
70
|
version_requirements: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
72
|
- - "~>"
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version: 3.
|
74
|
+
version: 3.5.0
|
75
75
|
- !ruby/object:Gem::Dependency
|
76
|
-
name:
|
76
|
+
name: htmlentities
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
78
78
|
requirements:
|
79
79
|
- - "~>"
|
80
80
|
- !ruby/object:Gem::Version
|
81
|
-
version:
|
81
|
+
version: '4.3'
|
82
82
|
type: :runtime
|
83
83
|
prerelease: false
|
84
84
|
version_requirements: !ruby/object:Gem::Requirement
|
85
85
|
requirements:
|
86
86
|
- - "~>"
|
87
87
|
- !ruby/object:Gem::Version
|
88
|
-
version:
|
88
|
+
version: '4.3'
|
89
89
|
- !ruby/object:Gem::Dependency
|
90
|
-
name:
|
90
|
+
name: image_size
|
91
91
|
requirement: !ruby/object:Gem::Requirement
|
92
92
|
requirements:
|
93
93
|
- - "~>"
|
94
94
|
- !ruby/object:Gem::Version
|
95
|
-
version: '
|
95
|
+
version: '3.0'
|
96
96
|
type: :runtime
|
97
97
|
prerelease: false
|
98
98
|
version_requirements: !ruby/object:Gem::Requirement
|
99
99
|
requirements:
|
100
100
|
- - "~>"
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
version: '
|
102
|
+
version: '3.0'
|
103
103
|
- !ruby/object:Gem::Dependency
|
104
|
-
name:
|
104
|
+
name: marc
|
105
105
|
requirement: !ruby/object:Gem::Requirement
|
106
106
|
requirements:
|
107
|
-
- - "
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '1.0'
|
110
|
+
- - "<"
|
108
111
|
- !ruby/object:Gem::Version
|
109
|
-
version: '2
|
112
|
+
version: '1.2'
|
110
113
|
type: :runtime
|
111
114
|
prerelease: false
|
112
115
|
version_requirements: !ruby/object:Gem::Requirement
|
113
116
|
requirements:
|
114
|
-
- - "
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '1.0'
|
120
|
+
- - "<"
|
115
121
|
- !ruby/object:Gem::Version
|
116
|
-
version: '2
|
122
|
+
version: '1.2'
|
117
123
|
- !ruby/object:Gem::Dependency
|
118
|
-
name:
|
124
|
+
name: nokogiri
|
119
125
|
requirement: !ruby/object:Gem::Requirement
|
120
126
|
requirements:
|
121
127
|
- - "~>"
|
122
128
|
- !ruby/object:Gem::Version
|
123
|
-
version: 1.
|
129
|
+
version: '1.11'
|
124
130
|
type: :runtime
|
125
131
|
prerelease: false
|
126
132
|
version_requirements: !ruby/object:Gem::Requirement
|
127
133
|
requirements:
|
128
134
|
- - "~>"
|
129
135
|
- !ruby/object:Gem::Version
|
130
|
-
version: 1.
|
136
|
+
version: '1.11'
|
131
137
|
- !ruby/object:Gem::Dependency
|
132
138
|
name: psych
|
133
139
|
requirement: !ruby/object:Gem::Requirement
|
134
140
|
requirements:
|
135
|
-
- - "
|
141
|
+
- - ">="
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '3.2'
|
144
|
+
- - "<"
|
136
145
|
- !ruby/object:Gem::Version
|
137
|
-
version:
|
146
|
+
version: '4.1'
|
138
147
|
type: :runtime
|
139
148
|
prerelease: false
|
140
149
|
version_requirements: !ruby/object:Gem::Requirement
|
141
150
|
requirements:
|
142
|
-
- - "
|
151
|
+
- - ">="
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '3.2'
|
154
|
+
- - "<"
|
143
155
|
- !ruby/object:Gem::Version
|
144
|
-
version:
|
156
|
+
version: '4.1'
|
145
157
|
- !ruby/object:Gem::Dependency
|
146
158
|
name: zoom
|
147
159
|
requirement: !ruby/object:Gem::Requirement
|
@@ -171,103 +183,103 @@ dependencies:
|
|
171
183
|
- !ruby/object:Gem::Version
|
172
184
|
version: 0.3.0
|
173
185
|
- !ruby/object:Gem::Dependency
|
174
|
-
name:
|
186
|
+
name: rake
|
175
187
|
requirement: !ruby/object:Gem::Requirement
|
176
188
|
requirements:
|
177
189
|
- - "~>"
|
178
190
|
- !ruby/object:Gem::Version
|
179
|
-
version: '
|
191
|
+
version: '13.0'
|
180
192
|
type: :development
|
181
193
|
prerelease: false
|
182
194
|
version_requirements: !ruby/object:Gem::Requirement
|
183
195
|
requirements:
|
184
196
|
- - "~>"
|
185
197
|
- !ruby/object:Gem::Version
|
186
|
-
version: '
|
198
|
+
version: '13.0'
|
187
199
|
- !ruby/object:Gem::Dependency
|
188
|
-
name:
|
200
|
+
name: rspec
|
189
201
|
requirement: !ruby/object:Gem::Requirement
|
190
202
|
requirements:
|
191
203
|
- - "~>"
|
192
204
|
- !ruby/object:Gem::Version
|
193
|
-
version: '
|
205
|
+
version: '3.0'
|
194
206
|
type: :development
|
195
207
|
prerelease: false
|
196
208
|
version_requirements: !ruby/object:Gem::Requirement
|
197
209
|
requirements:
|
198
210
|
- - "~>"
|
199
211
|
- !ruby/object:Gem::Version
|
200
|
-
version: '
|
212
|
+
version: '3.0'
|
201
213
|
- !ruby/object:Gem::Dependency
|
202
|
-
name:
|
214
|
+
name: rubocop
|
203
215
|
requirement: !ruby/object:Gem::Requirement
|
204
216
|
requirements:
|
205
217
|
- - "~>"
|
206
218
|
- !ruby/object:Gem::Version
|
207
|
-
version: '
|
219
|
+
version: '1.25'
|
208
220
|
type: :development
|
209
221
|
prerelease: false
|
210
222
|
version_requirements: !ruby/object:Gem::Requirement
|
211
223
|
requirements:
|
212
224
|
- - "~>"
|
213
225
|
- !ruby/object:Gem::Version
|
214
|
-
version: '
|
226
|
+
version: '1.25'
|
215
227
|
- !ruby/object:Gem::Dependency
|
216
|
-
name: rubocop
|
228
|
+
name: rubocop-i18n
|
217
229
|
requirement: !ruby/object:Gem::Requirement
|
218
230
|
requirements:
|
219
231
|
- - "~>"
|
220
232
|
- !ruby/object:Gem::Version
|
221
|
-
version: 0
|
233
|
+
version: '3.0'
|
222
234
|
type: :development
|
223
235
|
prerelease: false
|
224
236
|
version_requirements: !ruby/object:Gem::Requirement
|
225
237
|
requirements:
|
226
238
|
- - "~>"
|
227
239
|
- !ruby/object:Gem::Version
|
228
|
-
version: 0
|
240
|
+
version: '3.0'
|
229
241
|
- !ruby/object:Gem::Dependency
|
230
|
-
name: rubocop-
|
242
|
+
name: rubocop-performance
|
231
243
|
requirement: !ruby/object:Gem::Requirement
|
232
244
|
requirements:
|
233
245
|
- - "~>"
|
234
246
|
- !ruby/object:Gem::Version
|
235
|
-
version:
|
247
|
+
version: '1.13'
|
236
248
|
type: :development
|
237
249
|
prerelease: false
|
238
250
|
version_requirements: !ruby/object:Gem::Requirement
|
239
251
|
requirements:
|
240
252
|
- - "~>"
|
241
253
|
- !ruby/object:Gem::Version
|
242
|
-
version:
|
254
|
+
version: '1.13'
|
243
255
|
- !ruby/object:Gem::Dependency
|
244
|
-
name: rubocop-
|
256
|
+
name: rubocop-rake
|
245
257
|
requirement: !ruby/object:Gem::Requirement
|
246
258
|
requirements:
|
247
259
|
- - "~>"
|
248
260
|
- !ruby/object:Gem::Version
|
249
|
-
version:
|
261
|
+
version: 0.6.0
|
250
262
|
type: :development
|
251
263
|
prerelease: false
|
252
264
|
version_requirements: !ruby/object:Gem::Requirement
|
253
265
|
requirements:
|
254
266
|
- - "~>"
|
255
267
|
- !ruby/object:Gem::Version
|
256
|
-
version:
|
268
|
+
version: 0.6.0
|
257
269
|
- !ruby/object:Gem::Dependency
|
258
270
|
name: rubocop-rspec
|
259
271
|
requirement: !ruby/object:Gem::Requirement
|
260
272
|
requirements:
|
261
273
|
- - "~>"
|
262
274
|
- !ruby/object:Gem::Version
|
263
|
-
version:
|
275
|
+
version: '2.7'
|
264
276
|
type: :development
|
265
277
|
prerelease: false
|
266
278
|
version_requirements: !ruby/object:Gem::Requirement
|
267
279
|
requirements:
|
268
280
|
- - "~>"
|
269
281
|
- !ruby/object:Gem::Version
|
270
|
-
version:
|
282
|
+
version: '2.7'
|
271
283
|
- !ruby/object:Gem::Dependency
|
272
284
|
name: webmock
|
273
285
|
requirement: !ruby/object:Gem::Requirement
|
@@ -323,24 +335,22 @@ files:
|
|
323
335
|
- lib/alexandria.rb
|
324
336
|
- lib/alexandria/about.rb
|
325
337
|
- lib/alexandria/book_providers.rb
|
326
|
-
- lib/alexandria/book_providers/
|
327
|
-
- lib/alexandria/book_providers/amazon_aws.rb
|
328
|
-
- lib/alexandria/book_providers/amazon_ecs_util.rb
|
329
|
-
- lib/alexandria/book_providers/barnes_and_noble.rb
|
338
|
+
- lib/alexandria/book_providers/bl_provider.rb
|
330
339
|
- lib/alexandria/book_providers/douban.rb
|
331
|
-
- lib/alexandria/book_providers/
|
340
|
+
- lib/alexandria/book_providers/loc_provider.rb
|
332
341
|
- lib/alexandria/book_providers/pseudomarc.rb
|
333
|
-
- lib/alexandria/book_providers/
|
342
|
+
- lib/alexandria/book_providers/sbn_provider.rb
|
334
343
|
- lib/alexandria/book_providers/thalia_provider.rb
|
335
344
|
- lib/alexandria/book_providers/web.rb
|
336
345
|
- lib/alexandria/book_providers/worldcat.rb
|
337
|
-
- lib/alexandria/book_providers/
|
346
|
+
- lib/alexandria/book_providers/z3950_provider.rb
|
338
347
|
- lib/alexandria/config.rb
|
339
348
|
- lib/alexandria/console.rb
|
340
349
|
- lib/alexandria/default_preferences.rb
|
341
350
|
- lib/alexandria/execution_queue.rb
|
342
351
|
- lib/alexandria/export_format.rb
|
343
352
|
- lib/alexandria/export_library.rb
|
353
|
+
- lib/alexandria/image_fetcher.rb
|
344
354
|
- lib/alexandria/import_library.rb
|
345
355
|
- lib/alexandria/import_library_csv.rb
|
346
356
|
- lib/alexandria/library_collection.rb
|
@@ -555,6 +565,9 @@ files:
|
|
555
565
|
- share/sounds/alexandria/good_scan.wav
|
556
566
|
- share/sounds/alexandria/scanning.ogg
|
557
567
|
- share/sounds/alexandria/scanning.wav
|
568
|
+
- spec/alexandria/book_providers/bl_provider_spec.rb
|
569
|
+
- spec/alexandria/book_providers/loc_provider_spec.rb
|
570
|
+
- spec/alexandria/book_providers/sbn_provider_spec.rb
|
558
571
|
- spec/alexandria/book_providers/thalia_provider_spec.rb
|
559
572
|
- spec/alexandria/book_providers/world_cat_provider_spec.rb
|
560
573
|
- spec/alexandria/book_providers_spec.rb
|
@@ -619,8 +632,9 @@ files:
|
|
619
632
|
- util/rake/omfgenerate.rb
|
620
633
|
homepage: http://www.github.com/mvz/alexandria-book-collection-manager
|
621
634
|
licenses:
|
622
|
-
- GPL-2
|
623
|
-
metadata:
|
635
|
+
- GPL-2.0+
|
636
|
+
metadata:
|
637
|
+
rubygems_mfa_required: 'true'
|
624
638
|
post_install_message:
|
625
639
|
rdoc_options:
|
626
640
|
- "--main"
|
@@ -631,14 +645,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
631
645
|
requirements:
|
632
646
|
- - ">="
|
633
647
|
- !ruby/object:Gem::Version
|
634
|
-
version: 2.
|
648
|
+
version: 2.6.0
|
635
649
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
636
650
|
requirements:
|
637
651
|
- - ">="
|
638
652
|
- !ruby/object:Gem::Version
|
639
653
|
version: '0'
|
640
654
|
requirements: []
|
641
|
-
rubygems_version: 3.
|
655
|
+
rubygems_version: 3.3.3
|
642
656
|
signing_key:
|
643
657
|
specification_version: 4
|
644
658
|
summary: GNOME application for managing collections of books
|
@@ -1,191 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# This file is part of Alexandria.
|
4
|
-
#
|
5
|
-
# See the file README.md for authorship and licensing information.
|
6
|
-
|
7
|
-
# AdLibris Bokhandel AB http://www.adlibris.com/se/
|
8
|
-
# Swedish online book store
|
9
|
-
|
10
|
-
# New AdLibris provider, taken from the Palatina MetaDataSource and
|
11
|
-
# modified to fit the structure of Alexandria book providers.
|
12
|
-
# (26 Feb 2009)
|
13
|
-
|
14
|
-
require "cgi"
|
15
|
-
require "alexandria/book_providers/web"
|
16
|
-
|
17
|
-
module Alexandria
|
18
|
-
class BookProviders
|
19
|
-
class AdLibrisProvider < WebsiteBasedProvider
|
20
|
-
include Logging
|
21
|
-
|
22
|
-
SITE = "http://www.adlibris.com/se/"
|
23
|
-
|
24
|
-
BASE_SEARCH_URL = "#{SITE}searchresult.aspx?search=advanced&%s=%s" \
|
25
|
-
"&fromproduct=False" # type/term
|
26
|
-
|
27
|
-
PRODUCT_URL = "#{SITE}product.aspx?isbn=%s"
|
28
|
-
|
29
|
-
def initialize
|
30
|
-
super("AdLibris", "AdLibris (Sweden)")
|
31
|
-
prefs.read
|
32
|
-
# @ent = HTMLEntities.new
|
33
|
-
end
|
34
|
-
|
35
|
-
## search (copied from new WorldCat search)
|
36
|
-
def search(criterion, type)
|
37
|
-
req = create_search_uri(type, criterion)
|
38
|
-
log.info { "Fetching #{req} " }
|
39
|
-
html_data = transport.get_response(URI.parse(req))
|
40
|
-
|
41
|
-
if type == SEARCH_BY_ISBN
|
42
|
-
parse_result_data(html_data.body)
|
43
|
-
else
|
44
|
-
results = parse_search_result_data(html_data.body)
|
45
|
-
raise NoResultsError if results.empty?
|
46
|
-
|
47
|
-
results.map { |result| get_book_from_search_result(result) }
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
## url
|
52
|
-
def url(book)
|
53
|
-
create_search_uri(SEARCH_BY_ISBN, book.isbn)
|
54
|
-
rescue StandardError => ex
|
55
|
-
log.warn { "Cannot create url for book #{book}; #{ex.message}" }
|
56
|
-
nil
|
57
|
-
end
|
58
|
-
|
59
|
-
private
|
60
|
-
|
61
|
-
def create_search_uri(search_type, search_term)
|
62
|
-
if search_type == SEARCH_BY_ISBN
|
63
|
-
PRODUCT_URL % Library.canonicalise_isbn(search_term)
|
64
|
-
else
|
65
|
-
(search_type_code = {
|
66
|
-
SEARCH_BY_AUTHORS => "author",
|
67
|
-
SEARCH_BY_TITLE => "title",
|
68
|
-
SEARCH_BY_KEYWORD => "keyword"
|
69
|
-
}[search_type]) || "keyword"
|
70
|
-
search_term_encoded = CGI.escape(search_term)
|
71
|
-
format(BASE_SEARCH_URL, search_type_code, search_term_encoded)
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
# TODO: use Iconv to pre-convert the html.body to UTF-8 everywhere
|
76
|
-
# before sending it to the parser methods
|
77
|
-
|
78
|
-
def get_book_from_search_result(rslt)
|
79
|
-
html_data = transport.get_response(URI.parse(rslt[:lookup_url]))
|
80
|
-
parse_result_data(html_data.body)
|
81
|
-
end
|
82
|
-
|
83
|
-
def parse_search_result_data(html)
|
84
|
-
doc = html_to_doc(html)
|
85
|
-
book_search_results = []
|
86
|
-
|
87
|
-
search_hit = doc.search("div'searchResult")[0]
|
88
|
-
return [] unless search_hit
|
89
|
-
|
90
|
-
(search_hit / "ul.ulSearch table").each do |t|
|
91
|
-
result = {}
|
92
|
-
if (title_data = (t % "div.divTitle"))
|
93
|
-
result[:title] = (title_data % :a).inner_text
|
94
|
-
lookup_url = (title_data % :a)["href"]
|
95
|
-
end
|
96
|
-
result[:lookup_url] = "#{SITE}#{lookup_url}"
|
97
|
-
|
98
|
-
book_search_results << result
|
99
|
-
end
|
100
|
-
book_search_results
|
101
|
-
end
|
102
|
-
|
103
|
-
def normalize(text)
|
104
|
-
text
|
105
|
-
end
|
106
|
-
|
107
|
-
def parse_result_data(html)
|
108
|
-
doc = html_to_doc(html)
|
109
|
-
begin
|
110
|
-
h1 = doc.at("div.productTitleFormat h1")
|
111
|
-
raise NoResultsError, _("title not found on page") unless h1
|
112
|
-
|
113
|
-
title = text_of(h1)
|
114
|
-
|
115
|
-
product = doc.at("div.product")
|
116
|
-
ul_info = doc.at("ul.info") # NOTE, two of these
|
117
|
-
|
118
|
-
author_cells = ul_info.search("li.liAuthor") # css-like search
|
119
|
-
authors = []
|
120
|
-
author_cells.each do |li|
|
121
|
-
author_name = text_of(li.search("h2 > a")[0])
|
122
|
-
|
123
|
-
authors << author_name
|
124
|
-
end
|
125
|
-
|
126
|
-
publisher = nil
|
127
|
-
if (publisher_elem = product.search('li[@id$="liPublisher"] a').first)
|
128
|
-
publisher = text_of(publisher_elem)
|
129
|
-
end
|
130
|
-
|
131
|
-
binding = nil
|
132
|
-
if (format = doc.search("div.productTitleFormat span").first)
|
133
|
-
binding = text_of(format)
|
134
|
-
binding = Regexp.last_match[1] if binding =~ /\(([^)]+)\)/
|
135
|
-
end
|
136
|
-
|
137
|
-
year = nil
|
138
|
-
if (published = product.search('span[@id$="Published"]').first)
|
139
|
-
publication = published.inner_text
|
140
|
-
year = Regexp.last_match[1].to_i if publication =~ /([12][0-9]{3})/
|
141
|
-
end
|
142
|
-
|
143
|
-
isbns = []
|
144
|
-
isbn_tds = doc.search("li[@id *= 'liISBN'] td[text()]")
|
145
|
-
|
146
|
-
isbn_tds.each do |isbn_td|
|
147
|
-
isbn = isbn_td.inner_text
|
148
|
-
next unless isbn =~ /[0-9x]{10,13}/i
|
149
|
-
|
150
|
-
isbn.gsub(/(\n|\r)/, " ")
|
151
|
-
isbn = Regexp.last_match[1] if isbn =~ /:\s*([0-9x]+)/i
|
152
|
-
isbns << isbn
|
153
|
-
end
|
154
|
-
isbn = isbns.first
|
155
|
-
isbn = Library.canonicalise_isbn(isbn) if isbn
|
156
|
-
|
157
|
-
# cover
|
158
|
-
image_url = nil
|
159
|
-
cover_img =
|
160
|
-
doc.search('span.imageWithShadow img[@id$="ProductImageNotLinked"]').first
|
161
|
-
if cover_img
|
162
|
-
image_url = if cover_img["src"].start_with?("http://")
|
163
|
-
cover_img["src"]
|
164
|
-
else
|
165
|
-
"#{SITE}/#{cover_img['src']}" # HACK: use html base
|
166
|
-
end
|
167
|
-
if /noimage.gif$/.match?(image_url)
|
168
|
-
# no point downloading a "no image" graphic
|
169
|
-
# Alexandria has its own generic book icon...
|
170
|
-
image_url = nil
|
171
|
-
end
|
172
|
-
|
173
|
-
end
|
174
|
-
|
175
|
-
book = Book.new(title, authors, isbn, publisher, year, binding)
|
176
|
-
|
177
|
-
[book, image_url]
|
178
|
-
rescue StandardError => ex
|
179
|
-
raise ex if ex.instance_of? NoResultsError
|
180
|
-
|
181
|
-
trace = ex.backtrace.join("\n> ")
|
182
|
-
log.warn do
|
183
|
-
"Failed parsing search results for AdLibris " \
|
184
|
-
"#{ex.message} #{trace}"
|
185
|
-
end
|
186
|
-
raise NoResultsError
|
187
|
-
end
|
188
|
-
end
|
189
|
-
end
|
190
|
-
end
|
191
|
-
end
|