|
| 1 | +# FastGet |
| 2 | +FastGet is a Python CLI application that downloads files using multiple threads for faster download speeds. It supports HTTP range requests to download file parts in parallel and merges them together. |
| 3 | + |
| 4 | +Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here. |
| 5 | + |
| 6 | +## Working Effectively |
| 7 | +- Bootstrap, setup, and validate the repository: |
| 8 | + - `python3 --version` -- verify Python 3.12+ is available |
| 9 | + - `python3 -m pip install --upgrade pip` |
| 10 | + - `python3 -m pip install -r requirements.txt` -- installs requests and rich libraries |
| 11 | + - `python3 -m py_compile fastget.py` -- validate Python syntax |
| 12 | +- Build standalone executable: |
| 13 | + - `python3 -m pip install pyinstaller ordered-set zstandard pefile` -- install build dependencies |
| 14 | + - `time pyinstaller --onefile --distpath dist --name fastget fastget.py` -- NEVER CANCEL: takes 15-25 seconds. Set timeout to 60+ seconds. |
| 15 | +- Run the application: |
| 16 | + - Python script: `python3 fastget.py` |
| 17 | + - Built executable: `./dist/fastget` |
| 18 | + - Both versions prompt for: URL, output filename (optional), number of threads (default 8) |
| 19 | + |
| 20 | +## Validation |
| 21 | +- ALWAYS test functionality manually after making changes using the validation scenarios below. |
| 22 | +- The application works correctly but network restrictions in CI environments may prevent downloads. |
| 23 | +- ALWAYS run through at least one complete download scenario after making changes when network access is available. |
| 24 | +- ALWAYS run `python3 -m py_compile fastget.py` before committing to validate Python syntax. |
| 25 | +- Build validation: `time pyinstaller --onefile --distpath dist --name fastget fastget.py` should complete in 15-25 seconds. |
| 26 | + |
| 27 | +## Manual Validation Scenarios |
| 28 | +When network access is available, test these scenarios: |
| 29 | + |
| 30 | +### Basic Download Test |
| 31 | +```bash |
| 32 | +python3 fastget.py |
| 33 | +# When prompted: |
| 34 | +# URL: https://speed.hetzner.de/1KB.bin |
| 35 | +# Save as: test.bin (or press Enter) |
| 36 | +# Threads: 4 |
| 37 | +# Expected: Downloads 1KB file quickly with progress bar |
| 38 | +``` |
| 39 | + |
| 40 | +### Multi-threading Test |
| 41 | +```bash |
| 42 | +python3 fastget.py |
| 43 | +# When prompted: |
| 44 | +# URL: https://speed.hetzner.de/10MB.bin |
| 45 | +# Save as: large_test.bin |
| 46 | +# Threads: 8 |
| 47 | +# Expected: Downloads 10MB file using multiple threads with progress |
| 48 | +``` |
| 49 | + |
| 50 | +### Single Thread Fallback Test |
| 51 | +```bash |
| 52 | +python3 fastget.py |
| 53 | +# When prompted: |
| 54 | +# URL: https://httpbin.org/bytes/1024 |
| 55 | +# Save as: single_thread.bin |
| 56 | +# Threads: 4 |
| 57 | +# Expected: Detects no range support, falls back to single thread |
| 58 | +``` |
| 59 | + |
| 60 | +### Executable Test |
| 61 | +```bash |
| 62 | +./dist/fastget |
| 63 | +# Run same tests as above using the built executable |
| 64 | +# Expected: Same behavior as Python script |
| 65 | +``` |
| 66 | + |
| 67 | +### Validation Criteria |
| 68 | +✓ Application starts without errors |
| 69 | +✓ Prompts for URL, filename, and threads |
| 70 | +✓ Shows rich progress bar during download |
| 71 | +✓ Creates output file with correct size |
| 72 | +✓ Handles range/non-range servers correctly |
| 73 | +✓ Multi-threading works when supported |
| 74 | +✓ Single-thread fallback works when needed |
| 75 | + |
| 76 | +## Build Process Details |
| 77 | +- Build command: `pyinstaller --onefile --distpath dist --name fastget fastget.py` |
| 78 | +- NEVER CANCEL: Build takes 15-25 seconds. ALWAYS set timeout to 60+ seconds minimum. |
| 79 | +- Output: Single executable file in `dist/fastget` (Linux/macOS) or `dist/fastget.exe` (Windows) |
| 80 | +- Size: Approximately 14MB for Linux build |
| 81 | +- Dependencies embedded: Python runtime, requests, rich, and all required libraries |
| 82 | + |
| 83 | +## Common Tasks |
| 84 | +The following are outputs from frequently run commands. Reference them instead of viewing, searching, or running bash commands to save time. |
| 85 | + |
| 86 | +### Repository Structure |
| 87 | +``` |
| 88 | +ls -la |
| 89 | +. |
| 90 | +.. |
| 91 | +.git/ |
| 92 | +.github/ |
| 93 | + workflows/ |
| 94 | + fastget-build.yml # CI build workflow |
| 95 | +LICENSE # MIT License |
| 96 | +README.md # Basic project description |
| 97 | +fastget.py # Main Python application (106 lines) |
| 98 | +requirements.txt # Python dependencies (requests, rich) |
| 99 | +``` |
| 100 | + |
| 101 | +### Dependencies |
| 102 | +``` |
| 103 | +cat requirements.txt |
| 104 | +requests |
| 105 | +rich |
| 106 | +``` |
| 107 | + |
| 108 | +### Main Application Structure |
| 109 | +``` |
| 110 | +fastget.py contains: |
| 111 | +- VERSION = "2.0" |
| 112 | +- Interactive prompts for URL, output file, threads |
| 113 | +- get_file_size() - checks Content-Length and Accept-Ranges headers |
| 114 | +- download_range() - downloads file chunk with Range header |
| 115 | +- merge_files() - combines downloaded parts into final file |
| 116 | +- main() - orchestrates the download process |
| 117 | +``` |
| 118 | + |
| 119 | +### Build Dependencies |
| 120 | +``` |
| 121 | +pip install pyinstaller ordered-set zstandard pefile |
| 122 | +``` |
| 123 | + |
| 124 | +## CI/CD Information |
| 125 | +- GitHub Actions workflow: `.github/workflows/fastget-build.yml` |
| 126 | +- Builds on release for multiple platforms: Windows, macOS, Linux (both x64 and ARM64) |
| 127 | +- Uses Python 3.12 |
| 128 | +- Build artifacts uploaded as GitHub release assets |
| 129 | +- Build time in CI: varies by platform, allow 5-10 minutes for full matrix |
| 130 | + |
| 131 | +## Known Limitations |
| 132 | +- No unit tests exist in the repository |
| 133 | +- No linting tools configured (flake8, pylint not available) |
| 134 | +- Network restrictions in some CI environments prevent download testing |
| 135 | +- Application is interactive only - no command-line argument support |
| 136 | +- No --help option available |
| 137 | + |
| 138 | +## Code Quality |
| 139 | +- Always run `python3 -m py_compile fastget.py` to validate syntax before committing |
| 140 | +- The code follows basic Python conventions |
| 141 | +- Uses rich library for progress display and user prompts |
| 142 | +- Implements proper error handling for network requests |
| 143 | +- Thread-safe file writing with part files merged at the end |
| 144 | + |
| 145 | +## Troubleshooting |
| 146 | +- Import errors: Ensure `pip install -r requirements.txt` completed successfully |
| 147 | +- Build errors: Verify all build dependencies are installed |
| 148 | +- Network errors during testing: Expected in restricted environments, test manually when possible |
| 149 | +- Permission errors: Ensure executable permissions on `dist/fastget` after build |
0 commit comments