alexandria-book-collection-manager 0.7.1 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +0 -1
- data/.rubocop.yml +45 -27
- data/.rubocop_todo.yml +127 -86
- data/.simplecov +1 -0
- data/.yardopts +1 -1
- data/CHANGELOG.md +5 -0
- data/ChangeLog.0 +33 -35
- data/Gemfile +2 -2
- data/INSTALL.md +152 -0
- data/Rakefile +12 -10
- data/alexandria-book-collection-manager.gemspec +5 -5
- data/bin/alexandria +2 -1
- data/doc/AUTHORS +61 -0
- data/doc/BUGS +31 -0
- data/doc/FAQ +369 -0
- data/doc/HACKING +19 -0
- data/doc/NEWS +341 -0
- data/doc/alexandria.1 +120 -0
- data/doc/cuecat_support.rdoc +67 -0
- data/doc/dependency_decisions.yml +61 -0
- data/lib/alexandria.rb +2 -0
- data/lib/alexandria/about.rb +7 -6
- data/lib/alexandria/book_providers.rb +6 -6
- data/lib/alexandria/book_providers/adlibris.rb +9 -14
- data/lib/alexandria/book_providers/amazon_aws.rb +29 -33
- data/lib/alexandria/book_providers/amazon_ecs_util.rb +10 -14
- data/lib/alexandria/book_providers/barnes_and_noble.rb +9 -11
- data/lib/alexandria/book_providers/deastore.rb +12 -20
- data/lib/alexandria/book_providers/douban.rb +9 -15
- data/lib/alexandria/book_providers/mcu.rb +26 -13
- data/lib/alexandria/book_providers/proxis.rb +9 -15
- data/lib/alexandria/book_providers/pseudomarc.rb +15 -27
- data/lib/alexandria/book_providers/renaud.rb +18 -9
- data/lib/alexandria/book_providers/siciliano.rb +8 -9
- data/lib/alexandria/book_providers/thalia.rb +6 -6
- data/lib/alexandria/book_providers/web.rb +2 -0
- data/lib/alexandria/book_providers/worldcat.rb +6 -7
- data/lib/alexandria/book_providers/z3950.rb +19 -10
- data/lib/alexandria/config.rb +4 -2
- data/lib/alexandria/console.rb +2 -0
- data/lib/alexandria/execution_queue.rb +2 -2
- data/lib/alexandria/export_library.rb +14 -18
- data/lib/alexandria/import_library.rb +8 -16
- data/lib/alexandria/import_library_csv.rb +5 -52
- data/lib/alexandria/logging.rb +4 -6
- data/lib/alexandria/models/book.rb +2 -0
- data/lib/alexandria/models/library.rb +10 -20
- data/lib/alexandria/net.rb +2 -0
- data/lib/alexandria/preferences.rb +10 -14
- data/lib/alexandria/scanners.rb +2 -0
- data/lib/alexandria/scanners/cuecat.rb +4 -2
- data/lib/alexandria/scanners/keyboard.rb +2 -0
- data/lib/alexandria/smart_library.rb +4 -3
- data/lib/alexandria/ui.rb +2 -0
- data/lib/alexandria/ui/builder_base.rb +2 -0
- data/lib/alexandria/ui/callbacks.rb +8 -12
- data/lib/alexandria/ui/columns.rb +2 -0
- data/lib/alexandria/ui/completion_models.rb +2 -0
- data/lib/alexandria/ui/dialogs/about_dialog.rb +3 -1
- data/lib/alexandria/ui/dialogs/acquire_dialog.rb +11 -17
- data/lib/alexandria/ui/dialogs/alert_dialog.rb +2 -0
- data/lib/alexandria/ui/dialogs/bad_isbns_dialog.rb +10 -2
- data/lib/alexandria/ui/dialogs/barcode_animation.rb +2 -0
- data/lib/alexandria/ui/dialogs/book_properties_dialog.rb +5 -9
- data/lib/alexandria/ui/dialogs/book_properties_dialog_base.rb +3 -3
- data/lib/alexandria/ui/dialogs/export_dialog.rb +3 -3
- data/lib/alexandria/ui/dialogs/import_dialog.rb +2 -2
- data/lib/alexandria/ui/dialogs/misc_dialogs.rb +6 -4
- data/lib/alexandria/ui/dialogs/new_book_dialog.rb +22 -31
- data/lib/alexandria/ui/dialogs/new_book_dialog_manual.rb +3 -3
- data/lib/alexandria/ui/dialogs/new_smart_library_dialog.rb +3 -3
- data/lib/alexandria/ui/dialogs/preferences_dialog.rb +8 -18
- data/lib/alexandria/ui/dialogs/smart_library_properties_dialog.rb +2 -0
- data/lib/alexandria/ui/dialogs/smart_library_properties_dialog_base.rb +4 -6
- data/lib/alexandria/ui/dndable.rb +4 -2
- data/lib/alexandria/ui/icons.rb +3 -3
- data/lib/alexandria/ui/iconview.rb +3 -3
- data/lib/alexandria/ui/iconview_tooltips.rb +4 -6
- data/lib/alexandria/ui/init.rb +2 -0
- data/lib/alexandria/ui/libraries_combo.rb +2 -0
- data/lib/alexandria/ui/listview.rb +15 -12
- data/lib/alexandria/ui/main_app.rb +2 -0
- data/lib/alexandria/ui/multi_drag_treeview.rb +2 -0
- data/lib/alexandria/ui/sidepane.rb +8 -6
- data/lib/alexandria/ui/sound.rb +2 -0
- data/lib/alexandria/ui/ui_manager.rb +37 -43
- data/lib/alexandria/undo_manager.rb +2 -0
- data/lib/alexandria/version.rb +5 -3
- data/lib/alexandria/web_themes.rb +2 -0
- data/spec/alexandria/book_providers_spec.rb +12 -49
- data/spec/alexandria/book_spec.rb +4 -2
- data/spec/alexandria/library_spec.rb +2 -0
- data/spec/alexandria/preferences_spec.rb +2 -0
- data/spec/alexandria/scanners/cuecat_spec.rb +2 -0
- data/spec/alexandria/smart_library_spec.rb +3 -1
- data/spec/alexandria/ui/dialogs_spec.rb +2 -0
- data/spec/alexandria/ui/iconview_spec.rb +2 -0
- data/spec/alexandria/ui/main_app_spec.rb +2 -0
- data/spec/alexandria/ui/sidepane_spec.rb +2 -0
- data/spec/alexandria/ui/sound_spec.rb +2 -0
- data/spec/alexandria/ui/ui_manager_spec.rb +2 -0
- data/spec/alexandria/ui/ui_utilities_spec.rb +2 -0
- data/spec/alexandria/utilities_spec.rb +2 -0
- data/spec/spec_helper.rb +2 -0
- data/tasks/dogtail.rake +2 -0
- data/tasks/setup.rb +3 -1
- data/tasks/spec.rake +2 -0
- data/util/rake/fileinstall.rb +6 -12
- data/util/rake/gettextgenerate.rb +9 -64
- data/util/rake/omfgenerate.rb +3 -3
- metadata +21 -37
- data/INSTALL.rdoc +0 -148
- data/lib/alexandria/book_providers/bol_it.rb +0 -160
- data/lib/alexandria/book_providers/ibs_it.rb +0 -147
- data/lib/alexandria/book_providers/webster_it.rb +0 -167
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.2
|
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: 2018-03-18 00:00:00.000000000 Z
|
32
32
|
dependencies:
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: gettext
|
@@ -45,75 +45,61 @@ dependencies:
|
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '3.1'
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
48
|
+
name: gstreamer
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
|
-
- -
|
51
|
+
- - '='
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version:
|
53
|
+
version: 3.2.1
|
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:
|
61
|
-
- !ruby/object:Gem::Dependency
|
62
|
-
name: htmlentities
|
63
|
-
requirement: !ruby/object:Gem::Requirement
|
64
|
-
requirements:
|
65
|
-
- - "~>"
|
66
|
-
- !ruby/object:Gem::Version
|
67
|
-
version: '4.3'
|
68
|
-
type: :runtime
|
69
|
-
prerelease: false
|
70
|
-
version_requirements: !ruby/object:Gem::Requirement
|
71
|
-
requirements:
|
72
|
-
- - "~>"
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
version: '4.3'
|
60
|
+
version: 3.2.1
|
75
61
|
- !ruby/object:Gem::Dependency
|
76
62
|
name: gtk3
|
77
63
|
requirement: !ruby/object:Gem::Requirement
|
78
64
|
requirements:
|
79
|
-
- -
|
65
|
+
- - '='
|
80
66
|
- !ruby/object:Gem::Version
|
81
|
-
version: 3.1
|
67
|
+
version: 3.2.1
|
82
68
|
type: :runtime
|
83
69
|
prerelease: false
|
84
70
|
version_requirements: !ruby/object:Gem::Requirement
|
85
71
|
requirements:
|
86
|
-
- -
|
72
|
+
- - '='
|
87
73
|
- !ruby/object:Gem::Version
|
88
|
-
version: 3.1
|
74
|
+
version: 3.2.1
|
89
75
|
- !ruby/object:Gem::Dependency
|
90
|
-
name:
|
76
|
+
name: hpricot
|
91
77
|
requirement: !ruby/object:Gem::Requirement
|
92
78
|
requirements:
|
93
79
|
- - "~>"
|
94
80
|
- !ruby/object:Gem::Version
|
95
|
-
version:
|
81
|
+
version: 0.8.5
|
96
82
|
type: :runtime
|
97
83
|
prerelease: false
|
98
84
|
version_requirements: !ruby/object:Gem::Requirement
|
99
85
|
requirements:
|
100
86
|
- - "~>"
|
101
87
|
- !ruby/object:Gem::Version
|
102
|
-
version:
|
88
|
+
version: 0.8.5
|
103
89
|
- !ruby/object:Gem::Dependency
|
104
|
-
name:
|
90
|
+
name: htmlentities
|
105
91
|
requirement: !ruby/object:Gem::Requirement
|
106
92
|
requirements:
|
107
93
|
- - "~>"
|
108
94
|
- !ruby/object:Gem::Version
|
109
|
-
version: '3
|
95
|
+
version: '4.3'
|
110
96
|
type: :runtime
|
111
97
|
prerelease: false
|
112
98
|
version_requirements: !ruby/object:Gem::Requirement
|
113
99
|
requirements:
|
114
100
|
- - "~>"
|
115
101
|
- !ruby/object:Gem::Version
|
116
|
-
version: '3
|
102
|
+
version: '4.3'
|
117
103
|
- !ruby/object:Gem::Dependency
|
118
104
|
name: image_size
|
119
105
|
requirement: !ruby/object:Gem::Requirement
|
@@ -216,7 +202,7 @@ files:
|
|
216
202
|
- COPYING
|
217
203
|
- ChangeLog.0
|
218
204
|
- Gemfile
|
219
|
-
- INSTALL.
|
205
|
+
- INSTALL.md
|
220
206
|
- PACKAGING
|
221
207
|
- README.md
|
222
208
|
- RELEASE_CHECKLIST
|
@@ -232,6 +218,7 @@ files:
|
|
232
218
|
- doc/NEWS
|
233
219
|
- doc/alexandria.1
|
234
220
|
- doc/cuecat_support.rdoc
|
221
|
+
- doc/dependency_decisions.yml
|
235
222
|
- dogtail/basic_run_test.py
|
236
223
|
- lib/alexandria.rb
|
237
224
|
- lib/alexandria/about.rb
|
@@ -240,10 +227,8 @@ files:
|
|
240
227
|
- lib/alexandria/book_providers/amazon_aws.rb
|
241
228
|
- lib/alexandria/book_providers/amazon_ecs_util.rb
|
242
229
|
- lib/alexandria/book_providers/barnes_and_noble.rb
|
243
|
-
- lib/alexandria/book_providers/bol_it.rb
|
244
230
|
- lib/alexandria/book_providers/deastore.rb
|
245
231
|
- lib/alexandria/book_providers/douban.rb
|
246
|
-
- lib/alexandria/book_providers/ibs_it.rb
|
247
232
|
- lib/alexandria/book_providers/mcu.rb
|
248
233
|
- lib/alexandria/book_providers/proxis.rb
|
249
234
|
- lib/alexandria/book_providers/pseudomarc.rb
|
@@ -251,7 +236,6 @@ files:
|
|
251
236
|
- lib/alexandria/book_providers/siciliano.rb
|
252
237
|
- lib/alexandria/book_providers/thalia.rb
|
253
238
|
- lib/alexandria/book_providers/web.rb
|
254
|
-
- lib/alexandria/book_providers/webster_it.rb
|
255
239
|
- lib/alexandria/book_providers/worldcat.rb
|
256
240
|
- lib/alexandria/book_providers/z3950.rb
|
257
241
|
- lib/alexandria/config.rb
|
@@ -511,7 +495,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
511
495
|
requirements:
|
512
496
|
- - ">="
|
513
497
|
- !ruby/object:Gem::Version
|
514
|
-
version:
|
498
|
+
version: 2.3.0
|
515
499
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
516
500
|
requirements:
|
517
501
|
- - ">="
|
@@ -519,7 +503,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
519
503
|
version: '0'
|
520
504
|
requirements: []
|
521
505
|
rubyforge_project:
|
522
|
-
rubygems_version: 2.6
|
506
|
+
rubygems_version: 2.7.6
|
523
507
|
signing_key:
|
524
508
|
specification_version: 4
|
525
509
|
summary: GNOME application for managing collections of books
|
data/INSTALL.rdoc
DELETED
@@ -1,148 +0,0 @@
|
|
1
|
-
= Installing Alexandria
|
2
|
-
|
3
|
-
Alexandria is written in Ruby with a GTK+2/GNOME user-interface. It
|
4
|
-
currently only runs on UNIX-style systems, such as GNU/Linux.
|
5
|
-
|
6
|
-
Alexandria is not an easy project to build from scratch. Apart from
|
7
|
-
Ruby and GNOME, it has a lot of dependencies; however, many of these
|
8
|
-
are now optional as detailed below. Once the dependencies have been
|
9
|
-
installed, building and installing Alexandria is relatively
|
10
|
-
straightforward.
|
11
|
-
|
12
|
-
[Also note that there are pre-built packages for some distros, such as
|
13
|
-
Fedora and Ubuntu.]
|
14
|
-
|
15
|
-
== Dependencies
|
16
|
-
|
17
|
-
The {Ruby-GNOME2}[http://ruby-gnome2.sourceforge.jp/] user-interface
|
18
|
-
involves a number of packages:
|
19
|
-
|
20
|
-
* <tt>ruby-gtk2</tt>
|
21
|
-
* <tt>ruby-goocanvas</tt>
|
22
|
-
* <tt>ruby-gst</tt>
|
23
|
-
* <tt>ruby-pango</tt>
|
24
|
-
|
25
|
-
You should have GTK+ >= 2.22.0, and use Ruby-GNOME2 >= 0.16.0.
|
26
|
-
|
27
|
-
<tt>ruby-gettext</tt>[http://ponx.s5.xrea.com/hiki/ruby-gettext.html]
|
28
|
-
is required for the internationalisation of the user interface.
|
29
|
-
Requires version 1.7.0 or higher.
|
30
|
-
|
31
|
-
=== Hpricot
|
32
|
-
|
33
|
-
Alexandria uses +hpricot+[http://code.whytheluckystiff.net/hpricot] to
|
34
|
-
parse the HTML from web pages for providers such as DeaStore and
|
35
|
-
Siciliano. It is also used to parse the XML for the Amazon web
|
36
|
-
service. You can install the +hpricot+ package natively or as a
|
37
|
-
ruby gem.
|
38
|
-
|
39
|
-
== HTMLEntities
|
40
|
-
|
41
|
-
This is used by all website-based providers except MCU.
|
42
|
-
+htmlentities+[http://htmlentities.rubyforge.org/] is used to
|
43
|
-
provide more flexible HTML parsing.
|
44
|
-
|
45
|
-
== Build Dependencies
|
46
|
-
|
47
|
-
=== Ruby Dependencies
|
48
|
-
|
49
|
-
+rake+[http://rake.rubyforge.org] is required to build Alexandria from
|
50
|
-
the project +Rakefile+.
|
51
|
-
|
52
|
-
You also need +rubygems+[http://www.rubygems.org/] and
|
53
|
-
+rspec+[http://rspec.rubyforge.org/] to run the RSpec test suite.
|
54
|
-
|
55
|
-
=== Native Dependencies
|
56
|
-
|
57
|
-
The +gettext+[http://www.gnu.org/software/gettext] package is needed
|
58
|
-
to generate the binary +mo+ files used by <tt>ruby-gettext</tt> at
|
59
|
-
runtime. You also need the
|
60
|
-
+intltool+[http://www.freedesktop.org/wiki/Software/intltool] package
|
61
|
-
to merge translations into generated files (and to extract
|
62
|
-
translatable string from xml files during development).
|
63
|
-
|
64
|
-
Note that these files are pre-generated in tar.gz releases, so you'll
|
65
|
-
only need them if you're building from the SVN version, or want to
|
66
|
-
change the translations.
|
67
|
-
|
68
|
-
=== Ruby/ZOOM and Yaz
|
69
|
-
|
70
|
-
For Z39.50 support and and the <b>Library of Congress</b> and
|
71
|
-
<b>British Library</b> book providers you will need
|
72
|
-
<tt>ruby-zoom</tt>[http://ruby-zoom.rubyforge.org], which in turn
|
73
|
-
requires the non-Ruby package +yaz+[http://www.indexdata.dk/yaz].
|
74
|
-
|
75
|
-
Note that if you install the recent Ruby/ZOOM as the +zoom+ gem, you
|
76
|
-
will also need to install the +marc+ gem. (Older implementations of
|
77
|
-
ruby-zoom contained their own implementation of MARC.)
|
78
|
-
|
79
|
-
The Z39.50 Object-Orientation Model (ZOOM) is an international
|
80
|
-
standard for communication between computer systems, particularly
|
81
|
-
libraries and information-related systems.
|
82
|
-
|
83
|
-
=== image_size
|
84
|
-
|
85
|
-
You will need
|
86
|
-
<tt>image_size</tt>[http://rubyforge.org/projects/imagesize/] for
|
87
|
-
optimizing the cover images in exported libraries.
|
88
|
-
|
89
|
-
== Build and Install
|
90
|
-
|
91
|
-
To build Alexandria from a subversion checkout, go to the base project
|
92
|
-
directory (where the Rakefile and this INSTALL file are located) and
|
93
|
-
issue the command
|
94
|
-
rake build
|
95
|
-
If you have downloaded a source package, this step will not usually be
|
96
|
-
necessary.
|
97
|
-
|
98
|
-
You must have root priveledges to install, so use +su+
|
99
|
-
su -c 'rake install'
|
100
|
-
or +sudo+
|
101
|
-
sudo rake install
|
102
|
-
|
103
|
-
Now you can check the version of the installed Alexandria
|
104
|
-
alexandria --version
|
105
|
-
|
106
|
-
To launch Alexandria, simply use
|
107
|
-
alexandria
|
108
|
-
|
109
|
-
If you wish to see more output on the console, you can use
|
110
|
-
alexandria --debug
|
111
|
-
|
112
|
-
=== Staged installation for making packages
|
113
|
-
|
114
|
-
When building a binary package (such as a deb or rpm) you will want to
|
115
|
-
"install" Alexandria into a specified directory instead of the root
|
116
|
-
filesystem. You should specify this as the DESTDIR environment variable
|
117
|
-
and use the +install_package_staging+ task instead of +install+
|
118
|
-
|
119
|
-
DESTDIR=debian/alexandria rake install_package_staging
|
120
|
-
|
121
|
-
If your distribution uses a specific directory to install Ruby
|
122
|
-
packages, you should also set the RUBYLIBDIR.
|
123
|
-
|
124
|
-
=== Installing in the home directory
|
125
|
-
|
126
|
-
If you want to install Alexandria in your home directory, you should
|
127
|
-
specify the PREFIX, SHARE and RUBYLIBDIR envrionment variables, and
|
128
|
-
use the +install_package+ task instead of +install+.
|
129
|
-
|
130
|
-
PREFIX=$HOME SHARE=$HOME/.share RUBYLIBDIR=$HOME/.rubylib rake install_package
|
131
|
-
|
132
|
-
This will install the +alexandria+ program into +$HOME/bin+ (which you
|
133
|
-
should add to your +PATH+), and the ruby files to your
|
134
|
-
+$HOME/.rubylib+ which you should add to your +RUBYLIBDIR+ environment
|
135
|
-
variable.
|
136
|
-
|
137
|
-
=== Uninstalling
|
138
|
-
|
139
|
-
To uninstall, simply run
|
140
|
-
|
141
|
-
sudo rake uninstall
|
142
|
-
|
143
|
-
(or +rake uninstall_package+ if you installed in your home directory).
|
144
|
-
|
145
|
-
If you specified any of the environment variables PREFIX, SHARE,
|
146
|
-
RUBYLIBDIR and DESTDIR during the installation, you should use the
|
147
|
-
same variables during uninstallation (or rake won't know where to look
|
148
|
-
for the files it has to remove).
|
@@ -1,160 +0,0 @@
|
|
1
|
-
# Copyright (C) 2007 Marco Costantini
|
2
|
-
# Copyright (C) 2014, 2016 Matijs van Zuijlen
|
3
|
-
# based on ibs_it.rb by Claudio Belotti
|
4
|
-
#
|
5
|
-
# Alexandria is free software; you can redistribute it and/or
|
6
|
-
# modify it under the terms of the GNU General Public License as
|
7
|
-
# published by the Free Software Foundation; either version 2 of the
|
8
|
-
# License, or (at your option) any later version.
|
9
|
-
#
|
10
|
-
# Alexandria is distributed in the hope that it will be useful,
|
11
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
-
# General Public License for more details.
|
14
|
-
#
|
15
|
-
# You should have received a copy of the GNU General Public
|
16
|
-
# License along with Alexandria; see the file COPYING. If not,
|
17
|
-
# write to the Free Software Foundation, Inc., 51 Franklin Street,
|
18
|
-
# Fifth Floor, Boston, MA 02110-1301 USA.
|
19
|
-
|
20
|
-
require 'fileutils'
|
21
|
-
require 'net/http'
|
22
|
-
require 'open-uri'
|
23
|
-
# require 'cgi'
|
24
|
-
|
25
|
-
module Alexandria
|
26
|
-
class BookProviders
|
27
|
-
class BOL_itProvider < GenericProvider
|
28
|
-
BASE_URI = 'http://www.bol.it'.freeze
|
29
|
-
CACHE_DIR = File.join(Alexandria::Library::DIR, '.bol_it_cache')
|
30
|
-
REFERER = BASE_URI
|
31
|
-
LOCALE = 'libri'.freeze # possible locales are: "libri", "inglesi", "video", "musica", "choco"
|
32
|
-
def initialize
|
33
|
-
super('BOL_it', 'BOL (Italy)')
|
34
|
-
FileUtils.mkdir_p(CACHE_DIR) unless File.exist?(CACHE_DIR)
|
35
|
-
# no preferences for the moment
|
36
|
-
at_exit { clean_cache }
|
37
|
-
end
|
38
|
-
|
39
|
-
def search(criterion, type)
|
40
|
-
criterion = criterion.encode('ISO-8859-1')
|
41
|
-
req = BASE_URI + '/' + LOCALE + '/'
|
42
|
-
req += case type
|
43
|
-
when SEARCH_BY_ISBN
|
44
|
-
'scheda/'
|
45
|
-
|
46
|
-
when SEARCH_BY_TITLE
|
47
|
-
'risultatoricerca?action=bolrisultatoricerca&skin=bol&filtro_ricerca=BOL&quick_type=Titolo&titolo='
|
48
|
-
|
49
|
-
when SEARCH_BY_AUTHORS
|
50
|
-
'risultatoricerca?action=bolrisultatoricerca&skin=bol&filtro_ricerca=BOL&quick_type=Autore&titolo='
|
51
|
-
|
52
|
-
when SEARCH_BY_KEYWORD
|
53
|
-
'risultatoricerca?action=bolrisultatoricerca&skin=bol&filtro_ricerca=BOL&quick_type=Parola%20chiave&titolo='
|
54
|
-
|
55
|
-
else
|
56
|
-
raise InvalidSearchTypeError
|
57
|
-
|
58
|
-
end
|
59
|
-
|
60
|
-
## warning: this provider uses pages like http://www.bol.it/libri/scheda/ea978888584104 with 12 numbers, without the checksum
|
61
|
-
criterion = 'ea' + Library.canonicalise_ean(criterion)[0..-2] + '.html' if type == SEARCH_BY_ISBN
|
62
|
-
req += CGI.escape(criterion)
|
63
|
-
p req if $DEBUG
|
64
|
-
data = transport.get(URI.parse(req))
|
65
|
-
if type == SEARCH_BY_ISBN
|
66
|
-
to_book(data) # rescue raise NoResultsError
|
67
|
-
else
|
68
|
-
begin
|
69
|
-
results = []
|
70
|
-
each_book_page(data) do |code, _title|
|
71
|
-
results << to_book(transport.get(URI.parse(BASE_URI + "/#{LOCALE}/scheda/ea" + code)))
|
72
|
-
end
|
73
|
-
return results
|
74
|
-
rescue
|
75
|
-
raise NoResultsError
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
def url(book)
|
81
|
-
BASE_URI + "/#{LOCALE}/scheda/ea" + Library.canonicalise_ean(book.isbn)[0..-2] + '.html'
|
82
|
-
end
|
83
|
-
|
84
|
-
private
|
85
|
-
|
86
|
-
def to_book(data)
|
87
|
-
raise NoResultsError if data =~ /Scheda libro non completa \(TP null\)/
|
88
|
-
data = data.encode('UTF-8')
|
89
|
-
|
90
|
-
md = /<INPUT type =hidden name ="mailTitolo" value="([^"]+)/.match(data)
|
91
|
-
raise 'No title' unless md
|
92
|
-
title = CGI.unescape(md[1].strip)
|
93
|
-
|
94
|
-
authors = []
|
95
|
-
if (md = /<INPUT type =HIDDEN name ="mailAutore" value="([^"]+)/.match(data))
|
96
|
-
md[1].strip.split(', ').each { |a| authors << CGI.unescape(a.strip) }
|
97
|
-
end
|
98
|
-
|
99
|
-
md = /<INPUT type =HIDDEN name ="mailEAN" value="([^"]+)/.match(data)
|
100
|
-
raise 'No ISBN' unless md
|
101
|
-
isbn = md[1].strip
|
102
|
-
isbn += String(Library.ean_checksum(Library.extract_numbers(isbn)))
|
103
|
-
|
104
|
-
# raise unless
|
105
|
-
md = /<INPUT type =HIDDEN name ="mailEditore" value="([^"]+)/.match(data)
|
106
|
-
(publisher = CGI.unescape(md[1].strip)) || md
|
107
|
-
|
108
|
-
# raise unless
|
109
|
-
md = /<INPUT type =HIDDEN name ="mailFormato" value="([^"]+)/.match(data)
|
110
|
-
(edition = CGI.unescape(md[1].strip)) || md
|
111
|
-
|
112
|
-
if (md = /#{edition}\ \;\|\ \;(\d+)\ \;\|\ \;/.match(data))
|
113
|
-
nr_pages = CGI.unescape(md[1].strip)
|
114
|
-
elsif (md = / (\d+) pagine \| /.match(data))
|
115
|
-
nr_pages = CGI.unescape(md[1].strip)
|
116
|
-
end
|
117
|
-
if (nr_pages != '0') && !nr_pages.nil?
|
118
|
-
edition = nr_pages + ' p., ' + edition
|
119
|
-
end
|
120
|
-
|
121
|
-
publish_year = nil
|
122
|
-
if (md = /<INPUT type =HIDDEN name ="mailAnnoPubbl" value="([^"]+)/.match(data))
|
123
|
-
publish_year = CGI.unescape(md[1].strip).to_i
|
124
|
-
publish_year = nil if publish_year.zero?
|
125
|
-
end
|
126
|
-
|
127
|
-
cover_url = BASE_URI + '/bol/includes/tornaImmagine.jsp?cdSoc=BL&ean=' + isbn[0..11] + '&tipoOggetto=PIB&cdSito=BL' # use "FRB" instead of "PIB" for smaller images
|
128
|
-
cover_filename = isbn + '.tmp'
|
129
|
-
Dir.chdir(CACHE_DIR) do
|
130
|
-
File.open(cover_filename, 'w') do |file|
|
131
|
-
file.write open(cover_url, 'Referer' => REFERER).read
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
medium_cover = CACHE_DIR + '/' + cover_filename
|
136
|
-
if File.size(medium_cover) > 43 && (File.size(medium_cover) != 2382) # 2382 is the size of the fake image "copertina non disponibile"
|
137
|
-
puts medium_cover + ' has non-0 size' if $DEBUG
|
138
|
-
return [Book.new(title, authors, isbn, publisher, publish_year, edition), medium_cover]
|
139
|
-
end
|
140
|
-
puts medium_cover + ' has 0 size, removing ...' if $DEBUG
|
141
|
-
File.delete(medium_cover)
|
142
|
-
[Book.new(title, authors, isbn, publisher, publish_year, edition)]
|
143
|
-
end
|
144
|
-
|
145
|
-
def each_book_page(data)
|
146
|
-
raise if data.scan(/<a href="\/#{LOCALE}\/scheda\/ea(\d+)\.html;jsessionid=[^"]+">\s*Scheda completa\s*<\/a>/) { |a| yield a }.empty?
|
147
|
-
end
|
148
|
-
|
149
|
-
def clean_cache
|
150
|
-
# FIXME: begin ... rescue ... end?
|
151
|
-
Dir.chdir(CACHE_DIR) do
|
152
|
-
Dir.glob('*.tmp') do |file|
|
153
|
-
puts 'removing ' + file if $DEBUG
|
154
|
-
File.delete(file)
|
155
|
-
end
|
156
|
-
end
|
157
|
-
end
|
158
|
-
end
|
159
|
-
end
|
160
|
-
end
|