This project is a Python-based server that automates the process of retrieving metadata for eBooks in PDF format using the OpenAI API. The server also facilitates sending the processed eBooks to a Kindle device via email using the Google Scripts App for email automation.
- Metadata Retrieval: Automatically fetches detailed metadata for eBooks in PDF format using OpenAI API.
- Kindle Integration: Sends processed eBooks to Kindle devices using email.
- Google Scripts Integration: Utilizes Google Scripts App for automated email services.
- User-Friendly API: Exposes endpoints for processing PDFs and sending them to Kindle.
- Python: Backend server implementation.
- OpenAI API: For metadata extraction.
- Google Scripts App: For automated email services.
- FastAPI: For creating RESTful API endpoints.
- Docker: For containerization.
- Postman (optional): For testing API endpoints.
- Python 3.11 or higher installed on your system.
- OpenAI API key for metadata extraction.
- Access to a Gmail account for Google Scripts integration.
- Docker (optional, for containerized deployment).
git clone https://github.com/your-username/ebook-metadata-server.git
cd ebook-metadata-serverCreate a .env file in the project root with the following contents:
OPENAI_API_KEY=your_openai_api_key
GMAIL_USER=your_gmail_account
KINDLE_EMAIL=your_kindle_email_addressCreate a virtual environment and install required packages:
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txtuvicorn main:app --host 0.0.0.0 --port 8000- URL:
/pdf/pdf-list - Method:
GET - Description: Lists all uploaded PDF files.
- Response:
{ "uploaded_files": ["example1.pdf", "example2.pdf"], "uploaded_files_string": "example1.pdf, example2.pdf" }
- URL:
/pdf/processed-pdf-list - Method:
GET - Description: Lists all processed PDF files.
- Response:
{ "processed_files": ["processed1.pdf", "processed2.pdf"] }
- URL:
/pdf/pdf-upload-and-process - Method:
POST - Description: Uploads and processes a PDF file to extract metadata.
- Request Parameters:
- file: The PDF file to upload (multipart).
- n_pages: Number of pages to process (default is 5).
- Response:
{ "message": "PDF uploaded and processed successfully.", "metadata_file": "processed_files/metadata_example.json", "cover_file": "processed_files/cover_example.png", "renamed_pdf": "processed_files/example_processed.pdf" }
- URL:
/pdf/pdf-check - Method:
GET - Description: Retrieves metadata of a processed PDF file.
- Query Parameters:
- file_name: Name of the processed PDF file.
- Response:
{ "message": "Metadata checked successfully.", "metadata": { "title": "Example Title", "author": "Example Author", "publisher": "Example Publisher" } }
- URL:
/pdf/pdf-download - Method:
GET - Description: Downloads a processed PDF file.
- Query Parameters:
- file_name: Name of the processed PDF file.
- Response: Returns the PDF file as a downloadable attachment.
- Open Google Scripts and create a new project.
- Add the email sending logic to the script.
- Deploy the script as a web app and ensure it has appropriate permissions.
- Note the Web App URL and configure it in the server.
docker build -t ebook-metadata-server .docker run -d -p 8000:8000 --env-file .env ebook-metadata-server- Add support for other eBook formats (e.g., EPUB, MOBI).
- Implement a web-based UI for easier interaction.
- Enhance metadata extraction with additional APIs.
- Include automated scheduling for sending eBooks to Kindle.
- Fork the repository.
- Create a new branch for your feature/fix.
- Commit your changes and push to your fork.
- Submit a pull request for review.
This project is licensed under the MIT License. See the LICENSE file for details.
For questions or support, please reach out to:
- Email: luannn010@gmail.com
- GitHub: luannn010