A Python script that automatically manages storage on put.io using a dual-threshold approach. Nothing to install - it can run as a Github Action for free.
-
Runs on a schedule on your own Github account for free.
-
Critical Threshold: Ensures minimum free space by permanently deleting files
-
Comfort Threshold: Keeps non-trash files below target levels by moving to trash
-
Limited to certain files (default: "chill.institute" and "putfirst")
-
Deletes oldest files first, based on creation date
-
Treats subfolders containing movie files as complete units (deletes entire folder)
-
Intelligent trash management with automatic permanent deletion
- Log in to put.io
- Go to Settings → API
- Click Create new OAuth app. The details on this page don't matter but the Name should be unique.
- Name: Put.io Janitor for <your_name>
- Description: Put.io Janitor
- Application website: https://github.com/elidickinson/PutioJanitor
- Callback URL:
urn:ietf:wg:oauth:2.0:oob - "Don't show in Extensions page" is checked
- Copy the OAuth Token for the next step.
- Fork this repository to your GitHub account
- Go to your forked repo's Settings tab → Secrets and variables → Actions
- Add a new repository secret named
PUTIO_TOKENwith your put.io OAuth Token - That's it! The workflow will run daily at 10:00 UTC (5:00 AM Eastern Time). Note it only looks in directories "chill.institute" and "putfirst" by default.
The script uses a two thresholds to manage storage: a critical threshold to maintain enough free space for downloads and a "comfort" threshold to try to move files to the Trash ahead of deleting them.
- Purpose: Ensures minimum free space is always available
- Includes trash in the free space calculation
- Action: Permanently deletes files (not just moving to trash)
- Priority: First cleans old files from trash, then from folders if needed
- Purpose: Keeps your active file collection organized
- Excludes trash - only counts non-trash files
- Action: Moves files to trash (not permanent deletion)
- Priority: Runs only after critical threshold is satisfied
In a 100GB account with 98GB in files, 6GB critical threshold, and 10GB comfort threshold:
- Critical cleanup: Permanently delete ~2GB of files (first from trash, then from folders) to have 6GB free
- Comfort cleanup: Move ~4GB of remaining files to trash to keep non-trash files below 90GB
All settings can be configured using environment variables:
| Environment Variable | Description | Default Value |
|---|---|---|
PUTIO_TOKEN |
Required - Your put.io API token | None |
PUTIO_CRITICAL_THRESHOLD_GB |
Minimum free space required (includes trash) | 6 |
PUTIO_COMFORT_THRESHOLD_GB |
Target maximum for non-trash files | 10 |
| PUTIO_DELETABLE_FOLDERS | Comma-separated list of folders to manage | chill.institute,putfirst |
| PUTIO_MAX_RETRIES | Maximum API call retry attempts | 3 |
| PUTIO_RETRY_DELAY | Seconds between retry attempts | 5 |
| PUTIO_DRY_RUN | Set to "true" to run without deleting files | false |
- Create a
.envfile in the project directory:
# .env
PUTIO_TOKEN=your_api_token_here
PUTIO_CRITICAL_THRESHOLD_GB=6
PUTIO_COMFORT_THRESHOLD_GB=10
PUTIO_DELETABLE_FOLDERS=chill.institute,putfirst
PUTIO_DRY_RUN=true # Remove this when ready to delete files- Install requirements:
pip install requests tus.py python-dotenv- Run the script:
python putio_janitor.pyIf you prefer to run the script manually with environment variables:
# Install requirements
pip install requests tus.py
# Set your API token
export PUTIO_TOKEN=your_api_token_here
# Run with default settings
python putio_janitor.py
# Test without deleting any files (dry run)
python putio_janitor.py --dry-run
# Enable debug logging
python putio_janitor.py --debugThis repository includes a GitHub Actions workflow that runs the script automatically once per day at 10:00 UTC (5:00 AM Eastern Time). The workflow file is already set up in .github/workflows/cleanup.yml.
To test the workflow immediately after setting up:
- Go to the Actions tab in your GitHub repository
- Select the Put.io Storage Manager workflow on the left
- Click the Run workflow button on the right
- Select the branch and click Run workflow
You can check the workflow logs to see what would be deleted. By default, the first run uses --dry-run mode which doesn't actually delete anything.
To customize the schedule or settings:
- Edit the
.github/workflows/cleanup.ymlfile in your repository - For the schedule, modify the
cronexpression under theschedulesection - To configure the environment variables, uncomment and modify the desired variables
- Commit your changes
To set environment variables for your workflow:
- Go to your repository's Settings tab → Secrets and variables → Actions
- Switch to the Variables tab
- Click New repository variable
- Add your variables (e.g.,
PUTIO_SPACE_THRESHOLD_GBwith value15)
You can also manually trigger the workflow from the Actions tab in your repository.
The script prioritizes environment variables over command-line arguments when both are provided. This is ideal for GitHub Actions deployment.
For example, instead of running:
python putio_janitor.py --dry-runYou can now use environment variables:
export PUTIO_COMFORT_THRESHOLD_GB=15
export PUTIO_DELETABLE_FOLDERS=movies,downloads
python putio_janitor.py --dry-runConservative Setup (keep more files):
export PUTIO_CRITICAL_THRESHOLD_GB=8 # Require more free space
export PUTIO_COMFORT_THRESHOLD_GB=15 # Allow more active filesAggressive Setup (faster cleanup, less space usage):
export PUTIO_CRITICAL_THRESHOLD_GB=4 # Less free space required
export PUTIO_COMFORT_THRESHOLD_GB=8 # Fewer active files allowedLarge Account Setup (for 500GB+ accounts):
export PUTIO_CRITICAL_THRESHOLD_GB=10 # Higher critical threshold
export PUTIO_COMFORT_THRESHOLD_GB=50 # More space for active files
export PUTIO_DELETABLE_FOLDERS=movies,downloads,4k # Manage more foldersThis makes it easy to configure the script via GitHub Actions environment variables without changing the code.
MIT