Skip to main content

A comprehensive, truly asynchronous tool for downloading Bible translations from BibleGateway.com

Project description

ByGoD - The Bible, By God - Bible Gateway Downloader

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 aiohttp for 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)

  1. Clone the repository:

    git clone git@github.com:Christ-Is-The-King/bygod.git
    cd bygod
    
  2. Install pipenv (if not already installed):

    pip install pipenv
    
  3. Install dependencies and activate virtual environment:

    pipenv install
    pipenv shell
    
  4. Install in development mode:

    pip install -e .
    
  5. Run the application:

    python main.py [options]
    

Option 3: Install from Source (Using pip)

  1. Clone the repository:

    git clone git@github.com:Christ-Is-The-King/bygod.git
    cd bygod
    
  2. Create a virtual environment:

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
    
  3. Install dependencies:

    pip install -r requirements.txt
    
  4. Install in development mode:

    pip install -e .
    

Option 4: Build and Install Package

  1. Build the package:

    python build_package.py
    
  2. Install the built package:

    pip install dist/bygod-*.whl
    

๐ŸŽฏ Quick Start

Basic Usage

Download a single translation in JSON format:

python main.py -t NIV -f json

Download multiple translations in multiple formats:

python main.py -t NIV,KJV,ESV -f json,csv,xml,yaml

Download specific books only:

python main.py -t NIV -b Genesis,Exodus,Psalms

Advanced Usage

Download with custom concurrency and retry settings:

python main.py \
  -t NIV,KJV \
  -f json,csv \
  -c 10 \
  --retries 5 \
  -d 3 \
  --timeout 600

Download only individual books (no full Bible):

python main.py -t NIV -m books

Download only full Bible (no individual books):

bygod -t NIV -m book

Verbosity and Logging

Control output verbosity and error logging:

  • Use -v, -vv, or -vvv for increasing verbosity
  • Use -q or --quiet to suppress all output except errors
  • Use -e or --log-errors to log errors to a file
  • Use -l or --log-level to set the logging level

Verbose mode (more detailed output):

bygod -t NIV -m books -v

Log errors to file:

bygod -t NIV --log-errors logs/bible_errors.log

Set specific log level:

bygod -t NIV -ll DEBUG

Combine options:

bygod -t NIV -v --log-errors logs/errors.log -ll WARNING

๐Ÿ“‹ Sample Log Output

12:15:50 - INFO - ๐Ÿš€ ByGoD
12:15:50 - INFO - ๐Ÿ“š Translations: NIV
12:15:50 - INFO - ๐Ÿ“– Books: Genesis
12:15:50 - INFO - ๐Ÿ“„ Formats: json
12:15:50 - INFO - ๐Ÿ“ Output Directory: ./bibles
12:15:50 - INFO - โšก Concurrency: 5 concurrent requests
12:15:50 - INFO - ๐Ÿ”„ Retries: 3 (delay: 2s)
12:15:50 - INFO - โฑ๏ธ Timeout: 300s
12:15:50 - INFO - ๐Ÿ“– Processing NIV...
12:15:50 - INFO - ๐Ÿ“š Starting download of Genesis (NIV)
12:15:50 - INFO - ๐Ÿ“– Starting Genesis 1 (NIV)
12:15:50 - INFO - ๐Ÿ“– Starting Genesis 2 (NIV)
...
12:15:57 - INFO - โœ… Downloaded Genesis 1 (NIV): 31 verses
12:15:57 - INFO - โœ… Downloaded Genesis 2 (NIV): 25 verses
12:15:57 - INFO - โœ… Downloaded Genesis 3 (NIV): 24 verses
...
12:16:14 - INFO - ๐Ÿ“Š Completed Genesis (NIV): 50/50 chapters, 1,533 total verses in 24.1s
12:16:14 - INFO - โฑ๏ธ Total Time: 24.1s, Successful: NIV, Failed: 0 translations

๐Ÿ“‹ Command Line Options

Option Description Default
-t, --translations Comma-separated list of Bible translations NIV
-b, --books Comma-separated list of specific books All books
-f, --formats Output formats: json, csv, xml, yaml json
-m, --mode Output mode: book, books, all all
-o, --output Directory to save downloaded Bibles ./bibles
--combined Generate combined file for multiple translations False
-c, --concurrency Maximum concurrent requests 5
--retries Maximum retry attempts 3
-d, --delay Delay between retries (seconds) 2
--timeout Request timeout (seconds) 300
-v, --verbose Increase verbosity level (-v: INFO, -vv: DEBUG, -vvv: TRACE) 0
-q, --quiet Suppress all output except errors False
-ll, --log-level Set logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL) INFO
--log-errors Log errors to specified file None
-dr, --dry-run Show what would be downloaded without downloading False
-r, --resume Resume interrupted downloads by skipping existing files False
--force Force re-download even if files already exist False

๐Ÿ“š Supported Translations

The downloader supports 32 Bible translations:

  • AMP - Amplified Bible
  • ASV - American Standard Version
  • AKJV - Authorized King James Version
  • BRG - BRG Bible
  • CSB - Christian Standard Bible
  • EHV - Evangelical Heritage Version
  • ESV - English Standard Version
  • ESVUK - English Standard Version UK
  • GNV - Geneva Bible
  • GW - God's Word Translation
  • ISV - International Standard Version
  • JUB - Jubilee Bible
  • KJV - King James Version
  • KJ21 - 21st Century King James Version
  • LEB - Lexham English Bible
  • LSB - Legacy Standard Bible
  • MEV - Modern English Version
  • NASB - New American Standard Bible
  • NASB1995 - New American Standard Bible 1995
  • NET - New English Translation
  • NIV - New International Version
  • NIVUK - New International Version UK
  • NKJV - New King James Version
  • NLT - New Living Translation
  • NLV - New Life Version
  • NMB - New Matthew Bible (New Testament only)
  • NOG - Names of God Bible
  • NRSV - New Revised Standard Version
  • NRSVUE - New Revised Standard Version Updated Edition
  • RSV - Revised Standard Version
  • WEB - World English Bible
  • YLT - Young's Literal Translation

๐Ÿ“ Output Structure

The downloader creates a well-organized directory structure:

bibles/
โ”œโ”€โ”€ NIV/
โ”‚   โ”œโ”€โ”€ bible.json        # Full Bible in JSON
โ”‚   โ”œโ”€โ”€ bible.csv         # Full Bible in CSV
โ”‚   โ”œโ”€โ”€ bible.xml         # Full Bible in XML
โ”‚   โ”œโ”€โ”€ bible.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/
โ”‚   โ”œโ”€โ”€ bible.json
โ”‚   โ”œโ”€โ”€ bible.csv
โ”‚   โ””โ”€โ”€ books/
โ”‚       โ””โ”€โ”€ ...
โ””โ”€โ”€ ...

๐Ÿ—๏ธ Project Structure

The project has been refactored into a clean, modular structure:

bible-gateway-downloader/
โ”œโ”€โ”€ 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
โ”‚   โ”‚   โ”œโ”€โ”€ chapters.py       # Chapter counts
โ”‚   โ”‚   โ””โ”€โ”€ cli.py            # CLI constants
โ”‚   โ”œโ”€โ”€ 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
โ”‚   โ”œโ”€โ”€ formatters/            # Output format handlers
โ”‚   โ”‚   โ”œโ”€โ”€ json.py           # JSON formatting
โ”‚   โ”‚   โ”œโ”€โ”€ csv.py            # CSV formatting
โ”‚   โ”‚   โ”œโ”€โ”€ xml.py            # XML formatting
โ”‚   โ”‚   โ””โ”€โ”€ yaml.py           # YAML formatting
โ”‚   โ””โ”€โ”€ tests/                 # Test suite
โ”‚       โ”œโ”€โ”€ test_constants.py  # Constants tests
โ”‚       โ”œโ”€โ”€ test_core.py       # Core functionality tests
โ”‚       โ””โ”€โ”€ test_utils.py      # Utility tests
โ”œโ”€โ”€ 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 framework
  • aiohttp: 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

  1. Fork the repository
  2. Create a feature branch
  3. Install dependencies using pipenv:
    pipenv install
    pipenv install --dev
    
  4. Make your changes
  5. Add tests for new functionality
  6. Ensure all tests pass:
    pipenv run python tests.py
    
  7. 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
    
  8. 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 --concurrency 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bygod-3.0.4.tar.gz (34.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bygod-3.0.4-py3-none-any.whl (41.4 kB view details)

Uploaded Python 3

File details

Details for the file bygod-3.0.4.tar.gz.

File metadata

  • Download URL: bygod-3.0.4.tar.gz
  • Upload date:
  • Size: 34.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.12

File hashes

Hashes for bygod-3.0.4.tar.gz
Algorithm Hash digest
SHA256 85364afc489e041fe77e5d100a33ca8f84295fe67a15e39a11666d4eba9f50d5
MD5 22712d8865f94878f0730f4b03bd9271
BLAKE2b-256 9fe88c4b9d2b2862b6f1d13cce2d985303913dd0165048b6fa235ba70a00645b

See more details on using hashes here.

File details

Details for the file bygod-3.0.4-py3-none-any.whl.

File metadata

  • Download URL: bygod-3.0.4-py3-none-any.whl
  • Upload date:
  • Size: 41.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.12

File hashes

Hashes for bygod-3.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a0278eda256d807f6112791f2efe345d148edf09e3ad111635cef75eae3c058a
MD5 8dd1401c9efcff2dfd034a4804afdc4b
BLAKE2b-256 c25a66a2def9281133a775820bd81812112446a2e0a5524aefeda0f224c395ee

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page