07 Your third plugin: an on-device catalog (5 minutes)
You need a JSON file reachable over HTTPS. A GitHub Gist ("Raw" link), a GitHub repo, or any static web host works.
books.json (hosted somewhere):
{
"books": [
{ "title": "My First Book", "author": "Me", "file": "https://example.com/books/first.epub" },
{ "title": "My Second Book", "author": "You", "file": "https://example.com/books/second.epub" }
]
}
/plugins/hello-shelf/device.json
{
"title": "Hello Shelf",
"description": "Books from my own JSON file.",
"browse": {
"url": "https://gist.githubusercontent.com/<you>/<id>/raw/books.json",
"items": "books",
"fields": { "title": "title", "author": "author", "url": "file" }
},
"download": {
"url": "{url}",
"dest_dir": "/Books/Hello Shelf",
"filename": "{title}.epub"
}
}
On the reader: Home -> Plugins -> Hello Shelf. The reader joins Wi-Fi, lists the two books, and selecting one downloads it to /Books/Hello Shelf/.
What each line does:
- browse.items: "books": the array of rows is at response.books.
- fields: for every row, which property holds the title, author and URL.
- download.url: "{url}": download the file whose URL the row's url field holds.
- filename: {title} is the row's title. The name is sanitized and cut to 100 bytes.
Tutorial 2 builds this into a full shelf with lists and a details screen.