EBook:...::BISG(3pm)

πŸ“¦
version 0.5.4 Β· 3 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

EBook::Tools::BISG β€” bestie, this is the class that goes and grabs all the info off the Book Industry Study Group webpages for you. That's it, that's the whole job. πŸ‘‘

It lives in the User Contributed Perl Documentation, section 3pm, so you know it's a Perl module. πŸ’…


✨ SYNOPSIS ✨

Like, here's the vibe in code form:

use EBook::Tools::BISG;
my $bisg = EBook::Tools::BISG->new();
$bisg->download_bisac;
$bisg->save_bisac;
say $bisg->bisac('fic000000');
%bisac_codes = $bisg->bisac();

No cap, that's genuinely all it takes. 🫢


πŸŽ€ DEPENDENCIES πŸŽ€

Okay so it needs a little squad to function:

  • DBI β€” the main character of database access. Heads up though: this will also require a DBD of your choice. The default is to use a local SQLite store, which is lowkey the easiest path. πŸ—„οΈ
  • LWP β€” the web-fetching bestie.
  • Mojo::DOM β€” the one that actually parses the HTML so we can read it. ✨

🌸 CONSTRUCTOR 🌸

new(%args)

Baby's first call: instantiates a brand new Ebook::Tools::BISG object. πŸ¦‹

Arguments

  • baseurl β€” the base url of the bisg.org website or a mirror you wanna use instead.
  • dsn β€” the Perl::DBI Data Source Name. Defaults to a sqlite store named bisac.sqlite in the user config directory. πŸ’Ύ

πŸ’œ ACCESSOR METHODS πŸ’œ

bisac($code)

Hand it a code and it gives you back the name that matches said code (and yes, it's case-insensitive, we don't do capital-letter drama here πŸ’…). Hand it nothing and you get the whole hash of all BISAC codes and references, with the keys all in lowercase. Take your pick, bestie. 🎁

find($regexp)

Gives you a list of all the BISAC values (the names) where either the key or the value for that entry matches a case-insensitive regular expression. Obsessed with the flexibility, honestly.

And if you pass no argument at all, or you just pass '.', then the entire list gets returned to you. The whole thing. Go off. πŸ”₯


πŸ”₯ MODIFIER METHODS πŸ”₯

download_bisac()

Downloads the BISAC codes straight from the BISG website and converts them into a hash. Both the codes and the obsolete entries get lowercased and turned into the keys, and the values end up being the official names they map to. Chef's kiss. πŸ‘‘

load_bisac()

Loads the BISAC codes from the specified database into the hash. It's called automatically by new(), so you usually don't even have to think about it. ✨

⚠️ Okay but real talk: if the load fails, nothing will happen. Silently! 😭 So the only way to know is to check whether you've actually got a populated hash afterwards. Check your hash, bestie.

save_bisac()

Saves the BISAC codes sitting in your hash into the database. πŸŽ€

πŸ’€ Heads up: this will destroy any existing table named bisac_codes. Like, gone gone.

And it croaks on failure β€” it will absolutely tell you if something went wrong. Periodt. 🐸


And that's the whole page, babes. This masterpiece ships with perl v5.40.0 and was dated 2025-01-10. Eat your heart out, it's giving documentation. πŸ’–πŸŒˆβ­

πŸ“¦ where this page comes from