### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### Verify ImageMaid Installation Source: https://github.com/kometa-team/imagemaid/blob/master/README.md This command executes the ImageMaid script to verify that the installation was successful. If the script runs without errors, it indicates that all dependencies are met and the script is ready for use. ```shell python imagemaid.py ``` -------------------------------- ### Install Python Dependencies Source: https://github.com/kometa-team/imagemaid/blob/master/README.md This command installs the necessary Python libraries required for ImageMaid to run. It's recommended to do this within a virtual environment to avoid conflicts with other Python projects. The `--ignore-installed` flag can be used if the initial installation fails. ```shell pip install -r requirements.txt ``` ```shell pip install -r requirements.txt --ignore-installed ``` -------------------------------- ### ImageMaid Environment Variables and .env File Example Source: https://github.com/kometa-team/imagemaid/blob/master/README.md This section shows how to configure ImageMaid using environment variables, either directly when running the container or by creating a .env file in the config directory. The example .env file lists various options like Plex path, mode, and API keys. ```shell # Example .env File PLEX_PATH=C:\Plex Media Server MODE=report SCHEDULE= PLEX_URL=http://192.168.1.12:32400 PLEX_TOKEN=123456789 DISCORD=https://discord.com/api/webhooks/###################/#################################################################### TIMEOUT=600 SLEEP=60 IGNORE_RUNNING=False LOCAL_DB=False USE_EXISTING=False PHOTO_TRANSCODER=False EMPTY_TRASH=False CLEAN_BUNDLES=False OPTIMIZE_DB=False TRACE=False LOG_REQUESTS=False ``` -------------------------------- ### Clone ImageMaid Repository Source: https://github.com/kometa-team/imagemaid/blob/master/README.md This command clones the ImageMaid repository from GitHub. It's the first step for a local installation, allowing you to get the latest version of the script and its associated files. ```shell git clone https://github.com/Kometa-Team/ImageMaid ``` -------------------------------- ### Untitled No description -------------------------------- ### Enable Logging and Tracing - Python Source: https://context7.com/kometa-team/imagemaid/llms.txt This example demonstrates how to enable detailed logging for troubleshooting and debugging ImageMaid operations. It supports trace logging and request logging. It requires the Plex server path, URL, and token. ```python # Enable trace logging for detailed operation logs python imagemaid.py \ --plex "/path/to/Plex Media Server" \ --url "http://localhost:32400" \ --token "your-token" \ --mode move \ --trace # Log all HTTP requests for API debugging python imagemaid.py \ -p "/path/to/Plex Media Server" \ -u "http://localhost:32400" \ -t "your-token" \ -m move \ --log-requests # Combined trace and request logging with custom timeout python imagemaid.py \ --plex "/path/to/Plex Media Server" \ --url "http://localhost:32400" \ --token "your-token" \ --mode move \ --trace \ --log-requests \ --timeout 1200 python imagemaid.py ``` -------------------------------- ### Untitled No description -------------------------------- ### Run All Maintenance Operations - Python Source: https://context7.com/kometa-team/imagemaid/llms.txt This example demonstrates how to run all maintenance operations using ImageMaid. It takes the Plex server path, URL, and token as input. It covers operations such as moving, photo transcoding, empty trash, cleaning bundles, and optimizing the database. ```python python imagemaid.py \ -p "/path/to/Plex Media Server" \ -u "http://localhost:32400" \ -t "your-token" \ -m move \ -pt \ -et \ -cb \ -od \ --sleep 120 ``` -------------------------------- ### Schedule Operations - Python Source: https://context7.com/kometa-team/imagemaid/llms.txt This example demonstrates how to schedule ImageMaid operations. It requires the Plex server path, URL, and token. The script supports daily, weekly, and monthly schedules with different modes and configurations. ```python # Simple daily schedule python imagemaid.py \ --plex "/path/to/Plex Media Server" \ --url "http://localhost:32400" \ --token "your-token" \ --schedule "07:00|daily" # Weekly schedule with specific mode python imagemaid.py \ -p "/path/to/Plex Media Server" \ -u "http://localhost:32400" \ -t "your-token" \ -sc "07:00|weekly(sunday)|mode=move" # Multiple scheduled runs with different configurations python imagemaid.py \ --plex "/path/to/Plex Media Server" \ --url "http://localhost:32400" \ --token "your-token" \ --schedule "08:00|weekly(sunday)|mode=clear,09:00|weekly(sunday)|mode=move,10:00|monthly(1)|mode=nothing;photo-transcoder=true" python imagemaid.py ``` -------------------------------- ### Query Database and Detect Images - Python Source: https://context7.com/kometa-team/imagemaid/llms.txt This example shows the internal function used by ImageMaid to query the Plex database and identify actively used images. It connects to the database, queries for poster, art, and banner images, and scans the metadata directory for bloat. It uses sqlite3, contextlib, os, tqdm, and requests modules. ```python import sqlite3 from contextlib import closing dbpath = "config/com.plexapp.plugins.library.db" urls = [] with sqlite3.connect(dbpath) as connection: connection.row_factory = sqlite3.Row with closing(connection.cursor()) as cursor: # Query for in-use poster, art, and banner images for field in ["user_thumb_url", "user_art_url", "user_banner_url"]: cursor.execute( f"SELECT {field} AS url FROM metadata_items " f"WHERE {field} like 'upload://%' OR {field} like 'metadata://%'" ) urls.extend([ requests.utils.urlparse(r["url"]).path.split("/")[-1] for r in cursor.fetchall() if r and r["url"] ]) # Scan metadata directory for files not in active URLs list import os from tqdm import tqdm meta_dir = "/path/to/Plex Media Server/Metadata" bloat_paths = [ os.path.join(r, f) for r, d, fs in tqdm(os.walk(meta_dir), unit=" directories") for f in fs if 'Contents' not in r and "." not in f and f not in urls ] print(f"Found {len(bloat_paths)} bloat images") ``` -------------------------------- ### Docker Execution for ImageMaid Source: https://context7.com/kometa-team/imagemaid/llms.txt Run ImageMaid as a Docker container for easy deployment and management. This allows for persistent configuration by mounting volumes for config and Plex data. Environment variables can be used to set operational modes and Plex connection details. Docker Compose is also supported for more complex setups. ```bash # Basic Docker run command docker run -v "/path/to/config:/config:rw" -v "/path/to/Plex Media Server:/plex:rw" kometateam/imagemaid # Docker run with specific mode via environment variable docker run \ -e MODE=move \ -e PLEX_URL=http://192.168.1.100:32400 \ -e PLEX_TOKEN=ABC123XYZ789 \ -v "/home/user/imagemaid:/config:rw" \ -v "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server:/plex:rw" \ kometateam/imagemaid # Docker Compose deployment # docker-compose.yml services: imagemaid: image: kometateam/imagemaid container_name: imagemaid environment: - TZ=America/New_York - MODE=move - PLEX_URL=http://192.168.1.100:32400 - PLEX_TOKEN=ABC123XYZ789 - SCHEDULE=07:00|weekly(sunday) volumes: - /path/to/config:/config - /path/to/plex:/plex restart: unless-stopped # Run with docker-compose docker-compose up -d ``` -------------------------------- ### Clean PhotoTranscoder Directory - Python Source: https://context7.com/kometa-team/imagemaid/llms.txt This example shows how to use ImageMaid to clean the PhotoTranscoder directory. It requires the Plex server path, URL, and token as input. It cleans the PhotoTranscoder directory using 'nothing' mode. ```python python imagemaid.py \ --plex "/path/to/Plex Media Server" \ --url "http://localhost:32400" \ --token "your-token" \ --photo-transcoder \ --mode nothing ``` -------------------------------- ### Untitled No description -------------------------------- ### Send Discord Notifications - Python Source: https://context7.com/kometa-team/imagemaid/llms.txt This example demonstrates how to send ImageMaid operation reports and notifications to a Discord channel via webhook. It requires the Plex server path, URL, token, mode, and Discord webhook URL. It sends operation mode, status, file counts, space recovered, runtime statistics, and error notifications. ```python python imagemaid.py \ --plex "/path/to/Plex Media Server" \ --url "http://localhost:32400" \ --token "your-token" \ --mode move \ --discord "https://discord.com/api/webhooks/1234567890/abcdefghijklmnopqrstuvwxyz" ``` -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### Run ImageMaid with Docker Source: https://github.com/kometa-team/imagemaid/blob/master/README.md This command demonstrates how to run the ImageMaid Docker container, mounting configuration and Plex directories. Ensure you replace placeholders with your actual paths. Paths with spaces should be enclosed in quotation marks. ```shell docker run -v :/config:rw -v :/plex:rw kometateam/imagemaid docker run -v "X:\Media\ImageMaid\config:/config:rw" -v "X:\Plex Media Server:/plex:rw" kometateam/imagemaid ``` -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### Configure ImageMaid with Docker Compose Source: https://github.com/kometa-team/imagemaid/blob/master/README.md This Docker Compose configuration file defines the ImageMaid service, including the image to use, container name, optional timezone environment variable, and volume mounts for configuration and Plex data. ```yaml services: imagemaid: image: kometateam/imagemaid container_name: imagemaid environment: - TZ=TIMEZONE #optional volumes: - /path/to/config:/config - /path/to/plex:/plex restart: unless-stopped ``` -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### Command Line Execution Modes for ImageMaid Source: https://context7.com/kometa-team/imagemaid/llms.txt Execute ImageMaid using the command line with various modes to control how unused Plex images are handled. Modes include reporting, moving to a restore directory, permanent removal, restoring moved files, and clearing the restore directory. Requires specifying the Plex path, mode, and optionally Plex URL and token. ```python # Report mode - analyze without making changes python imagemaid.py --plex "/path/to/Plex Media Server" --mode report --url "http://localhost:32400" --token "your-plex-token" # Move mode - move bloat images to restore directory (can be restored) python imagemaid.py -p "/path/to/Plex Media Server" -m move -u "http://192.168.1.100:32400" -t "ABC123XYZ789" # Remove mode - permanently delete bloat images python imagemaid.py --plex "/path/to/Plex Media Server" --mode remove --local # Restore mode - restore previously moved images back to Plex python imagemaid.py --plex "/path/to/Plex Media Server" --mode restore # Clear mode - permanently delete images from restore directory python imagemaid.py --plex "/path/to/Plex Media Server" --mode clear ``` -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### Set Plex Path for ImageMaid Source: https://github.com/kometa-team/imagemaid/blob/master/README.md Demonstrates the different ways to specify the Plex configuration directory for ImageMaid. This can be done via an environment variable, a shell command flag, or it will default to checking '/plex' relative to the script's base directory. ```shell # Environment Variable: PLEX_PATH=C:\Plex Media Server # Shell Command: -p "C:\Plex Media Server" or --plex "C:\Plex Media Server" ``` -------------------------------- ### Environment Configuration File (.env) for ImageMaid Source: https://context7.com/kometa-team/imagemaid/llms.txt Configure ImageMaid settings persistently using a `.env` file located in the config directory. This file allows setting various parameters like Plex path, operational mode, schedule, API details, and other operational flags. When this file is present, the script automatically loads these settings. ```bash # config/.env PLEX_PATH=C:\\Plex Media Server MODE=report SCHEDULE= PLEX_URL=http://192.168.1.12:32400 PLEX_TOKEN=123456789 DISCORD=https://discord.com/api/webhooks/1234567890/abcdefghijklmnopqrstuvwxyz TIMEOUT=600 SLEEP=60 IGNORE_RUNNING=False LOCAL_DB=False USE_EXISTING=False PHOTO_TRANSCODER=False EMPTY_TRASH=False CLEAN_BUNDLES=False OPTIMIZE_DB=False TRACE=False LOG_REQUESTS=False # Run with .env configuration python imagemaid.py # Script will automatically load settings from config/.env ``` -------------------------------- ### Local Database Mode for ImageMaid Source: https://context7.com/kometa-team/imagemaid/llms.txt Utilize a local copy of the Plex database instead of fetching data via the API. This is recommended for large databases or when Plex might restart during the operation. It can be enabled via command line or environment variables and supports options to ignore warnings about Plex running or to use an existing database if it's recent. ```python # Using local database copy with command line python imagemaid.py \ --plex "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server" \ --mode move \ --local # Using local database with environment variable # In config/.env: # LOCAL_DB=True # PLEX_PATH=/var/lib/plexmediaserver/Library/Application Support/Plex Media Server # MODE=move python imagemaid.py # Ignore warnings about Plex running (use cautiously) python imagemaid.py --plex "/path/to/plex" --mode move --local --ignore # Use existing database if less than 2 hours old python imagemaid.py --plex "/path/to/plex" --mode move --local --existing ``` -------------------------------- ### Set ImageMaid Run Mode Source: https://github.com/kometa-team/imagemaid/blob/master/README.md Explains how to set the operational mode for ImageMaid. The 'Mode' option controls whether changes are reported, moved, restored, cleared, removed, or ignored. This can be configured via environment variable or shell command. ```shell # Environment Variable: MODE=remove # Shell Command: -m remove or --mode remove ``` -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.