abigegg/lanark

Client for Glasgow Libraries data

0.1.5 2020-11-16 01:41 UTC

This package is auto-updated.

Last update: 2024-04-27 21:46:45 UTC


README

Lanark is a PHP library for pulling data from the Glasgow Libraries catalogue.

It uses headless Chrome to scrape the library's Arena website (https://libcat.csglasgow.org/) and provides a (very very) simple interface to work with it programmatically.

Requirements

Usage

Install with composer:

composer require abigegg/lanark

Get book by its ISBN

use ABigEgg\Lanark;

$client = new Lanark\Client();

// grab an item by its ISBN
$book = $client->getItemByISBN('9781787300521');

var_dump( $book );

// object(Lanark\Item)#21 (5) {
//     ["title"]=>
//     string(30) "Orwell on truth, George Orwell"
//     ["author"]=>
//     string(25) "Orwell, George, 1903-1950"
//     ["isbn"]=>
//     string(13) "9781787300521"
//     ["availability_count":protected]=>
//     NULL
//     ["year"]=>
//     string(4) "2017"
//   }

Search for books using keywords

use ABigEgg\Lanark;

$client = new Lanark\Client();

// search for some items by keyword
$books = $client->search('hitchhikers guide');

var_dump( $books );

// array(10) {
//     [0]=>
//         object(ABigEgg\Lanark\Item)#148 (6) {
//         ["title"]=>
//         string(51) "The hitchhiker's guide to the Galaxy, Douglas Adams"
//         ["author"]=>
//         string(26) "Adams, Douglas, 1952-2001,"
//         ["isbn"]=>
//         string(13) "9781509808311"
//         ["availability_count":protected]=>
//         NULL
//         ["year"]=>
//         string(4) "2016"
//         ["item_page_url"]=>
//         NULL
//         }
//     [1]=>
//         object(ABigEgg\Lanark\Item)#247 (6) {
//         ["title"]=>
//         string(52) "The hitch-hiker's guide to the Bible, Colin Sinclair"
//         ["author"]=>
//         string(15) "Sinclair, Colin"
//         ["isbn"]=>
//         string(13) "9781854248541"
//         ["availability_count":protected]=>
//         NULL
//         ["year"]=>
//         string(4) "2008"
//         ["item_page_url"]=>
//         NULL
//     }
// }
// ...

Check if a book is available to borrow (and how many copies)

use ABigEgg\Lanark;

$client = new Lanark\Client();

$book = $client->getItemByISBN("9781787300521");

var_dump( $book->getAvailability() );

// int(2)

Changelog

[0.1.5] 16 Nov 2020

  • Add keyword search with $client->search( 'Keywords' )
  • Pull in availability information just-in-time, to avoid unnecessary requests
  • Refactoring

[0.1.4] 15 Nov 2020

  • Replace Goutte with Chrome driver, now book availability information works!

[0.1.0] 14 Nov 2020

  • Initial commit

Planned features

  • Search
    • Search by book title and author (keywords)
    • Search by book year of publication
    • Search by book genre
  • Books
    • Show if book currently available for loan, and from which libraries
    • Get summary and thumbnail from Google Books, if available
    • (If authenticated) reserve a book to borrow it
  • Borrowing
    • Authenticate with Glasgow Libraries user ID and PIN
    • Get a list of your current reservations, and when they are due back

License

Licensed under the The MIT License