{"id":16225755,"url":"https://github.com/macfja/bookretriever","last_synced_at":"2025-10-10T04:08:10.169Z","repository":{"id":43210467,"uuid":"250899843","full_name":"MacFJA/BookRetriever","owner":"MacFJA","description":"Library to retrieve data about books","archived":false,"fork":false,"pushed_at":"2022-03-13T15:09:09.000Z","size":309,"stargazers_count":3,"open_issues_count":7,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-28T00:37:31.694Z","etag":null,"topics":["abebooks","amazon-books","archive-org","book","books","composer-library","goodreads","google-books","isbn","isbndb","librarything","oclc","open-library","retrieve-data"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MacFJA.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-28T21:45:52.000Z","updated_at":"2024-11-19T10:13:09.000Z","dependencies_parsed_at":"2022-09-12T16:04:02.018Z","dependency_job_id":null,"html_url":"https://github.com/MacFJA/BookRetriever","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/MacFJA/BookRetriever","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MacFJA%2FBookRetriever","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MacFJA%2FBookRetriever/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MacFJA%2FBookRetriever/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MacFJA%2FBookRetriever/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MacFJA","download_url":"https://codeload.github.com/MacFJA/BookRetriever/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MacFJA%2FBookRetriever/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279002696,"owners_count":26083442,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["abebooks","amazon-books","archive-org","book","books","composer-library","goodreads","google-books","isbn","isbndb","librarything","oclc","open-library","retrieve-data"],"created_at":"2024-10-10T12:46:13.164Z","updated_at":"2025-10-10T04:08:10.141Z","avatar_url":"https://github.com/MacFJA.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Book Retriever\n\nLibrary to retrieve data about books\n\n## Installation\n\n```shell script\ncomposer require macfja/book-retriever\n```\n\n## Usage\n\n### Simple provider\n\nTo get information of a book on a specific provider:\n\n```php\n$htmlGetter = new \\MacFJA\\BookRetriever\\Helper\\HtmlGetter();\n$isbnTool = new \\Isbn\\Isbn();\n\n$antoineOnline = new \\MacFJA\\BookRetriever\\Provider\\AntoineOnline($htmlGetter, $isbnTool);\n$books = $antoineOnline-\u003esearchIsbn('9782253006329');\n// $books contains a list of \\MacFJA\\BookRetriever\\SearchResultInterface\n```\n\n### Configurable provider\n\nTo get information of a book with a configurable provider:\n\n```php\n$providerConfiguration = ...; // A class that implement \\MacFJA\\BookRetriever\\ProviderConfigurationInterface\n$configurator = new \\MacFJA\\BookRetriever\\ProviderConfigurator($providerConfiguration);\n$amazon = new \\MacFJA\\BookRetriever\\Provider\\Amazon();\n$configurator-\u003econfigure($amazon);\n$books = $amazon-\u003esearchIsbn('9782253006329');\n// $books contains a list of \\MacFJA\\BookRetriever\\SearchResultInterface\n```\n\n### Multiple providers\n\nUsing the `Pool` provider to request several providers:\n\n```php\n$providerConfiguration = ...; // A class that implement \\MacFJA\\BookRetriever\\ProviderConfigurationInterface\n$configurator = new \\MacFJA\\BookRetriever\\ProviderConfigurator($providerConfiguration);\n\n$htmlGetter = new \\MacFJA\\BookRetriever\\Helper\\HtmlGetter();\n$isbn = new \\Isbn\\Isbn();\n$opds = new \\MacFJA\\BookRetriever\\Helper\\OPDSParser();\n$sru = new \\MacFJA\\BookRetriever\\Helper\\SRUParser();\n\n$providers = [\n    new \\MacFJA\\BookRetriever\\Provider\\AbeBooks($htmlGetter),\n    new \\MacFJA\\BookRetriever\\Provider\\Amazon(),\n    new \\MacFJA\\BookRetriever\\Provider\\AntoineOnline($htmlGetter, $isbn),\n    new \\MacFJA\\BookRetriever\\Provider\\ArchiveOrg($opds),\n    new \\MacFJA\\BookRetriever\\Provider\\LibraryHub($sru),\n    new \\MacFJA\\BookRetriever\\Provider\\DigitEyes(),\n    new \\MacFJA\\BookRetriever\\Provider\\Ebay()\n];\narray_walk($providers, [$configurator, 'configure']);\n\n$pool = new \\MacFJA\\BookRetriever\\Pool($providers, $providerConfiguration);\n\n$books = $pool-\u003esearchIsbn('9782253006329');\n// $books contains a list of \\MacFJA\\BookRetriever\\SearchResultInterface\n```\n\nIf you use an dependency injection library, lots of code can be remove. (see below for a Symfony example)\n\n### With Symfony (and Doctrine)\n\nAn example of integration in Symfony with configuration stored in database with Doctrine as ORM.\n\n`config/services.yaml`\n```yaml\nservices:\n    _instanceof:\n        # services whose classes are instances of ProviderInterface will be tagged automatically\n        MacFJA\\BookRetriever\\ProviderInterface:\n            tags: ['app.provider']\n    MacFJA\\BookRetriever\\:\n        resource: '../vendor/macfja/book-retriever/lib/'\n    MacFJA\\BookRetriever\\Pool:\n        arguments:\n            $providers: !tagged_iterator app.provider\n    MacFJA\\BookRetriever\\ProviderConfigurationInterface: '@App\\Repository\\ProviderConfigurationRepository'\n```\n\n`src/Entity/ProviderConfiguration.php`\n```php\n\u003c?php\nnamespace App\\Entity;\nuse Doctrine\\ORM\\Mapping as ORM;\n/** @ORM\\Entity(repositoryClass=\"App\\Repository\\ProviderConfigurationRepository\") */\nclass ProviderConfiguration\n{\n    /**\n     * @ORM\\Id()\n     * @ORM\\GeneratedValue()\n     * @ORM\\Column(type=\"integer\")\n     */\n    private $id;\n    /** @ORM\\Column(type=\"string\", length=50) */\n    private $provider;\n    /** @ORM\\Column(type=\"boolean\") */\n    private $active;\n    /** @ORM\\Column(type=\"json\") */\n    private $parameters = [];\n\n    // All Getters/Setters\n    // Removed in this example for readability\n}\n```\n\n`src/Repository/ProviderConfigurationRepository.php`\n```php\n\u003c?php\nnamespace App\\Repository;\nuse App\\Entity\\ProviderConfiguration;\nuse Doctrine\\Bundle\\DoctrineBundle\\Repository\\ServiceEntityRepository;\nuse Doctrine\\Common\\Persistence\\ManagerRegistry;\nuse MacFJA\\BookRetriever\\ProviderConfigurationInterface;\nuse MacFJA\\BookRetriever\\ProviderInterface;\n\nclass ProviderConfigurationRepository extends ServiceEntityRepository implements ProviderConfigurationInterface\n{\n    public function __construct(ManagerRegistry $registry)\n    {\n        parent::__construct($registry, ProviderConfiguration::class);\n    }\n\n    public function getParameters(ProviderInterface $provider): array\n    {\n        $configuration = $this-\u003efindOneBy(['provider' =\u003e $provider-\u003egetCode()]);\n        \n        return $configuration !== null ? $configuration-\u003egetParameters() : [];\n    }\n\n    public function isActive(ProviderInterface $provider): bool\n    {\n        $configuration = $this-\u003efindOneBy(['provider' =\u003e $provider-\u003egetCode()]);\n        // not active by default\n        return $configuration !== null ? $configuration-\u003egetActive() : false;\n    }\n}\n```\n\n`src/Controller/SomeController.php`\n```php\n\u003c?php\nnamespace App\\Controller;\nuse MacFJA\\BookRetriever\\Pool;\nuse Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController;\nuse Symfony\\Component\\HttpFoundation\\JsonResponse;\nuse Symfony\\Component\\Routing\\Annotation\\Route;\n\nclass SomeController extends AbstractController\n{\n    /** @Route(\"/test\") */\n    public function index(Pool $pool)\n    {\n        return new JsonResponse($pool-\u003esearchIsbn('9782253006329'));\n    }\n}\n```\n\n## Providers\n\nThere are currently **20** built-in providers.\nYou can find [more details here](Providers.md).\n\n## Contributing\n\nYou can contribute to the library.\nTo do so, you have Github issues to:\n - ask your question\n - notify any change in the providers\n - suggest new provider\n - request any change (typo, bad code, etc.)\n - and much more...\n\nYou also have PR to:\n - add a new provider\n - suggest a correction\n - and much more... \n\n### Local installation\n\nFirst clone the project (either this repository, or your fork),\nnext run:\n```shell script\nmake install # Install project vendor\nmake all # Run QA tools + tests suites + generate docs\n```\n\n### Validate your code\n\nWhen you done writing your code run the following command check if the quality meet defined rule and to format it:\n```shell script\nmake analyze # Run QA tools + tests suites\n```\nIf you add unit tests you run the following to do the same on test suite code:\n```shell script\nmake analyze-tests # Run QA tools on tests suites\n```\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmacfja%2Fbookretriever","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmacfja%2Fbookretriever","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmacfja%2Fbookretriever/lists"}