libraccio_extractor 1.0.0 copy "libraccio_extractor: ^1.0.0" to clipboard
libraccio_extractor: ^1.0.0 copied to clipboard

A Flutter library for extracting book data from libraccio.it

Libraccio Extractor #

A Flutter library for extracting book data from libraccio.it product pages.

This library parses the JSON-LD structured data embedded in libraccio.it book pages and provides a convenient Dart API to access book information including title, author, ISBN, description, cover image, price, and availability.

Pub License

Features #

  • Extracts book data from libraccio.it product pages
  • Parses JSON-LD structured data (schema.org Book/Product)
  • Provides Dart models for all book properties
  • Includes a widget for displaying book cover images
  • Handles network requests and HTML parsing
  • Automatic handling of ISBN-based lookups
  • Manages HTML redirects from libraccio.it

Installation #

Add this to your pubspec.yaml:

dependencies:
  libraccio_extractor: ^1.0.0

Then run:

flutter pub get

Usage #

Basic Usage #

import 'package:libraccio_extractor/libraccio_extractor.dart';

// Extract book data by ISBN
final book = await LibraccioParser.extractBookDataByIsbn('9788806266738');

if (book != null) {
  print('Title: ${book.name}');
  print('Author: ${book.author?.name}');
  print('Price: ${book.offers?.price} ${book.offers?.priceCurrency}');
}

Using the BookCoverWidget #

import 'package:libraccio_extractor/book_cover_widget.dart';

BookCoverWidget(
  imageUrl: book.image,
  width: 120,
  height: 160,
  fit: BoxFit.cover,
)

API Reference #

LibraccioParser #

The main class for extracting book data from libraccio.it.

Methods

extractBookData(String url) → Future<Book?>

Extracts book data from a libraccio.it product page URL.

  • url: The full URL of the libraccio.it product page
  • Returns: A Book object if successful, null otherwise
extractBookDataByIsbn(String isbn) → Future<Book?>

Extracts book data by ISBN from libraccio.it. This method automatically constructs the URL and handles redirects.

  • isbn: The ISBN of the book to look up
  • Returns: A Book object if successful, null otherwise
parseBookFromHtml(String htmlContent) → Book?

Parses book data from HTML content containing JSON-LD script tags.

  • htmlContent: The HTML content to parse
  • Returns: A Book object if successful, null otherwise

Book Model #

Represents a book with all its properties extracted from libraccio.it.

Properties

  • type: List of types (e.g., ["Book", "Product"])
  • context: JSON-LD context
  • name: Title of the book
  • isbn: ISBN of the book
  • description: Description of the book
  • image: URL of the book cover image
  • offers: Offer information (see Offer model)
  • author: Author information (see Author model)

Offer Model #

Represents the offer information for a book.

Properties

  • type: Type of the offer
  • context: JSON-LD context
  • availability: Availability status
  • price: Price of the book
  • priceCurrency: Currency of the price (e.g., "EUR")

Author Model #

Represents the author of a book.

Properties

  • type: Type of the author
  • context: JSON-LD context
  • name: Name of the author

BookCoverWidget #

A Flutter widget to display a book cover image with loading and error states.

Properties

  • imageUrl: URL of the book cover image
  • width: Width of the widget (default: 120)
  • height: Height of the widget (default: 160)
  • fit: How to fit the image (default: BoxFit.cover)

Example #

See the example directory for a complete Flutter app demonstrating the usage of this library.

License #

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing #

Contributions are welcome! Please feel free to submit a Pull Request.

Then run:

flutter pub get

Usage #

Import the library:

import 'package:libraccio_extractor/libraccio_extractor.dart';

Extract book data by ISBN (recommended approach):

final book = await LibraccioParser.extractBookDataByIsbn('9788806266738');

if (book != null) {
  print('Title: ${book.name}');
  print('Author: ${book.author?.name}');
  print('ISBN: ${book.isbn}');
  print('Price: €${book.offers?.price}');
  print('Availability: ${book.offers?.availability}');
}

Alternatively, extract book data from a libraccio.it URL:

final book = await LibraccioParser.extractBookData(
  'https://www.libraccio.it/libro/9788806266738/davide-longo/la-donna-della-mansarda.html',
);

Display a book cover image:

BookCoverWidget(
  imageUrl: book.image,
  width: 120,
  height: 160,
)

Parse book data from HTML content directly:

final book = LibraccioParser.parseBookFromHtml(htmlContent);

Data Models #

The library provides the following data models:

  • Book: Main book data including title, author, ISBN, description, etc.
  • Offer: Pricing and availability information
  • Author: Author information

Dependencies #

This library depends on:

  • http: For making network requests
  • html: For parsing HTML content
  • json_annotation: For JSON serialization
  • cached_network_image: For efficient image loading and caching

Example App #

See the example/ directory for a complete Flutter app demonstrating usage.

License #

MIT

0
likes
130
points
14
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter library for extracting book data from libraccio.it

Documentation

API reference

License

MIT (license)

Dependencies

cached_network_image, flutter, html, http, json_annotation

More

Packages that depend on libraccio_extractor