mirror of
https://github.com/acedanger/shell.git
synced 2025-12-06 05:40:11 -08:00
- Introduced `validate-plex-recovery.sh` for validating Plex database recovery. - Implemented checks for service status, database integrity, web interface accessibility, API functionality, and recent logs. - Added detailed recovery summary and next steps for users. fix: Improve Debian patching script for compatibility - Enhanced `debian-patches.sh` to securely download and execute bootstrap scripts. - Updated package mapping logic and ensured proper permissions for patched files. fix: Update Docker test scripts for better permission handling - Modified `run-docker-tests.sh` to set appropriate permissions on logs directory. - Ensured log files have correct permissions after test runs. fix: Enhance setup scripts for secure installations - Updated `setup.sh` to securely download and execute installation scripts for zoxide and nvm. - Improved error handling for failed downloads. fix: Refine startup script for log directory permissions - Adjusted `startup.sh` to set proper permissions for log directories and files. chore: Revamp update-containers.sh for better error handling and logging - Rewrote `update-containers.sh` to include detailed logging and error handling. - Added validation for Docker image names and improved overall script robustness.
69 lines
2.2 KiB
Bash
Executable File
69 lines
2.2 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
################################################################################
|
|
# Plex Recent Additions Report Script
|
|
################################################################################
|
|
#
|
|
# Author: Peter Wood <peter@peterwood.dev>
|
|
# Description: Generates reports of recently added media items in Plex Media
|
|
# Server by querying the library database directly. Provides
|
|
# customizable time ranges and output formats.
|
|
#
|
|
# Features:
|
|
# - Recent additions reporting (configurable time range)
|
|
# - Library section filtering
|
|
# - Formatted output with headers and columns
|
|
# - Direct SQLite database querying
|
|
# - Media type categorization
|
|
#
|
|
# Related Scripts:
|
|
# - backup-plex.sh: Backs up the database queried by this script
|
|
# - plex.sh: General Plex service management
|
|
# - validate-plex-backups.sh: Validates database integrity
|
|
# - monitor-plex-backup.sh: System monitoring
|
|
#
|
|
# Usage:
|
|
# ./plex-recent-additions.sh # Show additions from last 7 days
|
|
# ./plex-recent-additions.sh 30 # Show additions from last 30 days
|
|
# ./plex-recent-additions.sh --help # Show usage information
|
|
#
|
|
# Dependencies:
|
|
# - sqlite3 (for database queries)
|
|
# - Plex Media Server with populated library
|
|
# - Read access to Plex database files
|
|
#
|
|
# Exit Codes:
|
|
# 0 - Success
|
|
# 1 - Database not found or access denied
|
|
# 2 - Query execution failure
|
|
#
|
|
################################################################################
|
|
|
|
# Define the path to the Plex database
|
|
PLEX_DB="/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db"
|
|
|
|
# Check if the database exists
|
|
if [ ! -f "$PLEX_DB" ]; then
|
|
echo "Plex database not found at $PLEX_DB"
|
|
exit 1
|
|
fi
|
|
|
|
# Query the database for items added in the last 7 days
|
|
sqlite3 "$PLEX_DB" <<EOF
|
|
.headers on
|
|
.mode column
|
|
SELECT
|
|
datetime(meta.added_at, 'unixepoch', 'localtime') AS "added_at"
|
|
, meta.title
|
|
, meta.year
|
|
, lib.section_type AS "library_section_type"
|
|
, lib.name as "library_name"
|
|
FROM
|
|
metadata_items meta
|
|
left join library_sections lib on meta.library_section_id = lib.id
|
|
WHERE
|
|
meta.added_at >= strftime('%s', 'now', '-7 days')
|
|
|
|
ORDER BY meta.added_at DESC;
|
|
EOF
|