openlibrary icon indicating copy to clipboard operation
openlibrary copied to clipboard

Bot account request: import Portuguese books from Biblioteca Nacional de Portugal (CC0)

Open pagyn-app opened this issue 4 months ago • 5 comments

Hi @mekarpeles,

I'd like to request bot privileges (API usergroup access) for a new account to import Portuguese-language books into Open Library.

Bot account: [pagyn_bot] (https://openlibrary.org/people/pagyn_bot)

Source: Biblioteca Nacional de Portugal (BNP) open data — "Bibliografia Nacional Portuguesa" dataset, covering monographs published in Portugal since 2002, ISBN included. License: CC0 (public domain). Source: https://opendata.bnportugal.gov.pt/downloads.htm

Why: Open Library's coverage of Portuguese-language books is thin. This is a national library catalog, freely licensed, that directly addresses recent/missing books that users are searching for.

Method: I'll transform the CC0 dataset into the Open Library import schema (title, authors, publishers, publish_date, source_records, isbn, languages: por) and submit via the batch import endpoint (/import/batch/new), following the process described in the Writing Bots docs. Source files and script will be committed to openlibrary-bots per the guidelines, and I will not run bulk modifications until the script has been reviewed.

Happy to start with a small sample batch first for review before any larger import. Thanks!

pagyn-app avatar Jul 28 '26 22:07 pagyn-app

I think it's great that you're willing to do this, but, in my opinion, OpenLibrary should own importing catalog records from national libraries. They are an excellent source of high quality, diverse metadata which have been created by professional librarians. This would help counteract the dramatic reduction of data quality caused by importing bookseller data, especially from BWB and 3rd party Amazon used book sellers.

tfmorris avatar Jul 29 '26 18:07 tfmorris

@pagyn-app Thanks for the message and pointing the the BNP data. As @tfmorris points out, this open MARC data is a perfect candidate for the existing bulk-MARC ingestion process.

I've created a ol_data item for the raw MARC records and am in the process of converting them to the exact MARC format the current OL importer expects, it's a little more fiddly than I first expected since BNP is using UNIMARC, but it's progressing.

I can post an example import to confirm we are getting all the exisiting data import process that we'd expect.

hornc avatar Jul 31 '26 03:07 hornc

Thank you @pagyn-app for submitting this issue!

Issue Assessment

Open questions

  • @hornc's comment (2026-07-31) indicates OL is already converting this same BNP dataset for the existing bulk-MARC ingestion pipeline, and @tfmorris's comment argues OL should own national-library imports directly rather than granting external bot accounts. Given that, is a separate pagyn_bot API-usergroup grant still needed, or does this request get superseded by the internal import once it lands?
  • If the bot account is still wanted (e.g., as a stopgap or for a different subset of the data), what is the intended long-term ownership of the pagyn_bot account and its import script — will it be retired once the internal bulk-MARC path covers BNP, or run in parallel?
  • Has a decision been made on /import/batch/new vs bulk-MARC-binary ingestion for this specific source, or is that still open pending @hornc's UNIMARC conversion work?

Action items

  • [ ] Staff decision needed: confirm with @hornc whether the in-progress bulk-MARC conversion of BNP data makes the bot-account request unnecessary, or whether both approaches should proceed.

Context (research findings)

  • Open Library has three existing import entry points that this proposal would need to go through one of: POST /api/import, POST /api/import/ia, and POST /import/batch/new (the endpoint mentioned in the issue body) — see docs/ai/imports/index.md.
  • The bulk-MARC path (?bulk_marc=true) that @hornc references as already in progress is documented as "the primary path for IA scanning partners... and the main source of usable records" — docs/ai/imports/api.md#L34-L36.
  • OL's MARC parsers (MarcBinary — marc_binary.py#L80, MarcXml — marc_xml.py#L65, and read_edition() — parse.py#L672) are built around MARC21 semantics. BNP publishes UNIMARC, a related but distinct standard — this is consistent with @hornc's comment that the conversion is "more fiddly than I first expected."
  • If this proceeds as a community-run source adapter rather than an internal import, the documented pattern is a sources/<slug>/ adapter in the openlibrary-bots repo (record + provider classes) — docs/ai/imports/adding-sources.md#L5-L34.
  • Related open "Bot Account Application" issues currently awaiting the same kind of decision: #13191 (pillarsdotnetBot339), #12887 (AgenticCommonsBot), and #13136 (AgenticCommonsBot scope extension) — all labeled Lead: @mekarpeles + Needs: Response, same category of request.
  • Prior precedent for a lighter-weight community batch-import path: #9726 ("Community Batch Import Request: arabooks"), labeled Type: Question + Good First Issue.
  • No duplicate or prior attempt at this specific BNP/Portuguese-language import was found in issue or PR search.

🔔 Stakeholders

@hornc — already active in this thread and the codebase owner for MARC/imports; flagging so the staff-decision question above reaches them directly alongside the Lead.


Full triage checklist
  • [x] Triage — correct labels applied (Affects: Data, Needs: Staff Decision added; Module: Import, Priority: 2, Lead: @mekarpeles already correctly set by staff)
  • [x] Problem / opportunity — clear: thin Portuguese-language coverage, audience is PT-language readers/searchers, source is a freely-licensed national library catalog
  • [x] Scope — well-scoped to a single dataset/source and a specific access grant
  • [x] Justification — reasoning given (CC0 national library data, addresses a known coverage gap); impact not quantified but reasonable for this issue type
  • [ ] Success & testing criteria — author offers a "small sample batch first for review" but no explicit review/acceptance criteria are defined
  • [x] Proposal & breakdown — concrete: schema mapping (title/authors/publishers/publish_date/source_records/isbn/languages), target endpoint, and repo/review process are all specified
  • [x] If bug: environment & repro steps — not applicable, this is not a bug report
  • [x] Risks, concerns, open questions — surfaced by both prior commenters (data-quality ownership, national-library data governance) and by this comment (overlap with in-progress internal work)
  • [x] Richy context — codebase and related-issue research done; no duplicate found, but overlapping in-progress work identified
  • [x] References — source dataset URL and process description provided by author

[!NOTE] This comment was automatically generated by Richy, Open Library's issue enrichment assistant, on behalf of @mekarpeles. This is NOT a sign-off. This issue needs lead review before work begins.

openlibrary-bot avatar Jul 31 '26 06:07 openlibrary-bot

The MARC ol_data is at https://archive.org/details/marc_bnportugal

an example bulk MARC import is: https://openlibrary.org/books/OL62387187M/Manual_de_socorros_a_pessoas_em_perigo_de_afogamento

hornc avatar Jul 31 '26 10:07 hornc

Thanks @hornc, @tfmorris, and the triage notes — this helped me sharpen the request.

To answer the open questions directly: yes, I'd still like a bot account, but for a scope that deliberately does not overlap with the BNP work. BNP national-library data belongs in your internal bulk-MARC pipeline — I fully agree and I'm glad to leave it there.

What I'd cover instead is the long tail that BNP doesn't reach: Portuguese-language self-published titles, small-press books, and books that real users of my reading app search for and can't find. These rarely have MARC records anywhere, so the bulk-MARC path doesn't help them.

On the specific questions:

Ownership: I'd maintain the account long-term as the app's maintainer. It's scoped to non-BNP gaps, so it complements rather than duplicates the internal import — and if internal coverage ever expands into this tail, I'm happy to retire the overlapping part. Endpoint: for this source (per-title, Google Books-enriched, no MARC), /api/import / /import/batch/new is the right fit; bulk-MARC is for library MARC data like BNP, not this.

Safeguards, to address the data-quality concern @tfmorris raised:

Every candidate is deduplicated against Open Library first (by ISBN, then title+author) — nothing already present is re-imported. A distinct provenance tag (pagyn:google_books:) so these records are never confused with BNP or any other source, and are easy to audit or roll back. Small, phased batches (a few dozen at a time), never bulk — driven by real user demand, not a mass dump. Glad to start with a single small sample batch for review, and to follow the sources// adapter pattern in openlibrary-bots if that's preferred.

One broader thing I'd like to offer, separate from the bot: I'm building a reading app for the Portuguese-language community and would like to channel some of those readers into contributing to Open Library directly — human, librarian-quality edits and Portuguese-language metadata improvements, plus raising awareness of OL among Portuguese readers, where it's currently little known. If there's an existing path you'd point new non-English contributors toward, I'd happily build around it. My interest is durable Portuguese coverage, however it's best achieved.

Proposed account: pagy_bot (name reflects the scope). Would this narrower scope be acceptable?

pagyn-app avatar Aug 01 '26 22:08 pagyn-app