mirror of
https://github.com/acedanger/shell.git
synced 2025-12-06 01:10:12 -08:00
feat: Update Plex Recent Additions script to use custom SQLite binary and improve query output
This commit is contained in:
@@ -42,6 +42,10 @@
|
|||||||
# Handle command line arguments
|
# Handle command line arguments
|
||||||
DAYS=${1:-7}
|
DAYS=${1:-7}
|
||||||
|
|
||||||
|
# Plex SQLite path (custom Plex SQLite binary)
|
||||||
|
PLEX_SQLITE="/usr/lib/plexmediaserver/Plex SQLite"
|
||||||
|
|
||||||
|
|
||||||
# Show help if requested
|
# Show help if requested
|
||||||
if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
|
if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
|
||||||
echo "Usage: $0 [DAYS]"
|
echo "Usage: $0 [DAYS]"
|
||||||
@@ -69,20 +73,18 @@ if [ ! -f "$PLEX_DB" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Query the database for items added in the specified number of days
|
# Query the database for items added in the specified number of days
|
||||||
sqlite3 "$PLEX_DB" <<EOF
|
"$PLEX_SQLITE" "$PLEX_DB" <<EOF
|
||||||
.headers on
|
.headers on
|
||||||
.mode column
|
.mode column
|
||||||
SELECT
|
SELECT
|
||||||
date(meta.added_at, 'unixepoch', 'localtime') AS "added_at"
|
date(meta.added_at, 'unixepoch', 'localtime') AS "added_at"
|
||||||
, lib.name as "library_name"
|
, trim(lib.name) as "library_name"
|
||||||
, meta.year
|
, meta.year
|
||||||
, meta.title
|
, trim(meta.title) as "title"
|
||||||
, meta.original_title
|
|
||||||
FROM
|
FROM
|
||||||
metadata_items meta
|
metadata_items meta
|
||||||
join library_sections lib on meta.library_section_id = lib.id
|
join library_sections lib on meta.library_section_id = lib.id
|
||||||
WHERE
|
WHERE
|
||||||
meta.added_at >= strftime('%s', 'now', '-$DAYS days')
|
meta.added_at >= strftime('%s', 'now', '-$DAYS days')
|
||||||
and meta.title is null
|
ORDER BY lib.name, meta.added_at DESC;
|
||||||
ORDER BY meta.added_at DESC;
|
|
||||||
EOF
|
EOF
|
||||||
|
|||||||
Reference in New Issue
Block a user