Skip to content

Instantly share code, notes, and snippets.

@Lucent
Last active April 3, 2024 22:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Lucent/63d91941aca7d4c440abee96a2cc010f to your computer and use it in GitHub Desktop.
Save Lucent/63d91941aca7d4c440abee96a2cc010f to your computer and use it in GitHub Desktop.
View Plex watch history by user on Synology
#!/bin/bash
db_loc="/volume1/Plex/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db"
names=$(sqlite3 "$db_loc" "SELECT name from accounts;")
counter=0
while read -r name; do
let counter++
echo "$counter : $name"
nameArray[counter]=$name
done <<< "$names"
read index
sqlite3 "$db_loc" "SELECT a.name, l.name, v.grandparent_title, v.parent_index, v.'index', v.title FROM metadata_item_views v JOIN accounts a ON v.account_id = a.id JOIN library_sections l ON v.library_section_id = l.id WHERE a.name='${nameArray[$index]}' ORDER BY l.name, v.grandparent_title, v.parent_index, v.'index' ASC;"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment