Include notes when exporting lists to other formats
Problem
A clear and concise description of what you want to happen
When exporting lists, they should either include any notes attached to items in the list or provide an option to include the notes.
E.g. Go to https://openlibrary.org/people/ScarTissue/lists/OL233794L/TPL_Treasure_Sale_2023
Click the "HTML" or "JSON" options
Screenshots
Additional Context
From @dcapillae on Slack:
Adding notes to the books included in an Open Library list is great because you can create annotated bibliographies to share with other readers. However, these notes are not exported when you export your lists to HTML, BibTex or JSON format. It would be interesting to be able to export your lists in Open Library including the notes you have added to each book.
Proposal & Constraints
Rough proposal:
- Update the export endpoint https://github.com/internetarchive/openlibrary/blob/ceb273a02efd2372c6411b0e86e49529c4817c21/openlibrary/plugins/openlibrary/lists.py#L743 to have a new
vparameter which defaults to 1. To avoid a breaking change to these APIs. - Update the list export method to instead of having the raw OL thing, have an object like
{ thing: THING, notes: notes }. See https://github.com/internetarchive/openlibrary/blob/f197acb2c3d23575ab9af05b2f27a061685723ba/openlibrary/core/lists/model.py#L212-L218 - For HTML: Update
lists/export_as_html.htmlto also display the notes and handle the nested dict - Handle v=1 returning just the
thingdirectly;v=2should return the wrapper{thing: THING, notes: notes}.
Leads
Related files
Stakeholders
Instructions for Contributors
- Please run these commands to ensure your repository is up to date before creating a new branch to work on this issue and each time after pushing code to Github, because the pre-commit bot may add commits to your PRs upstream.
Hi, I'd like to work on this! Just to clarify, editions, works and authors all have notes associated with them?
Hi @ChinoUkaegbu ! Apologies for the delay; if you're still interested, let me know and I will assign you!
Yes that is correct; lists on open library are either a raw reference to a edition/work/author (eg { key: "/works/OL123w" }) -- known in the code as a Seed, or a wrapping object called an AnnotatedSeed, eg: { thing: { key: "/works/OL123W" }, notes: "My note!" }.
I'd recommend updating this code: https://github.com/internetarchive/openlibrary/blob/f197acb2c3d23575ab9af05b2f27a061685723ba/openlibrary/core/lists/model.py#L204-L218
to
- Switch to using
self.get_seeds()instead ofself.seeds; this will normalize the format - change the
thingsobject to be a mapping of seed index to the item returned from the db ; that'll let you stitch them together with the notes - If
api=v2is specified as a url parameter, return the annotated seed, eg{ thing: <ITEM_FROM_DB>, notes: ... }
Hope that makes sense! Let me know if you want to be assigned or have any further questions :)