As far as I can see the database on my Linux machine (Debian) is stored at
/var/lib/plexmediaserver/Library/Application Support/Plex Media Server
(contains 2 directories with movies ~1600, 1 directory with tv-shows ~2900 episodes)
What I want to achieve: I need a tool to manipulate the “collection” info for the media in my “library” entries. I don’t want to click on every entry, click on “…”, click on “add to”, click on “add to collection”, select a collection etc. So I think of a browser for the entries row by row where I can mark multiple entries and set the “collection” info for all of the marked rows.
Actually I marked a lot of entries by “smart collection” filters. But it is a bit exhausting to find entries that don’t match the actual filter. So I would like to see something like "[] - media (e.g. movie title) - description (e.g. content) - collection(s)" and then be able to mark [X] or unmark [] it and finally set the collection info. A filter for entries without a collection (yet) would be a nice add-on.
I should be able to code a program for this task, but I don’t find info about the structure of the database. And all “manipulate” guides refer to the web interface (and thus, a lot of mouse clicks).
So I ask you if there already is such a tool or where the database structure is documented.
As far as automating the process, it would probably be easier to use something like Python-PlexAPI opposed to modifying the database directly.
If you’re still interested in looking into the database, I don’t know of any official documentation, but collection information is spread across three tables:
The tags_collections column of the metadata_items table, represented as a pipe (|) separated list of collections.
id
…
title
…
tags_collections
123
Movie1
Collection1|Collection2
456
Movie2
Collection2
Each unique collection has an entry in the tag table with a tag_type of 2.
id
metadata_item_id
tag
tag_type
…
789
NULL
Collection1
2
790
NULL
Collection2
2
For each metadata_item that is part of a collection, there’s an entry in the taggings table:
id
metadata_item_id
tag_id
index
…
1
123
789
0
…
2
456
789
0
…
3
123
790
0
…
You have to use Plex SQLite to edit some tables like metadata_items, since it uses custom SQLite extensions that aren’t part of the standard distribution.
Thank you very much for your answer. I think it will push me into the right direction.
The Python-PlexAPI will def. be interesting for me. In fact I was looking for some kind of API to get access to the database, instead of re-inventing the wheel.
And there’s no off. doc. then? Thought so, because I didn’t find any, too. But I wasn’t sure if I had used the right keywords for a search.
But I have a problem locating the database files itself. Below that above mentioned dir. I only see a bunch of “xxx.bundle” dirs which I thought to be the database. But now I think there is some SQL server involved? You talked about SQLite?
No, modifying the database directly isn’t something that’s officially supported, so there’s no official documentation on its layout, and is subject to change between updates.
But I have a problem locating the database files itself.
Above the section on finding Plex SQLite, there’s also a section explaining that the database file is " located at /Plug-in Support/Databases/com.plexapp.plugins.library.db inside the main Plex Media Server data directory." It doesn’t live alongside Plex SQLite itself.
But now I think there is some SQL server involved? You talked about SQLite?
Yes, the Plex database uses sqlite3, but as mentioned above, with custom extensions that require using Plex SQLite to edit some tables instead of e.g. the version you’ll find on the official SQLite download page.