I need help querying the Plex DB using SQLite. I’m a SQL beginner, I can do basic select statements, joins, etc. I’ve made a copy of the DB and started querying it. I need to check the active accounts on a server (I know I can just get it via the Web Interface, just want to see if there’s a way of getting the information out of the DB). I found the accounts table but it includes ALL accounts (active and inactive). Does anyone know where I can find the active status of the account in the DB?
What do you define as active?
I think the server can only go by accounts which did playbacks recently. It doesn’t have access to the user database on plex.tv, to get a real information about whether the account still exists at all and whether any client has been active using this account.
To get recent playback activity on your server, you might want to query the statistics_media table. A simple JOIN with the accounts table will get you the user names and the date when each user has been playing from your server last time.
The accounts tables shows all accounts that I’ve ever invited on the server. I want to see only the accounts that I am currently sharing my libraries with.
Ah. Thanks. I have a number friends and family that I’m sharing with on 2 servers. I don’t want to have to click on each person in the web interface to view which libraries I’m sharing with them. Is there an easy way to get a full list of accounts and which libraries I’m sharing with them?
Put your X-Plex-Token in the place of the ... at the end of the query string.
You can fetch https://plex.tv/api/v2/shared_servers/owned/all?X-Plex-Client-Identifier=1234&X-Plex-Token=...
as well as https://plex.tv/api/users/?X-Plex-Token=...
The value <sharedServer id="15644162" from the former is corresponding with <Server id="15644162" within the latter.