Back to list
theflysurfer

realdebrid-torrent-cleanup

by theflysurfer

Personal marketplace for developing and sharing custom Claude skills

1🍴 0📅 Jan 21, 2026

SKILL.md


name: realdebrid-torrent-cleanup description: Identifies and removes dead, unavailable, or error torrents from Real-Debrid account using the API. Shows torrent status, filters by health, and safely deletes torrents with missing files. Use this when Jellyfin scans are slow, when troubleshooting 404 errors, to clean account storage, or before major library refreshes. allowed-tools:

  • bash
  • grep
  • read

Real-Debrid Torrent Cleanup

Automatically detect and remove dead torrents from your Real-Debrid account.

What This Does

Observability

First: At the start of execution, display:

🔧 Skill "realdebrid-torrent-cleanup" activated
  1. Lists all torrents with status breakdown
  2. Identifies dead torrents: magnet_error, dead, virus, 404
  3. Shows statistics: Total size, reclaimable space
  4. Safe deletion: Whitelist support, dry-run mode, confirmation required
  5. Post-cleanup: Displays before/after comparison

When To Use This

  • Jellyfin scans taking >10 minutes (dead files slow scanning)
  • Zurg logs showing "404 file not found" errors
  • Account storage approaching limit (cleanup frees 50-200GB typically)
  • After bulk torrent adding (some may fail to download)
  • Monthly maintenance to keep account healthy

Quick Start

1. Install Script on Server

ssh automation@srv759970.hstgr.cloud
cd /home/automation/scripts

# Download script (from repo or copy manually)
wget https://raw.githubusercontent.com/YOUR_REPO/main/.claude/skills/realdebrid-cleanup/scripts/cleanup_realdebrid.py

# Or copy from local repo
cat > cleanup_realdebrid.py << 'EOF'
[paste script from scripts/cleanup_realdebrid.py]
EOF

chmod +x cleanup_realdebrid.py

2. Dry-Run (See What Would Be Deleted)

python3 /home/automation/scripts/cleanup_realdebrid.py --dry-run

Expected output:

📊 Fetching Real-Debrid torrents...
Total torrents: 537
Total size: 2.30 TB

--- Status Breakdown ---
🟢 downloaded: 480
🔴 magnet_error: 23
🔴 dead: 18
🔴 virus: 4
🟡 downloading: 12

🔴 Found 45 dead torrents
Reclaimable: 156 GB

--- Dead Torrents ---
1. [MAGNET_ERROR] Movie.XYZ.2024.mkv
2. [DEAD] Old.Show.S01.Complete
...

🔍 DRY-RUN MODE - No torrents will be deleted

3. Execute Cleanup

python3 /home/automation/scripts/cleanup_realdebrid.py
# Type 'DELETE' when prompted

4. Post-Cleanup Workflow

After cleanup, refresh the media stack:

# See media-stack-refresh skill for complete workflow
docker restart zurg rclone
sleep 15
curl -X POST 'http://localhost:8096/Library/Refresh' \
  -H 'X-Emby-Token: 9af5f56a66e44ee68ddeec7bd07c9db8'

Safety Features

Automatic Protections

  • ✅ Never deletes active torrents (downloading, uploading, queued)
  • ✅ Whitelist support (preserve specific content)
  • ✅ Dry-run mode available
  • ✅ Confirmation required ("Type DELETE")
  • ✅ Respects API rate limits (0.5s between requests)

Whitelist Configuration

Edit script to protect specific torrents:

# In cleanup_realdebrid.py
WHITELIST = [
    "Naruto",            # By filename (partial match)
    "Breaking Bad",
    "4QMHWXG66PW64"     # By torrent ID (exact match)
]

Torrent Status Reference

StatusMeaningAction
downloadedFully available✅ Keep
downloadingIn progress✅ Keep
queuedWaiting to start✅ Keep
magnet_errorFailed to resolve🔴 Delete
deadFiles unavailable🔴 Delete
virusFlagged by RD🔴 Delete
errorGeneric error🔴 Delete
timeoutDownload timeout🔴 Delete

Typical Results

ScenarioTorrents DeletedSpace FreedTime Saved
First cleanup30-50%100-200 GBScans 5-10x faster
Monthly5-10%20-50 GBMinor improvement
After bulk add10-20%50-100 GBModerate improvement

Integration with Other Skills

Before cleanup:
  ├─ server-diagnostics (check disk space)
  └─ backup-status (ensure configs backed up)

Run cleanup:
  └─ realdebrid-torrent-cleanup ← YOU ARE HERE

After cleanup:
  ├─ media-stack-refresh (restart Zurg/Rclone)
  └─ jellyfin-scan (monitor library update)

API Configuration

API Key Location

  • Stored in: SECRETS.md (not committed to Git)
  • Environment variable: RD_API_KEY (optional)

Rate Limits

  • 500 requests/hour per IP
  • Script adds 0.5s delay between requests
  • Safe for accounts with 1000+ torrents

Troubleshooting

Issue: Script returns 401 Unauthorized

Cause: Invalid or expired API key

Solution:

# Update API key in script or set environment variable
export RD_API_KEY="your_new_key_here"
python3 cleanup_realdebrid.py

Issue: Can't delete torrent (403 Forbidden)

Cause: Torrent is active or locked

Solution: Wait for torrent to finish or cancel it manually in Real-Debrid web UI

Issue: Deleted torrents reappear

Cause: Sonarr/Radarr re-added the torrent

Solution: Remove from *arr apps first, then cleanup

For More Details

See reference.md for:

  • Complete API endpoint documentation
  • Advanced configuration options
  • Detailed troubleshooting guide
  • Automation setup (cron job)

See scripts/cleanup_realdebrid.py for:

  • Complete Python source code
  • Customization options
  • Function documentation

Score

Total Score

50/100

Based on repository quality metrics

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

0/10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

Reviews

💬

Reviews coming soon