File: //proc/thread-self/root/workspace/retry_failed.sh
#!/bin/bash
WRAPPER="/root/clawd/skills/x-twitter/scripts/x_twitter.py"
PROFILE="datathrop"
OK=0
FAIL=0
TOTAL=0
while IFS= read -r tid; do
TOTAL=$((TOTAL+1))
URL="https://x.com/datathrop/status/$tid"
# Try delete first
RESULT=$(python3 "$WRAPPER" --profile-key "$PROFILE" delete "$URL" 2>&1)
RC=$?
if [ $RC -eq 0 ] && echo "$RESULT" | grep -q '"ok": true'; then
OK=$((OK+1))
echo "[$TOTAL/292] DELETE OK: $tid"
else
# Try unretweet as fallback
RESULT2=$(python3 "$WRAPPER" --profile-key "$PROFILE" unretweet "$URL" 2>&1)
RC2=$?
if [ $RC2 -eq 0 ] && echo "$RESULT2" | grep -q '"ok": true'; then
OK=$((OK+1))
echo "[$TOTAL/292] UNRETWEET OK: $tid"
else
# Check if already gone
if echo "$RESULT$RESULT2" | grep -qi "not found\|already\|does not exist\|no status"; then
OK=$((OK+1))
echo "[$TOTAL/292] ALREADY GONE: $tid"
else
FAIL=$((FAIL+1))
echo "[$TOTAL/292] STILL FAILING: $tid"
echo " stderr: $(echo "$RESULT" | tail -1)"
fi
fi
fi
sleep 2
done < /tmp/failed_ids.txt
echo ""
echo "=== RETRY DONE: $OK ok, $FAIL still failing out of $TOTAL ==="