Skip to main content

A CLI tool for SJTU Netdisk

Project description

jdisk

A CLI tool for SJTU Netdisk.

Features:

  • 🔐 QR Code Authentication - Simple and secure login with auto-refresh
  • 📁 Complete File Operations - Upload, download, list, move, delete operations
  • 🔄 Smart Session Management - Persistent authentication with automatic renewal
  • High-Speed Transfers - Direct S3 integration with real-time progress tracking

Quick Start

Installation

Install from PyPI

pip install jdisk

or

uv tool install jdisk

Install from Source

git clone https://github.com/chengjilai/jdisk.git
cd jdisk

# Option 1: Using pixi
pixi install
pixi run python src/jdisk/jdisk.py --help

# Option 2: Using hatch for packaging
hatch build
pip install dist/jdisk-*.whl

# Option 3: Development installation
pip install -e .

# Option 4: Using uv tool
hatch build
uv tool install -f dist/

First Time Authentication

jdisk auth

Process:

  1. QR code displayed in terminal with automatic refresh
  2. Scan with SJTU mobile app
  3. Authentication automatically captured and saved for future use

Usage Examples

Authentication

jdisk auth                    # QR code authentication

Directory Listing

jdisk ls                      # List root directory (simple format)
jdisk ls docs/                # List specific directory
jdisk ls -l                   # Long listing format with details
jdisk ls -lH                  # Long format with human-readable sizes (B, K, M, G)
jdisk ls -lt                  # Sort by modification time (newest first)
jdisk ls -lS                  # Sort by file size (largest first)
jdisk ls -lr                  # Reverse sort order (oldest first)
jdisk ls -a                   # Show all files including hidden (starting with .)
jdisk ls -R                   # Recursive directory listing with tree structure
jdisk ls -lH -t               # Combine options: long format + human sizes + time sort

File Operations

jdisk upload file.txt         # Upload to root directory with progress bar
jdisk upload file.txt docs/   # Upload to specific directory
jdisk download file.txt       # Download from root directory with progress tracking
jdisk download docs/file.txt  # Download from specific directory

Directory Management

jdisk mkdir new_folder        # Create directory
jdisk mkdir -p path/to/nested # Create nested directories (parents created automatically)
jdisk rm file.txt             # Remove file
jdisk rm -r docs/             # Remove directory recursively with confirmation
jdisk mv old.txt new.txt      # Rename file (atomic operation)
jdisk mv file.txt docs/       # Move file to directory (batch move API)

File operations with paths

jdisk upload ./local/file.txt /remote/path/
jdisk download /remote/file.txt ./local/
jdisk ls /folder/subfolder/

Command Reference

ls - List Directory Contents

Option Description Example
-l Long listing format with details jdisk ls -l
-H Human readable sizes (B, K, M, G) jdisk ls -lH
-t Sort by modification time (newest first) jdisk ls -lt
-S Sort by file size (largest first) jdisk ls -lS
-r Reverse sort order jdisk ls -lr
-a Show all files including hidden jdisk ls -a
-R Recursive directory listing jdisk ls -R

upload - Upload Files

jdisk upload <local_path> [remote_path]

download - Download Files

jdisk download <remote_path> [local_path]

mkdir - Create Directories

jdisk mkdir <path> [-p]

rm - Remove Files/Directories

jdisk rm <path> [-r]

mv - Move/Rename Files

jdisk mv <source> <destination>

Troubleshooting

Authentication Issues

  • "QR code expired": Fixed with auto-refresh (QR codes refresh every 50 seconds)
  • "Network error": Ensure VPN or campus network connection to SJTU services
  • "Session expired": Run jdisk auth to re-authenticate (sessions last 30 minutes)
  • "Invalid signature": Restart authentication process and try again

File Operation Issues

  • "Upload failed": Check file size (max ~200MB) and network connectivity
  • "Download error": Verify file exists and you have download permissions
  • "Permission denied": Re-authenticate with jdisk auth to refresh session
  • "Move failed": Ensure source file exists and destination path is valid

Performance Issues

  • Slow uploads: Check internet speed and try uploading smaller files first
  • Connection timeouts: Use stable network connection, avoid WiFi if possible
  • Large directory listings: Use specific paths instead of root directory

Common Solutions

  • Always run jdisk auth first if you get authentication errors
  • Check network connection to SJTU servers (try ping pan.sjtu.edu.cn)
  • Verify file paths are correct and use absolute paths starting with /
  • Use -p flag with mkdir for creating nested directory structures
  • For large file transfers, ensure stable internet connection

Advanced Debugging

# Check session status
ls -la ~/.jdisk/session.json

# Test basic connectivity
curl -I https://pan.sjtu.edu.cn

# Reinstall if needed
uv tool uninstall jdisk && uv tool install jdisk

License

MIT License


Project Status

✅ Fully Implemented Features:

  • ✅ QR Code Authentication with auto-refresh mechanism
  • ✅ Complete file operations (upload, download, list, move, delete)
  • ✅ Advanced directory listing with Unix-like options
  • ✅ Direct S3 integration for high-speed transfers

For detailed documentation, development guides, and API reference, see the docs/ directory.


🎉 Enjoy using jdisk!

For issues, feature requests, or questions, please create an issue on GitHub.

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

jdisk-0.3.2.tar.gz (35.0 kB view details)

Uploaded Source

Built Distribution

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

jdisk-0.3.2-py3-none-any.whl (48.1 kB view details)

Uploaded Python 3

File details

Details for the file jdisk-0.3.2.tar.gz.

File metadata

  • Download URL: jdisk-0.3.2.tar.gz
  • Upload date:
  • Size: 35.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for jdisk-0.3.2.tar.gz
Algorithm Hash digest
SHA256 7aa22b2dd22d43cb9ea07ad3a9d1c3f270c657ac27a3b3701b05bd0aa1757013
MD5 3a261f01ad27e99b3c4fff4438eb96a5
BLAKE2b-256 84d303c83f8263f82adf68c36036ca2fc19dce05a3562ff5b48ed6b60bd4b93a

See more details on using hashes here.

File details

Details for the file jdisk-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: jdisk-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 48.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for jdisk-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 537d624c9e9658cd07feb9d4a4747fdc338b4699d6f9b7c7956dfb261b96d8c2
MD5 56118478944eb7b925df2daf9ac125fb
BLAKE2b-256 ac5c8bcdbab64e6724ddf081d5028585d9afc2702079ee2aea942eb335ee6656

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