How farishijazi/rarbgcli works
Project type and purpose
• This is a Python-based command-line interface (CLI) tool named rarbgcli.
• Its purpose is to scrape the RARBG torrent search engine (and its mirrors), solve CAPTCHAs if needed, and output torrent metadata as JSON or magnet links.
File structure
Top-level files and directories:
• rarbgcli/ – core Python package
• rarbgcli.py – entry point and CLI argument parser
• download_tesseract.py – helper for downloading/installing Tesseract OCR
• get_chrome_driver.py – helper for installing or launching Chrome WebDriver
• assets/ – usage and CAPTCHA-solving animations
• test/ – unit tests for the CLI (test_rarbgcli.py)
• requirements.txt, setup.py – dependency and packaging metadata
• build.sh, gittag-increment.sh – build/release scripts
• .pre-commit-config.yaml – code-style checks
• .gitignore
README for additional insights
• Confirms the workflow: user runs rarbgcli, passes search term and flags, tool scrapes, solves CAPTCHA (via Selenium + Tesseract), then outputs JSON or magnet links (pipe-friendly).
• Mentions optional interactive mode.
• Highlights external dependencies: Selenium Chrome Driver and Tesseract OCR.
Main components to portray
a. CLI Interface
– Argument parsing (rarbgcli.py)
– Interactive menu logic (when --interactive is used)
b. Core Scraper Engine
– HTTP client module
– HTML parser (e.g., BeautifulSoup under the hood)
– Result formatter (JSON & magnet link extraction)
c. CAPTCHA Handler
– Selenium ChromeDriver (via get_chrome_driver.py)
– OCR component (Tesseract via download_tesseract.py)
– Cookie storage and management
d. External Services
– RARBG mirror domains (e.g., rargb.to)
– Selenium browser instance
– Tesseract OCR binary
e. Output/Integration
– Standard output (JSON stream)
– Piping to external programs (e.g., jq, torrent client)
– Browser invocation for .torrent downloads
f. Packaging & CI/CD
– setup.py / PyPI distribution
– build.sh / gittag-increment.sh release workflow
– Unit tests in test/
Relationships and interactions
• User invokes CLI → CLI Interface
• CLI Interface → Core Scraper Engine (passes flags & search term)
• Core Scraper Engine → External Service (HTTP GET to mirror)
• If CAPTCHA encountered → route to CAPTCHA Handler
→ Selenium ChromeDriver → Tesseract OCR → cookie retrieval → back to HTTP client
• Scraper Engine → parse HTML → build JSON objects or magnet links
• CLI Interface → writes JSON/magnets to stdout or pipes to browser/external client
• Packaging & CI/CD operate externally on the codebase for release management; tests validate the Scraper Engine and CLI logic.
Architectural patterns & design principles
• Separation of concerns:
• CLI parsing vs. scraping logic vs. CAPTCHA resolution
• Modular helpers for external dependencies (isolated install/get routines)
• Pipe-friendly design: single responsibility and standard I/O streams
• Test coverage: isolated unit tests for key behaviors
Detail but stay focused
• Every logical component and its interactions.
• Every drop-down of functionality (interactive, download, magnet) is clearly indicated.