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.2.tar.gz
.
File metadata
- Download URL: py_apple_books-0.2.2.tar.gz
- Upload date:
- Size: 15.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3aeaf8dfa66b4f9f25e180397cfeb177492e5b5210b28ba1abb8bcb16cf662a9 |
|
MD5 | 63a50cf82c5d95aac2938ef62c5c4b0c |
|
BLAKE2b-256 | ac5745295c8a15a1d74b2333243396b14d40fcf76b9389cf175ca5b0e84cb8c7 |
File details
Details for the file py_apple_books-0.2.2-py3-none-any.whl
.
File metadata
- Download URL: py_apple_books-0.2.2-py3-none-any.whl
- Upload date:
- Size: 16.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 23dde380727973f9d8381af6c662d3670ba01a62d76e6f7d3c20e1b5add87ad6 |
|
MD5 | a10faa1f3bf7fd8e57d510bc76658528 |
|
BLAKE2b-256 | 576f4de90f807409a87854b9b00d721ad47e0672112f730f9ed8292a33080d4f |