A powerful Python utility that lets you download specific folders from GitHub repositories without cloning the entire repo.
- Selective downloading: Download only the folders you need, not the entire repository
- Progress tracking: Real-time download and extraction progress bars
- Robust error handling: Automatic retries with exponential backoff for network issues
- Path preservation: Maintains the original folder structure
- User-friendly: Clear status updates and error messages
- Cross-platform: Works on Windows, macOS, and Linux
# Clone this repository
git clone https://github.com/Priyanshu-i/PGLoader.git
# Navigate to the project directory
cd PGLoader
# Install dependencies
pip install -r requirements.txt
- Python 3.6+
- requests
- tqdm
python PGLoader.py https://github.com/username/repo/tree/branch/folder
python PGLoader.py https://github.com/username/repo/tree/branch/folder -o custom_folder_name
python PGLoader.py https://github.com/username/repo/tree/branch/folder -t 120
python PGLoader.py https://github.com/username/repo/tree/branch/folder -f
Option | Description |
---|---|
url |
GitHub URL of the folder to download |
-o, --output |
Output directory name (default: folder name) |
-t, --timeout |
Connection timeout in seconds (default: 60) |
-r, --retries |
Number of retries for failed downloads (default: 3) |
-f, --force |
Force overwrite if output directory exists |
The tool accepts GitHub URLs in various formats:
https://github.com/username/repo/tree/branch/folder/path
https://github.com/username/repo/tree/branch/folder
https://github.com/username/repo
(downloads entire repo)
- Parses the GitHub URL to extract the owner, repository, branch, and folder path
- Downloads the repository as a zip archive
- Extracts only the specified folder and its contents
- Maintains the original folder structure
python PGLoader.py https://github.com/geekan/MetaGPT/tree/main/metagpt
This downloads only the metagpt
folder from the MetaGPT repository.
python PGLoader.py https://github.com/tensorflow/models/tree/master/official -o tf_official_models
This downloads the official
folder from TensorFlow models repository and saves it as tf_official_models
.
Contributions are welcome! Please feel free to submit a Pull Request.
- 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.
- GitHub API for making this tool possible
- requests library for HTTP requests
- tqdm library for progress bars
Made with ❤️ by Priyanshu Singh