internetarchive / internetarchive/openlibrary

Give Patrons Ability to Save Open Access Books Offline (JS File System Access API)

Open
#10,529 9 comments 0 reactions 0 assignees View on GitHub
Fellowship Opportunity Lead: @mekarpeles Module: BookServer Needs: Breakdown Needs: Response Priority: 3 Type: Feature Request
Dominant language
Python
Stars
6.7k
Forks
2k
Avg merge
2d 14h
Merged PRs (30d)
126

Description

### Feature Request

### Problem / Opportunity

For Open Library to be useful as a library to patrons, it makes sense that patrons should be able to identify certain books from within their library that they want to be available when the app is offline.

Success may look like a prototype to see if/how this works and whether it may be useful to us as a way to make files available offline via PWA mode.

### Proposal

The UI could show an option (e.g. in the Unified Read Button) with a checkbox, whether to save this book in their library.

This requires the patron to grant access via [JS File System Access API](https://developer.mozilla.org/en-US/docs/Web/API/File_System_API). The patron can specify e.g. a device and directory and this information can be stored on their account preferences object as a list.

Once access is granted, the API can be used to fetch a list of books that have been saved offline. The filename would somehow have to contain data (e.g. openlibrary edition ID) that would allow us to resolve the file to a book on Open Library. This filename would also have to work with some API to follow redirects (as editions/works can be merged and cause drift of the filename v. the record on Open Library).

A new tab could be added to the My Books page (e.g. "Offline Library").

https://gist.github.com/mekarpeles/db2cc61a55c62ef3a4204ef72530fb42

### Breakdown

### Related files

Refer to [this map of common Endpoints](https://github.com/internetarchive/openlibrary/wiki/Endpoints):
* macros/LoanStatus would likely be the place where we can add this feature (the option/checkbox to add a book offline). When clicked, the button would likely use JS and require grant access. Once grant access is provided, a default path of e.g. `~/.openlibrary` would be used or allow the patron to specify.
* https://github.com/internetarchive/openlibrary/wiki/Coding-Recipes#privacy-settings -- this API allows one to save values to the patron's account preferences.

### Requirements Checklist
Checklist of requirements that need to be satisfied in order for this issue to be closed:
* [ ]

### Stakeholders

*


### Instructions for Contributors

* **Before** [creating a new branch](https://github.com/internetarchive/openlibrary/wiki/Git-Cheat-Sheet#making-changes-and-creating-a-pull-request) or pushing up changes to a PR, please first [run these commands](https://github.com/internetarchive/openlibrary/wiki/Git-Cheat-Sheet#working-on-your-branch) to ensure your repository is up to date, as the pre-commit bot may add commits to your PRs upstream.

Contributor guide

Open the contributing guide

Research direction

Start by reviewing macros/LoanStatus, the privacy-settings Coding Recipe, and the linked File System Access API gist. Define a prototype for granting directory access, saving an open-access book for offline use, and exposing it in an Offline Library tab; success is demonstrating whether this works in PWA mode.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend, web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.