Sign inSign up

jelhe32/embycleanup

By jelhe32

•Updated 5 months ago

Image
0

2.5K

jelhe32/embycleanup repository overview

⁠Emby Cleaner & Sonarr Integration

This Docker image provides an automated system to identify and clean up inactive TV series from your Emby library, optionally unmonitoring them in Sonarr. It also provides a small Flask web UI to view logs and trigger various test scripts.


⁠Features

  • Emby Integration: Connects to your Emby server to find inactive series, manage symlinks in a “to be deleted” library, and delete them when no user shows interest.
  • Sonarr Integration: If you have Sonarr, the script can unmonitor a series before deleting it from Emby.
  • User Interest Checks: Checks whether a series or its episodes appear in user favorites or playlists, or if the series has been active recently.
  • Automated Final Deletions: If a series remains unplayed and no interest is detected, it gets scheduled for final deletion (configurable days).
  • Three-Day Notice: Sends an email 3 days before final deletion, prompting users to show interest if they want to keep the series.
  • Flask Web App: Provides a dashboard to run test scripts, run cleanup manually, and view logs.

⁠Environment Variables

VariableDescriptionDefault / Example
EMBY_URLEmby server URL (including port).http://localhost:9096
EMBY_API_KEYAPI key for Emby."" (empty)
USER_IDThe admin user ID for Emby operations."" (empty)
SONARR_URLSonarr server URL (including port).http://localhost:8989
SONARR_API_KEYAPI key for Sonarr."" (empty)
LIBRARY_IDEmby Library ID of the “to be deleted” folder/library."447866"
SERIES_FOLDER_IDEmby folder ID for the main library containing Series.6
LIBRARY_PATHPhysical path (inside container) where symlinks are created for the “to be deleted” library./app/data/to_be_deleted/
EMBY_SYMLINK_BASEThe path Emby sees for those symlinks (e.g. /media/to_be_deleted)./media/to_be_deleted
CALCULATE_TOTAL_PLAY_COUNTWhether to sum the total play count of episodes across all users for scoring.true
CHECK_EPISODES_INTERESTWhether to check if episodes appear in playlists/favorites (episode-level interest).true
CHECK_SERIES_INTERESTWhether to check if the series itself appears in playlists/favorites.true
INACTIVE_DAYSNumber of days with no plays to consider a series inactive.365
RATING_THRESHOLDCommunity rating above which the script skips deletion.7.0
FINAL_DELETE_DAYSHow many days after linking a series to “to be deleted” it will be removed.14
THREE_DAY_NOTICEDays before final deletion to send a warning email.FINAL_DELETE_DAYS - 3
MAX_ITEMSMax number of items allowed in the “to be deleted” list.30
SIZE_WEIGHTWeight multiplier for series size in the scoring system.2
NOTIFICATION_ENABLEDToggle email notifications on/off.True
NOTIFICATION_METHODCurrently only “email” is implemented.email
ADMIN_EMAILAdmin email to receive error and important notifications.[email protected]
USER_EMAILSComma-separated list of additional user emails to get certain notifications.[email protected],[email protected]
SMTP_HOSTSMTP server host (for email).smtp.gmail.com
SMTP_PORTSMTP server port.587
SMTP_USERNAMESMTP user/email.[email protected]
SMTP_PASSWORDSMTP password or App Password."" (empty)
DISPLAY_NAMEThe display name for sent emails.EmbyCleaner
⁠Additional Configuration
  • CRON: By default, a cron job is installed to run main.py daily at midnight, appending output to /var/log/emby_cleanup/cron.log.
  • Log Files:
    • Main log: logs/emby_cleanup.log
    • Cron log: /var/log/emby_cleanup/cron.log
    • Email log: logs/email_delivery.log
    • Test scripts log: /var/log/emby_cleanup/test_scripts.log

⁠Usage

⁠Docker Run Example

docker run -d
--name emby_cleanup
-e EMBY_URL="http://192.168.1.10:8096⁠"
-e EMBY_API_KEY="abc123"
-e USER_ID="999999"
-e SONARR_URL="http://192.168.1.10:8989⁠"
-e SONARR_API_KEY="sonarr_api_key"
-e ADMIN_EMAIL="[email protected]⁠"
-e USER_EMAILS="[email protected]⁠,[email protected]⁠"
-p 9999:9999
jelhe32/emby_cleaner:latest

⁠Accessing the Web UI
  1. Open http://localhost:9999⁠ (or your mapped IP and port) in a browser.
  2. You’ll see a dashboard with buttons to:
    • Run Cleanup Program (manually run the main.py script)
    • Run Test Scripts (for Emby or Sonarr test scripts)
    • View Logs (main logs, cron logs, test scripts logs)
    • Download Main Logs

⁠Cron Execution

By default, a line is added to crontab:

0 0 * * * root CRON_JOB=1 /usr/local/bin/python /app/main.py >> /var/log/emby_cleanup/cron.log 2>&1

This calls main.py nightly at 00:00 to perform the automated cleanup.


⁠Build & Contribute
  1. Clone the repository.

  2. Edit or customize environment variables in .env.

  3. Build your local image:

    docker build -t emby_cleaner:local .
    
  4. Run as described in Docker usage examples.

⁠License

This project is provided under the MIT License (or the license you prefer). Feel free to open issues or submit PRs for improvements.

⁠Enjoy an automated Emby & Sonarr experience with the Emby Cleaner Docker image!

Tag summary

Content type

Image

Digest

sha256:029087ef2…

Size

401 MB

Last updated

5 months ago

docker pull jelhe32/embycleanup