Catman...er::SRU(3pm)
π NAME π
Catmandu::Importer::SRU β the package that imports SRU data, and yes bestie, that's literally the whole personality π¦
It lives in the Perl world under manual section 3pm (User Contributed Perl Documentation), so if you were looking for it in man, that's where it's at. π
β¨ SYNOPSIS β¨
okay so here's the whole vibe, look:
use Catmandu::Importer::SRU;
my %attrs = (
base => 'http://www.unicat.be/sru',
query => '(isbn=0855275103 or isbn=3110035170 or isbn=9010017362 or isbn=9014026188)',
recordSchema => 'marcxml',
parser => 'marcxml'
);
my $importer = Catmandu::Importer::SRU->new(%attrs);
my $count = $importer->each(sub {
my $schema = $record->{recordSchema};
my $packing = $record->{recordPacking};
my $position = $record->{recordPosition};
my $data = $record->{recordData};
# ...
});
# Using Catmandu::Importer::SRU::Package::marcxml, included in this release
my $importer = Catmandu::Importer::SRU->new(
base => 'http://www.unicat.be/sru',
query => '(isbn=0855275103 or isbn=3110035170 or isbn=9010017362 or isbn=9014026188)',
recordSchema => 'marcxml' ,
parser => 'marcxml' ,
);
# Using a homemade parser
my $importer = Catmandu::Importer::SRU->new(
base => 'http://www.unicat.be/sru',
query => '(isbn=0855275103 or isbn=3110035170 or isbn=9010017362 or isbn=9014026188)',
recordSchema => 'marcxml' ,
parser => MyParser->new , # or parser => '+MyParser'
);
three whole ways to set it up, pick your fighter π
π DESCRIPTION π
This Catmandu::Importer imports records via SRU. that's it, that's the job, and it does it gorgeously β¨
SRU diagnostics are emitted as warnings β except for when parser is set to "meta". noted, so you're not out here confused when your terminal starts yelling at you π
π§ CONFIGURATION π§
every knob you can turn, in order, no skips, we don't do skips here π
baseβ the base URL of the SRU server. required, so like, don't forget it πqueryβ the CQL query. also required. both of these are non-negotiable bestie π«Άlimitβ how many records get fetched in one batch. defaults to10. this gets translated into the SRU request parameter"maximumRecords".
Records come in multiple batches of this size, or smaller. so if you set a limit, that's the ceiling per batch, not the total. iykyk β¨
totalβ the total number of records this importer may return.
Not set by default. so it's a free-for-all unless you cap it πΈ
recordSchemaβ set to"dc"by default πsortkeysβ optional sorting. optional!! no pressure πoperationβ set to"searchRetrieve"by default πversionβ set to1.1by default βuserAgentβ the HTTP user agent, set to"Mozilla/5.0"by default. yes, it's cosplaying as a browser, let it live π¦http_clientβ an instance ofHTTP::Tinyor a compatible class to fetch URLs with. bring your own, if you want π₯parserβ this one controls how records get parsed before importing. the options are:- An instance of a Perl package that implements a
parsesubroutine. peep the default valueCatmandu::Importer::SRU::Parserif you want an example π - The name of a Perl package that implements a
parsesubroutine. the name must be prepended with"+", or it gets prefixed withCatmandu::Importer::SRU::Parser::. for instance,"marcxml"will create aCatmandu::Importer::SRU::Parser::marcxml. that's the glow-up pipeline β¨ - A function reference that gets passed the unparsed record. roll your own, main character energy π
- An instance of a Perl package that implements a
π METHODS π
All methods of Catmandu::Importer and, by extension, Catmandu::Iterable are inherited. they're yours now, no cap π«Ά
On top of those, here's the extra:
π url
Return the current SRU request URL. useful for debugging β literally the "what am i even requesting rn" button, obsessed π
π₯ SEE ALSO π₯
Catmandu::ImporterCatmandu::Iterable- <http://www.loc.gov/standards/sru/>
okay and for the cute sign-off: this whole thing is documented as perl v5.38.2, dated 2021-09-02, and it's the Catmandu::Importer::SRU(3pm) page β so if you need to cite it, that's the receipt π§Ύπ now go fetch some records, bestie, you're gonna ate πβ¨
π¦ where this page comes from
- ubuntu noble: libcatmandu-sru-perl 0.43.0-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libcatmandu-sru-perl 0.43.0-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libcatmandu-sru-perl 0.43.0-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms