Complete workflow to refresh the entire media stack after changes - cleanup Real-Debrid, restart Zurg/Rclone mounts, clear caches, verify mount health, and trigger Jellyfin library scan. Use this after deleting torrents, when mount shows stale data, after configuration changes, or when content doesn't sync between RD and Jellyfin.
Complete workflow to refresh entire media stack after RD changes - restarts Zurg/Rclone, clears caches, verifies mounts, and triggers Jellyfin scan. Use after deleting torrents, when mounts show stale data, or when content doesn't sync between Real-Debrid and Jellyfin.
/plugin marketplace add theflysurfer/claude-skills-marketplace/plugin install theflysurfer-claude-skills-marketplace@theflysurfer/claude-skills-marketplaceThis skill is limited to using the following tools:
reference.mdscripts/full_refresh.shComplete end-to-end refresh workflow for the entire media infrastructure.
Orchestrates the full refresh chain:
❌ Deleted 9-1-1 from RD but 42 folders still in /mnt/rd/shows/
❌ Added Naruto to RD but doesn't appear in Jellyfin
❌ Zurg logs show "404" for files that should exist
❌ Rclone mount frozen or stale
❌ Jellyfin shows "0 items" after adding content
ssh automation@srv759970.hstgr.cloud
# Download script
cd /home/automation/scripts
wget https://raw.githubusercontent.com/YOUR_REPO/main/.claude/skills/media-stack-refresh/scripts/full_refresh.sh
chmod +x full_refresh.sh
# Run full refresh
./full_refresh.sh
# Or skip Jellyfin restart (faster, doesn't interrupt streams)
./full_refresh.sh --skip-jellyfin
Duration: 3-5 minutes (5-30 minutes with scan)
ssh automation@srv759970.hstgr.cloud
# 1. Restart Zurg
docker restart zurg && sleep 10
# 2. Restart Rclone
docker restart rclone && sleep 15
# 3. Verify mount
ls /mnt/rd/shows/ | wc -l
# 4. (Optional) Restart Jellyfin
docker restart jellyfin && sleep 30
# 5. Trigger scan
curl -X POST 'http://localhost:8096/Library/Refresh' \
-H 'X-Emby-Token: 9af5f56a66e44ee68ddeec7bd07c9db8'
# 6. Wait and verify (2-30 min depending on library size)
[INFO] Step 1/7: Restarting Zurg...
[INFO] ✓ Zurg is healthy
[INFO] Compiled 489 torrents
[INFO] Step 2/7: Restarting Rclone...
[INFO] ✓ Rclone is running
[INFO] Step 3/7: Verifying mount health...
[INFO] ✓ Mount accessible (282 shows found)
[INFO] Step 4/7: Restarting Jellyfin...
[WARN] This will interrupt active streams!
[INFO] ✓ Jellyfin is healthy
[INFO] Step 5/7: Triggering Jellyfin library scan...
[INFO] ✓ Library scan triggered
[INFO] Step 6/7: Waiting for scan to complete...
[WARN] This may take 2-30 minutes depending on library size
[INFO] Step 7/7: Verifying results...
[INFO] ✓ Library statistics retrieved
[INFO] Series: 245
[INFO] Episodes: 8,432
[INFO] Movies: 1,234
=========================================
MEDIA STACK REFRESH COMPLETED
=========================================
# Check Zurg compiled new torrent count
docker logs zurg 2>&1 | grep "Compiled" | tail -1
Expected: New torrent count matching Real-Debrid
# If you deleted 9-1-1, this should return 0
ls /mnt/rd/shows/ | grep -i "9-1-1" | wc -l
# If you added Naruto, this should find it
ls /mnt/rd/shows/ | grep -i "naruto"
# Check library stats
curl -s 'http://localhost:8096/Items/Counts' \
-H 'X-Emby-Token: 9af5f56a66e44ee68ddeec7bd07c9db8' | \
grep -oP '"SeriesCount":\K\d+'
# Search for specific content
curl -s 'http://localhost:8096/Items?SearchTerm=Naruto&Recursive=true' \
-H 'X-Emby-Token: 9af5f56a66e44ee68ddeec7bd07c9db8' | \
grep -oP '"Name":.*?Naruto'
The cache chain:
Real-Debrid API
↓ (cached 5min)
Zurg Database
↓ (cached until restart)
Rclone VFS Cache
↓ (cached 1h default)
Filesystem Mount
↓ (cached 30s kernel)
Jellyfin Library
↓ (cached until scan)
Each layer must be refreshed - that's why simple docker restart often isn't enough!
Step 1: realdebrid-cleanup
└─ Delete dead torrents from Real-Debrid
Step 2: media-stack-refresh ← YOU ARE HERE
├─ Restart Zurg (rebuild database)
├─ Restart Rclone (clear cache)
└─ Trigger Jellyfin scan
Step 3: jellyfin-scan
└─ Monitor scan progress
Step 4: health-check
└─ Verify all services healthy
1. Skip Jellyfin restart (faster, doesn't interrupt streams):
./full_refresh.sh --skip-jellyfin
2. Scan specific library only:
# Get library ID
curl -s 'http://localhost:8096/Library/VirtualFolders' \
-H 'X-Emby-Token: YOUR_TOKEN' | jq '.[] | {Name, ItemId}'
# Scan just TV library
curl -X POST 'http://localhost:8096/Items/{LibraryId}/Refresh?Recursive=true' \
-H 'X-Emby-Token: YOUR_TOKEN'
3. Increase Rclone cache (fewer API calls):
# In docker-compose.yml for rclone
command:
- --vfs-cache-max-size=20G # Increase from 10G
| Step | Duration | Can Skip? |
|---|---|---|
| Restart Zurg | 10-15s | No |
| Restart Rclone | 15-20s | No |
| Verify Mount | 5s | No (critical) |
| Restart Jellyfin | 30-45s | Yes |
| Trigger Scan | 1s | No |
| Wait for Scan | 2-30min | No (async) |
| Verify Results | 30s | No (critical) |
Total minimum: ~2 minutes (no Jellyfin restart, small library) Total typical: ~10 minutes (with restart, medium library) Total maximum: ~35 minutes (full refresh, large library)
| Symptom | Likely Cause | Quick Fix |
|---|---|---|
| Mount not accessible | Rclone crashed | docker restart rclone |
| Zurg not healthy | Config error | Check docker logs zurg |
| Deleted content still shows | Cache not cleared | Force: docker exec rclone rclone rc vfs/forget |
| Jellyfin scan finds nothing | Mount not accessible | docker exec jellyfin ls /media/shows/ |
| Scan takes >30min | Too many files | Scan specific library only |
# Add to automation crontab
crontab -e
# Daily refresh (skip Jellyfin to avoid interrupting streams)
0 4 * * * /home/automation/scripts/full_refresh.sh --skip-jellyfin >> /home/automation/logs/media-refresh.log 2>&1
Auto-refresh after Real-Debrid cleanup:
#!/bin/bash
# /home/automation/scripts/cleanup_and_refresh.sh
# Run RD cleanup
python3 /home/automation/scripts/cleanup_realdebrid.py "$@"
# If cleanup succeeded, refresh stack
if [ $? -eq 0 ]; then
echo "Cleanup completed, refreshing media stack..."
/home/automation/scripts/full_refresh.sh --skip-jellyfin
fi
See reference.md for:
See scripts/full_refresh.sh for:
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.