Automatically empty the trash in all of your Plex libraries

Overview

Plex Auto Trash

Automatically empty the trash in all of your Plex libraries.

If you disable automatic trash emptying (and you probably should) trash still accumulates and must be emptied manually. This tool will automatically empty the trash of every library using two simple rules:

  • Do not empty trash if the library is currently scanning.
  • Do not empty trash until X minutes have passed since last scan (where X is configurable).

Available as a standalone binary and Docker container.

Usage

You will need a Plex authentication token to use this tool. See Plex's documentation on how to obtain yours.

From there, you can access the tool in one of two ways:

Binary

Install on Mac with:

$ brew install JakeWharton/repo/plex-auto-trash

which will put the plex-auto-trash on your shell path (assuming Homebrew is set up correctly).

For other platforms, download ZIP from latest release and run bin/plex-auto-trash or bin/plex-auto-trash.bat.

Command-line instructions

Usage: plex-auto-trash [OPTIONS] [LIBRARY]...

  Empty the trash in all of your Plex libraries.

Options:
  --base-url URL          Base URL of Plex server web interface (e.g.,
                          http://plex:32400/)
  --token TOKEN           Plex authentication token. See:
                          https://support.plex.tv/articles/204059436-finding-an-authentication-token-x-plex-token/
  --scan-idle MINUTES     Minimum amount of time (in minutes) since a library
                          scan to empty its trash (default: 5)
  --exclude-library NAME  Name of libraries to exclude. Mutually exclusive
                          with LIBRARY arguments.
  -h, --help              Show this message and exit

Arguments:
  LIBRARY  Name of libraries to scan. All libraries will be scanned if none
           specified. Mutually exclusive with --exclude-library

The --base-url and --token arguments are required.

When run, the tool will traverse all of your Plex libraries to get their folder paths. Then, it will obtain every file in those paths and compare it to items in that Plex library. Any files which are not indexed by Plex will be output, and the command will have an exit code of 1.

$ plex-auto-trash --base-url http://plexms:32400/ --token MY_TOKEN
[1/2] Emptying trash: Movies... Done
[2/2] Emptying trash: TV... Done

Docker

A container which runs the binary is available from Docker Hub and GitHub Container Registry.

  • jakewharton/plex-auto-trash Docker Image Version Docker Image Size

  • ghcr.io/jakewharton/plex-auto-trash

Start this container and point it at your Plex server with the PLEX_BASE_URL and PLEX_TOKEN environment variables.

$ docker run -d \
    -e "PLEX_BASE_URL=http://plexms:32400" \
    -e "PLEX_TOKEN=abcdef123456" \
    jakewharton/plex-auto-trash:1

For Docker Compose, add it as an additional service:

services:
  plex-auto-trash:
    container_name: plex-auto-trash
    image: jakewharton/plex-auto-trash:1
    restart: unless-stopped
    environment:
      - "PLEX_BASE_URL=http://plexms:32400"
      - "PLEX_TOKEN=abcdef123456"

The container will empty trash at 12 minutes past the hour, every hour by default. This should hopefully avoid collision with other tools and scheduled library scans. To change when it runs, specify the CRON environment variable with a valid cron specifier. For help creating a valid cron specifier, visit cron.help.

The default minimum time since last scan (called "idle time") is 5 minutes. Specify an integer value in the SCAN_IDLE environment variable to change this value.

To be notified when sync is failing visit https://healthchecks.io, create a check, and specify the ID to the container using the HEALTHCHECK_ID environment variable.

Development

To run the latest code build with ./gradlew installDist. This will put the application into build/install/plex-auto-trash/. From there you can use the command-line instructions to run.

The Docker containers can be built with docker build ., which also runs the full set of checks as CI would.

License

Copyright 2021 Jake Wharton

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
You might also like...
Trikot / kotlin multiplatform libraries

Trikot / kotlin multiplatform libraries Table of contents Introduction Modules Samples License Introduction Trikot is a framework that helps building

A personal project made using Jetpack Compose, Clean-MVVM architecture and other jetpack libraries

A basic CRUD for recording your personal credit and debit transactions. Made using Jetpack Compose, Clean-MVVM and other Jetpack libraries, incorporated with Unit Tests.

The AppMetrica Push SDK is a set of libraries for working with push notifications.
The AppMetrica Push SDK is a set of libraries for working with push notifications.

Flutter AppMetrica Push AppMetrica Push SDK — это набор библиотек для работы с push-уведомлениями. Подключив AppMetrica Push SDK, вы можете создать и

🧸 A multiplatform coroutine-based wrapper for popular platform-specific Redis client libraries

🧸 rekt ⚠️ WARNING! This project is experimental and may be missing essential features. Please let us know if you found any issues or have any suggest

🧸 A multiplatform coroutine-based wrapper for popular platform-specific Redis client libraries

🧸 rekt ⚠️ WARNING! This project is experimental and may be missing essential features. Please let us know if you found any issues or have any suggest

Boilerplate code for implementing MVVM in Android using Jetpack libraries, coroutines, dependency injection and local persistance

MVVM Foundation This projects aims to speed up development of Android apps by providing a solid base to extend Libraries Jetpack Fragment Material3 :

An example for who are all going to start learning Kotlin programming language to develop Android application.

Kotlin Example Here is an example for who are all going to start learning Kotlin programming language to develop Android application. First check this

All in 1 picker library for android.
All in 1 picker library for android.

Lassi Lassi is simplest way to pick media (either image, video, audio or doc) Lassi Media picker Key features Simple implementation Set your own custo

Dots indicator that shows the current position on a View Pager. It does all the work for you with a few customisations.
Dots indicator that shows the current position on a View Pager. It does all the work for you with a few customisations.

Dots What is Dots? Dots is a library that helps in implementing a simple yet effective dots indicator for the View Pagers used in your android code. I

Comments
  • Protection against array / drive disconnection

    Protection against array / drive disconnection

    I've been looking for something like this for years as remembering to manually empty trash is a pain (usually when something won't play because I forgot to do it) so this is great thanks and seems to be ticking along right now (I used the CRON variable to increase the frequency). I just wondered if there's any protection built in (or if not whether it is possible to add it) for a situation where the RAID array (or drive) hosting the media goes down unexpectedly for any reason. Would plex-auto-trash keep running and essentially nuke the library? I think I remember seeing that even with auto-empty on in the Plex server settings it won't do it if the library path isn't available. Does this mean I'm safe even with plex-auto-trash? If not is it possible to add some sort of check before running the empty that will prevent it if the library path is unavailable? Sorry if I haven't explained it well or used the correct terminology. Thanks.

    opened by thatbritguy 2
  • Would be great to have an ARM build of this container available

    Would be great to have an ARM build of this container available

    Apologies if this isn't the correct place to raise this, but would love to use this on my ARM based server, but it seems like it's only built for linux/amd64 at the moment.

    opened by mikeyjarvis19 2
Releases(1.0.0)
Owner
Jake Wharton
Jake Wharton
Android Ptrace Inject for all ABIs and all APIs. Help you inject Shared Library on Android.

Android Ptrace Inject 中文可以参考我的注释内容进行理解 我写的注释相对来说比较全面了 How to build Make sure you have CMake and Ninja in your PATH Edit CMakeLists.txt. Set ANDROID_ND

SsageParuders 65 Dec 19, 2022
Parallax scrolling either by offset or automatically.

ParallaxScrollingView Parallax Scrolling View. automatic scrolling with different speeds minimal integration gpu accelerated supports vector drawables

Jan Rabe 100 Nov 21, 2022
🔨 Template for easy hosting of your Java/Kotlin libraries on GitHub

?? kotlin-jvm-library-template Another template for easy hosting your Java/Kotlin libraries on GitHub. Features boilerplate for Kotlin/Java projects w

Viktor 0 Jan 7, 2022
Simple(vanilla) yet 'Do it all' place picker for your place picking needs in Android

Vanilla Place Picker Vanilla Place Picker provides a UI that displays an interactive map to get the place details and Autocomplete functionality, whic

MindInventory 115 Dec 21, 2022
The most essential libraries for Kotlin Multiplatform development

Essenty The most essential libraries for Kotlin Multiplatform development. Supported targets: android jvm js (IR and LEGACY) iosArm64, iosX64 watchosA

Arkadii Ivanov 218 Jan 3, 2023
Android project setup files when developing apps from scratch. The codebase uses lates jetpack libraries and MVVM repository architecture for setting up high performance apps

Android architecture app Includes the following Android Respository architecture MVVM Jepack libraries Carousel view Kotlin Kotlin Flow and Livedata P

null 2 Mar 31, 2022
An awesome list that curates the best KMM libraries, tools and more.

Awesome KMM Kotlin Multiplatform Mobile (KMM) is an SDK designed to simplify creating cross-platform mobile applications. With the help of KMM, you ca

Konstantin 994 Dec 28, 2022
An awesome collaborative collection of Kotlin Multiplatform libraries

Awesome Kotlin Multiplatform Awesome Projects Updated 33 November 21, 2021 Contents Guides Dependency Injection Database NoSQL SQL Extension Reactive

Matteo Crippa 5 Dec 12, 2022
Run Kotlin/JS libraries in Kotlin/JVM and Kotlin/Native programs

Zipline This library streamlines using Kotlin/JS libraries from Kotlin/JVM and Kotlin/Native programs. It makes it possible to do continuous deploymen

Cash App 1.5k Dec 30, 2022
Account-lib - A suite of libraries to facilitate the usage of account-sdk

Usage Clone this repository (skip this step if the repo is on your local machine). The default branch is fine. git clone https://github.com/AFBlockcha

null 0 May 24, 2022