A Python tool to convert web content to markdown and PDF formats, with optional Kindle delivery support.
- Convert web content to markdown using jina.ai service
- Generate PDFs from markdown files
- Send PDFs to Kindle via email
- Extract and process non-YouTube links from markdown files
- Custom styling support for PDF generation
- Clone the repository:
git clone https://github.com/yourusername/brain.git
cd brain- Install dependencies:
pip install -r requirements.txt- Install pre-commit:
pip install pre-commit- Create a
.pre-commit-config.yamlfile:
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- id: check-merge-conflict
- repo: https://github.com/psf/black
rev: 24.1.1
hooks:
- id: black
- repo: https://github.com/pycqa/flake8
rev: 7.0.0
hooks:
- id: flake8
args: ['--max-line-length=88'] # Match black's line length
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
args: ["--profile", "black"]- Install the pre-commit hooks:
pre-commit installThis will set up the following code quality checks:
- Black (code formatting)
- Flake8 (code linting)
- isort (import sorting)
- Various file checks (trailing whitespace, merge conflicts, etc.)
- Create a
.envfile in the project root:
touch .env- Add your configuration:
KINDLE_EMAIL=your-kindle-email@kindle.com
SMTP_SERVER=smtp.gmail.com
SMTP_PORT=587
EMAIL_ADDRESS=your-email@gmail.com
EMAIL_PASSWORD=your-app-specific-password- To process a single URL:
from get_md import get_and_save_md
get_and_save_md("https://example.com/article")- To process links from a markdown file:
python get_md.py- To send a PDF directly to Kindle:
python send_to_kindle.py path/to/your/file.pdf- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.