/booky

Automate the creation of Book ad

Primary LanguageRustApache License 2.0Apache-2.0

Booky

Booky is an application to help publish ads for second-hand book. It enables taking multiple picture of the book(s). Specify the books state (brand new, worn out), add the weight (for shipping), then extract the ISBN from the barcode in the pictures to find the books metadata.
In the 'Enrichment' step, it query several websites to get the books metadata (title, authors, blurb, keywords and price).
Booky then automatically create a compelling ad with all the relevant information.

A bunch of books Use Booky to take picture of the book, and gather metadata Publish your book
abstract image of a book stack screenshot of Booky showing published book screenshot of ads created by Booky

Flowchart

Flowchart of the process of publishing a book with Booky

Enrichment

Booky will scrape various websites to find metadata like:

  • Title
  • Authors
  • Blurb. A book blurb is a short promotional description, whereas a synopsis summarizes the twists, turns, and conclusion of the story.
  • Keywords or genres
  • Market price

Example using Babelio as source

Input

let isbn = 9782266071529;

Output

BookMetaData {
  title: "Le nom de la bête",
  author: {
    surname: "Daniel",
    name: "Easterman",
  },
  blurb: "Janvier 1999. Peu à peu, les pays arabes ont sombré dans l'intégrisme. Les attentats terroristes se multiplient en Europe attisant la haine et le racisme. Au Caire, un coup d'état fomenté par les fondamentalistes permet à leur chef Al-Kourtoubi de s'installer au pouvoir et d'instaurer la terreur. Le réseau des agents secrets britanniques en Égypte ayant été anéanti, Michael Hunt est obligé de reprendre du service pour enquêter sur place. Aidé par son frère Paul, prêtre catholique et agent du Vatican, il apprend que le Pape doit se rendre à Jérusalem pour participer à une conférence œcuménique. Au courant de ce projet, le chef des fondamentalistes a prévu d'enlever le saint père.Dans ce récit efficace et à l'action soutenue, le héros lutte presque seul contre des groupes fanatiques puissants et sans grand espoir de réussir. Comme dans tous ses autres livres, Daniel Easterman, spécialiste de l'islam, part du constat que le Mal est puissant et il dénonce l'intolérance et les nationalismes qui engendrent violence et chaos.--Claude Mesplède<br>\t\t",
  key_words: [
    "roman", "fantastique", "policier historique", "romans policiers et polars", "thriller", "terreur", "action", "démocratie", "mystique", "islam", "intégrisme religieux", "catholicisme", "religion", "terrorisme", "extrémisme", "egypte", "médias", "thriller religieux", "littérature irlandaise", "irlande"
  ],
}

Sources

Source Metadata (in addition to title and authors) Notes
Babelio blurb, keyword No API available. No plan to build one.
Babelio seem to block the IP if it detect this bot is doing some scrapping
Decitre blurb, keywords in commentaries
GoodReads blurb, genres in english An API was available, but GoodRead does not create new developer key. See this
Google Books blurb, genres A real API is available to look up a book by ISBN
Some book can't be search by ISBN, even though a search by title can find them, and they display the right ISBN
ISBSearcher blurb, main category in english
Label Emmaus blurb, genres
OpenLibrary blurb are not translated Its is based on physical books, it is not really a book database
Chasse Aux Livre price only it is not possible to parse with Selenium
AbeBooks Seems to have good french blurb
Fnac blurb, second-hand price
Librarie Kleber blurb, price
JustBooks blurb (seldom), prices

GoogleBooks

GoogleBooks has some inconsistencies: https://www.googleapis.com/books/v1/volumes?q=isbn:9782744170812 says te publishedDate is 2004. But https://www.googleapis.com/books/v1/volumes/DQUFSQAACAAJ says the publishedDate is 2005.

In the first response, we don't have a publisher, in the second we have. In the first response, the title use a big C for "Cité", but in the second, it use a small 'c'

Contributing

Build the barcode detector binary

Clone the 3 OpenCV repo:

$ cd <open_cv>/
$ mkdir build
$ cd build/
build/ $ cmake -DOPENCV_EXTRA_MODULES_PATH=<opencv_contrib>/modules ..

You can test the barcode module with:

build/ $ make opencv_test_barcode
build/ $ OPENCV_TEST_DATA_PATH=<opencv_extra>/testdata/ bin/opencv_test_barcode

Install the rust/android toolchain

flutter_rust_bridge_template

Follow the instruction of flutter_rust_bridge_template. Here is an extract

To begin, ensure that you have a working installation of the following items:

echo "ANDROID_NDK=.." >> ~/.gradle/gradle.properties

super_native_extension

Follow this tutorial: https://pub.dev/packages/super_clipboard

Run the flutter application

On an android device

Connect your phone.
Use

flutter run --flavor nodrive

If you don't specify a flavor, flutter will output this error:

Exception: Gradle build failed to produce an .apk file. It's likely that this file was generated under /Users/pattobrien/dev/fine_designs/template/src/frontend/build, but the tool couldn't find it.

(See flutter/flutter#22856 for issue about this cryptic message and the use of default flavor)

On Linux

First connect your phone then mount its content on /media/phone.
You can mount your phone with adbfs-rootless

$ ./adbfs /media/phone/
$ ls /media/phone
... storage/ ... 

Then launch Booky with:

$ flutter run --flavor noDrive -d linux

Launching the test suite

OBS

Some test require to simulate a camera. Booky use OBS virtual camera to mock the real camera.

OBS home page: https://obsproject.com/

Setup of Virtual camera

OBS virtual camera need v4l2loopback module which may not be enabled.

If it is not enabled, you should see this log when launching OBS:

warning: v4l2loopback not installed, virtual camera disabled

And the button Start virutal camera will not appear.

To enable it, run

sudo modprobe v4l2loopback

and relaunch OBS.

Setup of android emulator

In the Android Virtual Device settings, select "webcam0" for both front and back camera

The android camera app will always rash, but Booky should work fine.

If in Booky the camera list is empty, stop OBS virtual cam, then execute:

echo "options v4l2loopback devices=1 video_nr=63 card_label='OBS Virtual Camera'    exclusive_caps=1" | sudo tee /etc/modprobe.d/v4l2loopback.conf
echo "v4l2loopback" | sudo tee /etc/modules-load.d/v4l2loopback.conf
sudo modprobe -r v4l2loopback
sudo modprobe v4l2loopback devices=63 video_nr=13 card_label='OBS Virtual Camera' exclusive_caps=1

then restart virtual cam and cold boot the emulator.

Importing scene

OBS does not provide a convenient way to create portable scene, because all scene contain absolute path to the sources. To be able to use relative path, Booky use OBS Scene Transporter.
Use this fork version of OBS scene transporter as it also bundle the scripts along all the other resources https://github.com/pixelshot91/obs-scene-transporter

License

Icon by Freepik
Illustrative image by Freepik