A comprehensive, truly asynchronous tool for downloading Bible translations from BibleGateway.com
Project description
ByGoD
A comprehensive, truly asynchronous tool for downloading Bible translations from BibleGateway.com in multiple formats (JSON, CSV, YAML, XML) with genuine parallel downloads, retry mechanisms, and flexible output options.
๐ Features
- True Async HTTP Requests: Uses
aiohttpfor genuine parallelism, not just threading - Direct HTML Parsing: Bypasses synchronous libraries to directly parse BibleGateway HTML
- Multiple Translations: Support for 30+ Bible translations (NIV, KJV, ESV, etc.)
- Multiple Formats: Output in JSON, CSV, YAML, and XML formats
- Intelligent Rate Limiting: Configurable concurrency with automatic rate limiting
- Retry Mechanisms: Exponential backoff with configurable retry attempts
- Organized Output: Structured directory organization by translation and format
- Comprehensive Logging: Colored, detailed progress tracking
- Flexible Output Modes: Download individual books, full Bibles, or both
๐ฆ Installation
Option 1: Install from PyPI (Recommended)
pip install bygod
Option 2: Install from Source (Using Pipenv)
-
Clone the repository:
git clone git@github.com:Christ-Is-The-King/bygod.git cd bygod
-
Install pipenv (if not already installed):
pip install pipenv
-
Install dependencies and activate virtual environment:
pipenv install pipenv shell
-
Install in development mode:
pip install -e .
-
Run the application:
python main.py [options]
Option 3: Install from Source (Using pip)
-
Clone the repository:
git clone git@github.com:Christ-Is-The-King/bygod.git cd bygod
-
Create a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Install in development mode:
pip install -e .
Option 4: Build and Install Package
-
Build the package:
python build_package.py -
Install the built package:
pip install dist/bygod-*.whl
๐ฏ Quick Start
Basic Usage
Download a single translation in JSON format:
bygod --translations NIV --formats json
Download multiple translations in multiple formats:
bygod --translations NIV,KJV,ESV --formats json,csv,xml
Download specific books only:
bygod --translations NIV --books Genesis,Exodus,Psalms
Advanced Usage
Download with custom rate limiting and retry settings:
bygod \
--translations NIV,KJV \
--formats json,csv \
--rate-limit 10 \
--retries 5 \
--retry-delay 3 \
--timeout 600
Download only individual books (no full Bible):
bygod --translations NIV --output-mode books
Download only full Bible (no individual books):
bygod --translations NIV --output-mode book
Verbosity and Logging
Control output verbosity and error logging:
- Use
-v,-vv, or-vvvfor increasing verbosity - Use
-qor--quietto suppress all output except errors - Use
-eor--log-errorsto log errors to a file - Use
-lor--log-levelto set the logging level
Verbose mode (more detailed output):
bygod --translations NIV --output-mode books -v
Log errors to file:
bygod --translations NIV --log-errors logs/bible_errors.log
Set specific log level:
bygod --translations NIV --log-level DEBUG
Combine options:
bygod --translations NIV -v --log-errors logs/errors.log --log-level WARNING
๐ Sample Log Output
Example log lines for chapter and book downloads:
โ
Downloaded Psalms 149 (NIV): 9 verses in 2.3s
โ
Downloaded Psalms 150 (NIV): 6 verses in 1.1s
๐ Completed Psalms (NIV): 150/150 chapters, 2,385 total verses in 1m 57.6s
- Each chapter log shows the number of verses and the time taken for that chapter.
- The book completion log shows the total chapters, total verses (comma-formatted), and the total time for the book.
๐ Command Line Options
| Option | Description | Default |
|---|---|---|
--translations |
Comma-separated list of Bible translations | NIV |
--formats |
Output formats: json, csv, xml, yaml | json |
--output-mode |
Output mode: book, books, all | all |
--output-dir |
Directory to save downloaded Bibles | ./bibles |
--rate-limit |
Maximum concurrent requests | 5 |
--retries |
Maximum retry attempts | 3 |
--retry-delay |
Delay between retries (seconds) | 2 |
--timeout |
Request timeout (seconds) | 300 |
--books |
Comma-separated list of specific books | All books |
-v, --verbose |
Increase verbosity level (-v for INFO, -vv for DEBUG) | 0 |
-q, --quiet |
Suppress all output except errors | False |
--log-level |
Set logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL) | INFO |
--log-errors |
Log errors to specified file in clean format | None |
๐ Supported Translations
The downloader supports 30+ Bible translations including:
- NIV - New International Version
- KJV - King James Version
- ESV - English Standard Version
- NKJV - New King James Version
- NLT - New Living Translation
- CSB - Christian Standard Bible
- NASB - New American Standard Bible
- RSV - Revised Standard Version
- ASV - American Standard Version
- WEB - World English Bible
- YLT - Young's Literal Translation
- AMP - Amplified Bible
- MSG - The Message
- CEV - Contemporary English Version
- ERV - Easy-to-Read Version
- GW - God's Word Translation
- HCSB - Holman Christian Standard Bible
- ICB - International Children's Bible
- ISV - International Standard Version
- LEB - Lexham English Bible
- NCV - New Century Version
- NET - New English Translation
- NIRV - New International Reader's Version
- NRSV - New Revised Standard Version
- TLB - The Living Bible
- TLV - Tree of Life Version
- VOICE - The Voice
- WYC - Wycliffe Bible
๐ Output Structure
The downloader creates a well-organized directory structure:
bibles/
โโโ NIV/
โ โโโ NIV.json # Full Bible in JSON
โ โโโ NIV.csv # Full Bible in CSV
โ โโโ NIV.xml # Full Bible in XML
โ โโโ NIV.yml # Full Bible in YAML
โ โโโ books/
โ โโโ Genesis.json # Individual book in JSON
โ โโโ Genesis.csv # Individual book in CSV
โ โโโ Genesis.xml # Individual book in XML
โ โโโ Genesis.yml # Individual book in YAML
โ โโโ ...
โโโ KJV/
โ โโโ KJV.json
โ โโโ KJV.csv
โ โโโ books/
โ โโโ ...
โโโ ...
๐๏ธ Project Structure
The project has been refactored into a clean, modular structure:
bygod/
โโโ main.py # Main entry point
โโโ src/ # Source code package
โ โโโ __init__.py
โ โโโ constants/ # Bible translations and books data
โ โ โโโ translations.py # BIBLE_TRANSLATIONS dictionary
โ โ โโโ books.py # BOOKS list
โ โโโ core/ # Core downloader functionality
โ โ โโโ downloader.py # AsyncBibleDownloader class
โ โโโ utils/ # Utility functions
โ โ โโโ formatting.py # Duration and number formatting
โ โ โโโ logging.py # Logging setup and configuration
โ โโโ cli/ # Command line interface
โ โ โโโ parser.py # Argument parsing and validation
โ โโโ processors/ # Processing logic
โ โ โโโ bible_processor.py # Bible download processing
โ โ โโโ master_processor.py # Master file processing
โ โโโ utils/ # Utility functions
โ โโโ formatting.py # Duration and number formatting
โ โโโ logging.py # Logging setup and configuration
โโโ pyproject.toml # Project configuration
โโโ README.md # This file
โโโ ... (other files)
๐ง Technical Details
True Async Architecture
Unlike traditional threading approaches, this downloader uses:
asyncio: Python's native async/await frameworkaiohttp: True async HTTP client for concurrent requests- Semaphores: Rate limiting with configurable concurrency
asyncio.gather(): Parallel execution of multiple downloads
HTML Parsing
The downloader directly parses BibleGateway HTML using:
- BeautifulSoup: HTML parsing and navigation
- CSS Selectors: Multiple fallback selectors for verse extraction
- Regex Patterns: Chapter discovery and verse number detection
Modular Architecture
The codebase has been refactored into a clean, modular structure:
- Separation of Concerns: Each module has a specific responsibility
- Maintainability: Easy to understand and modify individual components
- Testability: Each module can be tested independently
- Reusability: Core downloader can be imported and used in other projects
- Code Quality: Comprehensive linting and formatting standards
Code Quality Standards
The project maintains high code quality through automated tools:
- Formatting: Black for consistent code style, isort for import organization
- Linting: Flake8 for style guide enforcement, Pylint for code analysis
- Type Checking: MyPy for static type analysis
- Security: Bandit for security vulnerability detection, Safety for dependency scanning
- Documentation: Pydocstyle for docstring standards
- Complexity: Vulture for dead code detection, Radon for complexity analysis
All code is automatically formatted and follows PEP 8 standards.
Error Handling
- Exponential Backoff: Intelligent retry with increasing delays
- Rate Limit Detection: Automatic handling of 429 responses
- Graceful Degradation: Continues processing even if some downloads fail
- Detailed Logging: Comprehensive error reporting and progress tracking
๐งช Testing
Run the test suite to verify functionality:
# Using pipenv
pipenv run python -m pytest src/tests/ -v
# Run specific test categories
pipenv run python -m pytest src/tests/test_constants.py -v
pipenv run python -m pytest src/tests/test_utils.py -v
pipenv run python -m pytest src/tests/test_core.py -v
# Run with coverage
pipenv run python -m pytest src/tests/ --cov=src --cov-report=html
The test suite includes:
- Core Functionality: Downloader initialization, context management, request handling
- Constants Validation: Bible translations, books, and chapter counts
- Utilities: Formatting functions and logging setup
- Integration Tests: End-to-end download scenarios
Test Results
- 47 tests passed โ
- 1 test skipped โญ๏ธ (complex async mocking)
- 0 tests failed โ
- Clean test suite: Removed problematic network simulation tests
๐ Performance
The true async architecture provides significant performance improvements:
- Genuine Parallelism: Multiple HTTP requests execute simultaneously
- Efficient Resource Usage: No thread overhead, uses event loop
- Scalable Concurrency: Configurable rate limits prevent server overload
- Memory Efficient: Streams responses without loading entire files into memory
๐ค Contributing
- Fork the repository
- Create a feature branch
- Install dependencies using pipenv:
pipenv install pipenv install --dev
- Make your changes
- Add tests for new functionality
- Ensure all tests pass:
pipenv run python tests.py
- Run the linter to ensure code quality:
# Run all code quality checks ./scripts/code-checker.sh --all # Or run specific checks ./scripts/code-checker.sh --format # Black + isort ./scripts/code-checker.sh --lint # Flake8 + Pylint ./scripts/code-checker.sh --type # MyPy type checking ./scripts/code-checker.sh --security # Bandit + Safety
- Submit a pull request
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
- BibleGateway.com for providing Bible content
- The Python async community for excellent tools and documentation
- Contributors and users who provide feedback and improvements
๐ Troubleshooting
Common Issues
Rate Limiting: If you encounter 429 errors, reduce the --rate-limit value.
Timeout Errors: Increase the --timeout value for slower connections.
Missing Verses: Some translations may have different HTML structures. The parser includes multiple fallback methods.
Memory Usage: For large downloads, consider downloading fewer books at once or using a lower rate limit.
Getting Help
- Check the logs for detailed error messages
- Try with a single translation and book first
- Ensure your internet connection is stable
- Verify that BibleGateway.com is accessible from your location
Project details
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bygod-3.0.1.tar.gz.
File metadata
- Download URL: bygod-3.0.1.tar.gz
- Upload date:
- Size: 33.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cbbcbd824147c5a5d8d5ae2e881a4285008224b3c8ef45ed94a96aee16e3985a
|
|
| MD5 |
2d2adf03b745e42946d03642efa5b80c
|
|
| BLAKE2b-256 |
ec463cbd5704caefe8d4192bc8f0c46136c9e5bee2b54922474cd1e0ee1277f3
|
File details
Details for the file bygod-3.0.1-py3-none-any.whl.
File metadata
- Download URL: bygod-3.0.1-py3-none-any.whl
- Upload date:
- Size: 40.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c29b17cd45cd1d64909c0bd79c1c08a8ae6ba9d3c5c15fbaa0f18e43de3c5594
|
|
| MD5 |
960c58cc342f883b87260054f03574f4
|
|
| BLAKE2b-256 |
65aa427b541eac05d223d4777893fb4d292a244c0bb62ee01580c65a0290d04a
|