Python library for Apple Books
Project description
PyAppleBooks
PyAppleBooks is a Python library designed to streamline interactions with Apple Books data. It offers a straightforward and intuitive interface, empowering developers to effortlessly access, manipulate, and manage Apple Books content through Python-based applications.
Installation
pip install py_apple_books
Getting Started - Examples
Here are some basic examples of how to use PyAppleBooks
Using PyAppleBooks
from py_apple_books import PyAppleBooks
api = PyAppleBooks()
Get list of all books
books = api.list_books()
for book in books:
print('-'*50)
print(f"Title: {book.title}")
print(f"Author: {book.author}")
# Sample output
--------------------------------------------------
Title: Think & Grow Rich
Author: Napoleon Hill
--------------------------------------------------
Title: Autobiography of a Yogi (Complete Edition)
Author: Paramahansa Yogananda
--------------------------------------------------
Title: Sapiens
Author: Yuval Noah Harari
Get a list of books along with their highlights
books_with_highlights = api.list_books(include_annotations=True)
for book in books_with_highlights:
print('-'*50)
print(f"Title: {book.title}")
print(f"Author: {book.author}")
print("Annotations:")
for annotation in book.highlights:
print(f"\t{annotation.selected_text}")
if annotation.note:
print(f"\tNote: {annotation.note}")
# Sample output
--------------------------------------------------
Title: Elon Musk
Author: Walter Isaacson
Annotations:
Adversity shaped me
The people who are crazy enough to think they can change the world are the ones who do.
They’re always trying to save the world, with their underpants on the outside or these skin-tight iron suits, which is really pretty strange when you think about it,
Reading remained Musk’s psychological retreat. Sometimes he would immerse himself in books all afternoon and most of the night, nine hours at a stretch. When the family went to someone’s house, he would disappear into their host’s library. When they went into town, he would wander off and later be found at a bookstore, sitting on the floor, in his own world.
Elon developed into a night person, staying up until dawn reading books
One unfortunate trend in the 1980s was that cars and computers became tightly sealed appliances. It was possible to open up and fiddle with the innards of the Apple II that Steve Wozniak designed in the late 1970s, but you couldn’t do that with the Macintosh, which Steve Jobs in 1984 made almost impossible to open.
Get a list of collections along with books
collections = api.list_collections(include_books=True)
for collection in collections:
print('-'*50)
print(f"Collection: {collection.title}")
print(f"Books in collection: {len(collection.books)}")
for book in collection.books:
print(f"\t{book.title}")
# Sample output
--------------------------------------------------
Collection: Management
Books in collection: 1
Crucial Conversations
--------------------------------------------------
Collection: Finance
Books in collection: 2
TheBusinessofthe21stCenturyBook-FirstFiveChapters
The Richest Man in Babylon
--------------------------------------------------
Collection: biography
Books in collection: 1
Elon Musk
Get list of all books by author
books = api.get_books_by_author('Robert C. Martin')
for book in books:
print('-'*50)
print(f"Title: {book.title}")
print(f"Author: {book.author}")
--------------------------------------------------
Title: Clean Code
Author: Robert C. Martin
--------------------------------------------------
Title: The Clean Coder
Author: Robert C. Martin
Get all notes
notes = api.get_all_notes()
for note in notes:
print('-' * 50)
print(f'Selected text: {note.selected_text}')
print(f'Note text: {note.note}')
# sample output
--------------------------------------------------
Selected text: profusion
Note text: Plethora
--------------------------------------------------
Selected text: As multi-leader replication is a somewhat retrofitted feature in many databases, there are often
subtle configuration pitfalls and surprising interactions with other database features. For example,
autoincrementing keys, triggers, and integrity constraints can be problematic. For this reason,
multi-leader replication is often considered dangerous territory that should be avoided if possible
Note text: Retrofitted = add on
--------------------------------------------------
Selected text: By subtracting a follower’s current position from the leader’s
current position, you can measure the amount of replication lag.
Note text: Calculate lag for leader based replication.
Find all green highlights
notes = api.get_annotation_by_color('green')
for note in notes:
print('-'*50)
print(f'Selected text: {note.selected_text}')
print(f'Color: {note.color}')
# sample output
--------------------------------------------------
Selected text: The purpose of life is a life of purpose
Color: green
--------------------------------------------------
Selected text: No man is free who is not a master of himself.'
Color: green
--------------------------------------------------
Selected text: The only limits on your life are those that you set yourself.
Color: green
Contribution
Thank you for considering contributing to this project! Your help is greatly appreciated.
To contribute to this project, please follow these guidelines:
Opening Issues
If you encounter a bug, have a feature request, or want to discuss something related to the project, please open an issue on the GitHub repository. When opening an issue, please provide:
Bug Reports: Describe the issue in detail. Include steps to reproduce the bug if possible, along with any error messages or screenshots.
Feature Requests: Clearly explain the new feature you'd like to see added to the project. Provide context on why this feature would be beneficial.
General Discussions: Feel free to start discussions on broader topics related to the project.
Contributing
1️⃣ Fork the GitHub repository https://github.com/vgnshiyer/py-apple-books
2️⃣ Create a new branch for your changes (git checkout -b feature/my-new-feature).
3️⃣ Make your changes and test them thoroughly.
4️⃣ Push your changes and open a Pull Request to main
.
Please provide a clear title and description of your changes.
License
PyAppleBooks is licensed under the MIT license. See the LICENSE file for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file py_apple_books-0.2.3.tar.gz
.
File metadata
- Download URL: py_apple_books-0.2.3.tar.gz
- Upload date:
- Size: 15.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0171936ccf90ffbe325cfcacd47a94f3dc142db442dcf7552c9bc65783baa6a |
|
MD5 | 1ba5dee728fa1d3c02e1f024b69e870a |
|
BLAKE2b-256 | f1579d341349805985a44bc2dae8e38c817cc5d8acd8900c1a01e268bd4ac7f0 |
File details
Details for the file py_apple_books-0.2.3-py3-none-any.whl
.
File metadata
- Download URL: py_apple_books-0.2.3-py3-none-any.whl
- Upload date:
- Size: 16.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d26b70bd60da437c97341b67a8cb3a0d612c8ec4c65044d6b9977aeb9eca35cc |
|
MD5 | a32f36731b0ae9d98841737775dee5b6 |
|
BLAKE2b-256 | 8846f44d80103a008c948a677ed5827345b115beb20b66e5991865494d37b75c |