Fast and efficient Yandex Disk folder downloader with async support
Project description
YDisk Downloader
Fast and efficient Yandex Disk folder downloader with async support.
A Python command-line tool for downloading folders from Yandex Disk with support for:
- 📁 Public links - No authentication required
- 🔐 Private folders - OAuth token authentication
- ⚡ Concurrent downloads - Multiple files at once for speed
- 📊 Progress tracking - Visual progress bar with tqdm
- 🔄 Resume capability - Skip already downloaded files
- 📂 Folder structure - Preserves directory hierarchy
Installation
From Source
# Clone the repository
git clone https://github.com/MyDum-bsu/YDiskDownloader.git
cd YDiskDownloader
# Install with pip
pip install -e .
# Or install with development dependencies
pip install -e ".[dev]"
Using pip (after publishing)
pip install ydisk-downloader
Quick Start
Download from Public Link
# Basic usage
ydisk-downloader download https://disk.yandex.ru/d/xxxxx /path/to/save
# Example: Download to external HDD
ydisk-downloader download https://disk.yandex.ru/d/abc123xyz /media/external/backup
Download Private Folder
# With token option
ydisk-downloader download /Photos/Vacation /path/to/save --token YOUR_TOKEN
# With environment variable
export YANDEX_DISK_TOKEN=your_token_here
ydisk-downloader download /Photos/Vacation /path/to/save
Getting an OAuth Token
To access private folders, you need an OAuth token:
-
Visit the authorization URL:
https://oauth.yandex.com/authorize?response_type=token&client_id=c0ebe342af7d48fbbbfcf2d2eedb8f9b -
Log in to your Yandex account
-
Grant permission to the application
-
Copy the token from the redirect URL (after
#access_token=)
Or use the built-in help:
ydisk-downloader token-help
Token Storage Options
You can store your token in several ways:
-
Environment variable (recommended for scripts):
export YANDEX_DISK_TOKEN=your_token_here
-
Command-line option:
ydisk-downloader download SOURCE DEST --token YOUR_TOKEN
-
Configuration file:
# Save token to file echo "your_token_here" > ~/.ydisk-token
Usage
Commands
# Download a folder
ydisk-downloader download SOURCE DESTINATION [OPTIONS]
# Show disk information
ydisk-downloader info --token YOUR_TOKEN
# Get help with tokens
ydisk-downloader token-help
# Show version
ydisk-downloader --version
Download Options
| Option | Description |
|---|---|
--token, -t |
OAuth token for private folders |
--concurrent, -c |
Maximum concurrent downloads (default: 5) |
--no-skip |
Download files even if they already exist |
--no-verify |
Skip file size verification after download |
--quiet, -q |
Suppress progress output |
--no-banner |
Don't show the startup banner |
Examples
# Download with 10 concurrent connections
ydisk-downloader download https://disk.yandex.ru/d/xxxxx /path/to/save -c 10
# Re-download all files (don't skip existing)
ydisk-downloader download https://disk.yandex.ru/d/xxxxx /path/to/save --no-skip
# Quiet mode (no progress bar)
ydisk-downloader download https://disk.yandex.ru/d/xxxxx /path/to/save -q
# Download private folder
ydisk-downloader download /Documents/Work /backup/work --token $YANDEX_DISK_TOKEN
Python API
You can also use the library programmatically:
import asyncio
from ydisk_downloader import YDiskDownloader, print_stats
async def main():
# Create downloader
async with YDiskDownloader(
max_concurrent=10,
skip_existing=True,
verify_size=True,
) as downloader:
# Download from public link
stats = await downloader.download_folder(
"https://disk.yandex.ru/d/xxxxx",
"/path/to/save"
)
# Print statistics
print_stats(stats)
print(f"Downloaded: {stats.downloaded_files} files")
print(f"Total size: {stats.downloaded_size} bytes")
print(f"Skipped: {stats.skipped_files} files")
print(f"Failed: {stats.failed_files} files")
asyncio.run(main())
Using with Private Folders
import asyncio
from ydisk_downloader import YDiskDownloader
async def main():
async with YDiskDownloader(token="your_token_here") as downloader:
stats = await downloader.download_folder(
"/Photos/Vacation",
"/backup/vacation"
)
asyncio.run(main())
Advanced Usage
import asyncio
from ydisk_downloader import YDiskDownloader, YandexDiskClient
async def list_files():
"""List all files in a private folder."""
async with YandexDiskClient(token="your_token") as client:
files = await client.collect_all_files("/Photos")
for f in files:
print(f"{f.name} - {f.size} bytes")
asyncio.run(list_files())
Features
Concurrent Downloads
The downloader uses asyncio and aiohttp to download multiple files concurrently, significantly improving download speed for folders with many small files.
Resume Capability
By default, the downloader skips files that already exist in the destination with the correct size. This allows you to resume interrupted downloads without re-downloading everything.
Progress Tracking
A progress bar shows:
- Total bytes downloaded
- Download speed
- Estimated time remaining
Error Handling
The downloader handles various error conditions:
- Network errors with automatic retries
- Rate limiting with exponential backoff
- Authentication errors
- File system errors
Requirements
- Python 3.9 or higher
- Linux, macOS, or Windows
Dependencies
aiohttp- Async HTTP clientaiofiles- Async file operationstqdm- Progress barsclick- CLI framework
Troubleshooting
"OAuth token required" error
Make sure you've provided a valid OAuth token:
export YANDEX_DISK_TOKEN=your_token
# or
ydisk-downloader download SOURCE DEST --token your_token
"Resource not found" error
- For public links: Make sure the link is correct and the resource is still public
- For private folders: Make sure the path is correct and you have access
Slow downloads
Try increasing the number of concurrent downloads:
ydisk-downloader download SOURCE DEST -c 10
"No write permission" error
Make sure you have write access to the destination directory:
# Check permissions
ls -la /path/to/destination
# Create directory if needed
mkdir -p /path/to/destination
License
MIT License - see LICENSE file for details.
Contributing
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 amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Acknowledgments
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 ydisk_downloader-1.0.0.tar.gz.
File metadata
- Download URL: ydisk_downloader-1.0.0.tar.gz
- Upload date:
- Size: 18.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
15d9b554c28f0b030381c734a5b464d11556f6ecd047b0f7da84841ac567c900
|
|
| MD5 |
ea6e9b48a5d1291eac6e4c80a5851005
|
|
| BLAKE2b-256 |
6675fe4929b0f0eddba971894bd1dc414511f84e0023cd3689e4ff751198941c
|
File details
Details for the file ydisk_downloader-1.0.0-py3-none-any.whl.
File metadata
- Download URL: ydisk_downloader-1.0.0-py3-none-any.whl
- Upload date:
- Size: 17.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a1f5d3cd0c19f0fedb27d31f9c5b93434363005fc5c2363e07e68c572b80acd9
|
|
| MD5 |
a905ee204a88dbfd15c54088fed4f6fc
|
|
| BLAKE2b-256 |
055e83feb89a59c4af2ec4280d9bad07ade5e118bbccff173c6196a91a99a462
|