Sign inSign up

linuxshots/cleanmyarr

By linuxshots

•Updated about 3 years ago

A lightweight utility to delete movies and shows from Radarr and Sonarr after specified time.

Image
0

2.0K

linuxshots/cleanmyarr repository overview

⁠cleanmyarr

A lightweight utility to delete movies and shows from Radarr and Sonarr after specified time.

NOTE: Currently it only supports Radarr. Development for Sonarr is underway.

Cleanmyarr uses Radarr and Sonarr API to communicate with them and get the list of movies and episodes. It checks the age of movie/Show files in Radarr/Sonarr.

If age of file is more than the expiry age (deleteAfterDays) specified in configuration file (config.yaml), It deletes the file and movie/show from Radarr/Sonarr. It performs this job at every maintenance cycle which is configured in configuration file.

Some Movies/Shows can also be marked to ignore. In this case, movies/shows marked to ignore will not be deleted even if their age is more than expiry time. Movies can be marked to ignore by adding a tag to it which is specified in configuration file (config.yaml).

It also sends the notification through configured channels to user. Currently supported channels are Email (SMTP), Gotify and Telegram.

Status of the last activity is stored in /config/status.yaml file, where it stores information like,

  • Last time maintenance was run (lastMaintenanceDate)
  • Next time at which maintenance will run (nextMaintenanceDate)
  • Movies deleted when last maintenance was run (deletedMovies)
  • Shows deleted when last maintenance was run (deletedShows)
  • Movies which are marked to ignore (ignoredMovies)
  • Shows which are marked to ignore (ignoredShows)
  • Movies which are marked for deletion and will be deleted on next maintenance (moviesMarkedForDeletion)
  • Shows which are marked for deletion and will be deleted on next maintenance (showsMarkedForDeletion)

⁠How to install

To install cleanmyarr on docker run below command

docker run -d \
    --name cleanmyarr \
    --net mynetwork \
    --restart=unless-stopped \
    --env CMA_MAINTENANCE_CYCLE="bimonthly" \
    --env CMA_DELETE_AFTER_DAYS=90 \
    --env CMA_ENABLE_GOTIFY_NOTIFICATION=true \
    --env CMA_GOTIFY_URL=gotify.example.com \
    --env CMA_GOTIFY_ENCODED_APP_TOKEN="dGgxc2lzbjB0QSQzY3IzdAo=" \
    --env CMA_MONITOR_RADARR=true \
    --env CMA_RADARR_URL=radarr.example.com \
    --env CMA_RADARR_ENCODED_API_KEY="dGhpc2lzbm90YW5hcGlrZXkK" \
    --env CMA_RADARR_ENABLE_NOTIFICATION=true \
    linuxshots/cleanmyarr:latest

With docker-compose.yml

version: "3.9"
services:
  radarr:
    container_name: radarr
    image: lscr.io/linuxserver/radarr:latest
    networks:
      - mynetwork
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=UTC
    ports:
      - 7878:7878
    volumes:
      - radarr-config:/config
      - torrent-downloads:/downloads
    restart: "unless-stopped"

  cleanmyarr:
    depends_on:
      - radarr
    image: linuxshots/cleanmyarr:latest
    container_name: cleanmyarr
    networks:
      - mynetwork
    envitonment:
      - CMA_MAINTENANCE_CYCLE="bimonthly"
      - CMA_DELETE_AFTER_DAYS=90
      - CMA_ENABLE_GOTIFY_NOTIFICATION=true
      - CMA_GOTIFY_URL=gotify.example.com
      - CMA_GOTIFY_ENCODED_APP_TOKEN="dGgxc2lzbjB0QSQzY3IzdAo="
      - CMA_MONITOR_RADARR=true
      - CMA_RADARR_URL=radarr.example.com
      - CMA_RADARR_ENCODED_API_KEY="dGhpc2lzbm90YW5hcGlrZXkK"
      - CMA_RADARR_ENABLE_NOTIFICATION=true
    restart: unless-stopped

volumes:
  radarr-config:
  torrent-downloads:

networks:
  mynetwork:
    external: true

⁠Parameters

Cleanmyarr can be configured using parametes passed at runtime as in above example.

ParameterFunctionDefault valuePossible values
CMA_MAINTENANCE_CYCLEFrequency of maintenance/cleanupdailydaily , every3Days, weekly, bimonthly, monthly
CMA_DELETE_AFTER_DAYSExpiry age of movies/series in days90Any whole number greater than 0
CMA_IGNORE_TAGTag to mark a movie/series to ignore during maintenencecma-donotdeleteAny string
CMA_ENABLE_EMAIL_NOTIFICATIONEnable email notification channelfalsetrue, false
CMA_SMTP_SERVERSMTP server to use for sending email notificationsmtp.gmail.comValid smtp server hostname
CMA_SMTP_PORTSMTP server TLS port587Valid smtp port number
CMA_SMTP_USERNAMEUsername to authenticate to SMTP server[email protected]⁠valid username string
CMA_SMTP_ENCODED_PASSWORDBase64 encoded password to authenticate to SMTP serverValid encoded password
CMA_SMTP_FROM_EMAILEmail id from which notification will be sent[email protected]⁠Valid email id
CMA_SMTP_TO_EMAILSEmail ids to which notification will be sent[email protected]⁠Valid comma seperated email ids
CMA_SMTP_CC_EMAILSCC email idsValid comma seperated email ids
CMA_SMTP_BCC_EMAILSBCC email idsValid comma seperated email ids
CMA_ENABLE_GOTIFY_NOTIFICATIONEnable Gotify notification channelfalsetrue, false
CMA_GOTIFY_URLGotify api endpoint URLgotify.localAny valid hostname string
CMA_GOTIFY_ENCODED_APP_TOKENBase64 encoded application token from GotifyAny base64 string
CMA_GOTIFY_PRIORITYGotify notification priority5Any number
CMA_ENABLE_TELEGRAM_NOTIFICATIONEnable telegram notification channelfalsetrue, false
CMA_TELEGRAM_ENCODED_BOT_TOKENBase64 enccoded telegram bot tokenAny base64 string
CMA_TELEGRAM_CHAT_IDChat id of telegram000000000Any valid chat id
CMA_MONITOR_RADARRMonitor radarr for maintenancefalsetrue, false
CMA_RADARR_URLURL of radarrhttp://radarr:7878⁠Radarr hostname/url. Always use HTTPS link if using public hostname/url
CMA_RADARR_ENCODED_API_KEYBase64 encoded Radarr API keyAny base64 encoded key
CMA_RADARR_ENABLE_NOTIFICATIONSend notification related to Radarr maintenance to notification channels ?falsetrue, false
CMA_MONITOR_SONARRMonitor sonarr for maintenancefalsetrue, false
CMA_SONARR_URLURL of sonarrhttp://sonarr:8989⁠Sonarr hostname/url. Always use HTTPS link if using public hostname/url
CMA_SONARR_ENCODED_API_KEYBase64 encoded Sonarr API keyAny base64 encoded key
CMA_SONARR_ENABLE_NOTIFICATIONSend notification related to Sonarr maintenance to notification channels ?falsetrue, false

All the credential and sensitive values must be added after base64 encoding it. You can base64 encode any string using below command in Linux terminal.

echo 'str1ng-to_enc0de' | base64 -w 0

⁠Setup telegram bot for telegram notification

Follow below article on medium to learn about setting up telegram bot for notifications and alerts.

Setup Telegram bot to get alert notifications⁠

Tag summary

Content type

Image

Digest

sha256:eb8021d44…

Size

26.3 MB

Last updated

about 3 years ago

docker pull linuxshots/cleanmyarr