How to Bend Plex to Your Will to Handle Complex Libraries Without Losing Your Mind

These are of course just the trailers...

In past years I went back and forth between Plex and Emby as my media server of choice but eventually settled on the former since I switched my server to my desktop PC to an Nvidia Shield. It’s very easy to get started with Plex, but as you add different types of content and grow your libraries, it becomes more and more complicated to keep everything tidy and easy to use. I have 50TB+ in Plex organized in a dozen different libraries, learned a lot along the way, and will share my notes in this entry.

As a caveat, this post is not about streaming or transcoding, I’m using Plex in Direct Play on my LAN and do not care about serving low-quality transcodes to the entire neighborhood as some people seem keen to do. (I’m not judging, it’s just that I’m not interested nor experienced with this use case).

The ways we are interacting with a tutorial, audiobook, movie, or TV series are all very different, and it takes work to bend Plex to be a good fit with all these scenarios. If you have to take anything from this post, it’s that each type of content needs its own library with an approach that’s finetuned to it.

As much as I try to use automation and rely on Plex’s native features, to achieve the best results be prepared for some grunt work to get more obscure content organized neatly and in line with how it’s meant to be consumed. I try to stear away as much as possible from organizing or tagging content via the Plex UI, as that metadata won’t survive if you have to rebuild a library from scratch, which over the years is likely to happen eventually. Instead, metadata is best conveyed via 1) your folder/file organization and naming conventions, 2) by metatagging source files themselves, and/or 3) with helper text/json/xml files to be parsed by Plex agents.

If you’re not willing to make that effort, well, garbage in garbage out, you’ll get out of your libraries what you put into them.

1. Matching Recalcitrant Documentaries, TV Shows, Movies, Or Sports

Provided you apply the recommended naming conventions (TV, movies), Plex is usually good at auto-matching and fetching the right metadata, especially since the new movie scanner and agent were introduced with PMS 1.20. However, some content types can be tricky and tiny punctuation variations can throw the agents off (e.g. you can’t put colons in Windows file names), as well as titles in other languages than English. Follow these guidelines to save you a lot of grief, depending on the type of content you plan to collect.

Documentaries can’t be all dumped in the same library. Instead, make sure to put standalones (e.g. Tropicália) in a Movie library while series (e.g. Chef’s Table) should be in a separate TV library. Some are tricky as you may think they’re standalones but they’re actually part of an extended TV series of sorts (e.g., content from National Geographic). Look up these loose ends in TheTVDB and IMDB TMDB then decide whether to put them in your TV or Movie documentary libraries accordingly (edit: someone pointed out I made a mistake, it looks like IMDB is used by Plex just for ratings, like Rotten Tomatoes).

But after I posted this someone brought Colima to my attention. I think I’ll stick to my approach, but it’s good to have options:

“Combined Library Metadata Agent (Colima) in combination with Absolute Series Scanner (ASS) allows you to have movies and tv shows within the same library, something that Plex sadly not supports out of the box. Common scenarios to use this agent for are documentaries, western and Japanese animation libraries.”

Colima.bundle README.md

To automatically enforce Plex’s naming convention on TV shows, use a tool such as Sonarr, Filebot, TV Rename, or Rename My TV Series. TV shows should match in most cases if they’re properly named, but in the rare case that they won’t, find the offending series in TheTVDB then force a match by ID.

You can do the same ID matching with IDs from TMDB in movie libraries. Movie libraries also work for stand-up comedy shows, which I chose to set up a separate library because for me it’s a different mood, time commitment, and audience than watching a regular movie. This is why I also have a separate library for family movies but from a technical perspective you don’t have to use separate libraries in these cases, it’s more of a convenience.

Your mileage may vary with sports depending on whether individual events can be found in Tmdb or TheTVDB. UFC fights (I mean free trailers of course) for instance are recognized if you set them in a movie library. Here’s a reddit thread discussing success handling Formula 1 seasons, a similar approach may or may not work for your sport of choice.

It’s impossible for me to track all the ways people use Plex though, as there are many niches I have no interest in. For Anime there an agent called HAMA, some people want to handle radio shows, podcasts, comics, etc. There’s a whole subreddit and website just for preroll videos!

2. Getting the Best Experience for Tutorials: Use mp4 Tagging Or A Custom Agent

Multi-part video tutorials is the content type I found most tricky to handle, as the big public databases don’t have metadata about them. There are two main approaches to this challenge, each with their pros and cons. Again, you want to refrain from doing a lot of work via the Plex UI as you’ll have to redo it all over again in case you need to rebuild your library for whatever reason. With computers, nothing is permanent so plan accordingly.

2.1. The Embedded Metatag Approach

A first round of trial and error led me to using collections with the following settings:

  • Library type: Movies. If you use Other Videos you’ll have to merge video parts manually in Plex, which would need to be redone if you ever have to reset said library, which in my experience is bound to happen.
  • Scanner: Plex Movie Scanner.
  • Agent: Plex Movie (legacy).
  • Hide items belonging to collections (stacked content is based on Collections).
  • Rename files with a tool such as Flash Renamer, following the “- partx.ext” convention.
  • Group parts of the same tutorial under the same “album”, by tagging files with mp3tag. This works on mp4 video files so if you have AVIs or MKVs you’ll want to convert them with VLC or Handbrake first.
  • For categorization I don’t use tags, which never got any love in the Plex UI, but rather self-defined genres.
  • You can add specific artwork for each video segment (i.e. if you have different files within the same tutorial), which will make it easier to pick the right one among the 20 parts of a long tutorial. Some media players such as mpv make it very easy to save screenshots in one keyboard shortcut.
  • You might need to generate your own posters as tutorials about underwater archery or Roblox origami are not necessarily going to come with something good looking for Plex purposes. The expected aspect ratio is 1:1.5.

This turned to be a manageable but not entirely satisfying workflow in the backend, and the end result in the frontend is a decent but not optimal user experience since navigating a large library will mostly have to be done via the Collections tab. There must be a better way!

2.2. The Agent Approach with Helper Metadata Files

As an alternative, a better organization may be obtained by following the TV show/season convention, and even more control can be supplied by custom agents. It’s a shame that Plex stubbornly lacks support for long-established .nfo files, but people have been complaining about it for years to no avail so I’m not holding my breath. I tested four options and have adopted one that ended up being as close to my ideal requirements as it’s going to get.

  • Personal Shows Metadata Agent – this is possibly the best option for tutorials. Its meta.json format supports genre tags, studio, and cast, but it could be more thorough as there’s no support for some fields such as collections, tagline, or originally available date… I started hacking the Python source code to add these fields and I’m now very close to where I wanted to be.
  • Extended Personal Media Shows Agent (forum thread). Like the previous one, it unfortunately doesn’t leverage agents that harvest mp4 tags and there’s no way to set cast (actors/directors), Genre, or Studio. This agent relies on following a specific naming convention with optional .summary and .metadata files.
  • XBMCnfoTVImporter – This plugin is meant recognize the type of nfo files used by Kodi, but documentation is nonexistent so while this is probably a good option, prepare to fumble in the dark.
  • AvalonXmlAgent – inspired by XBMCnfoTVImporter, but with a different XML file format. Looks good but doesn’t handle season titles. My first attempt with it didn’t work too well though, I think I’ll stick to the Personal Shows Metadata Agent.
  • Local Assets-Metadata Double Agent (forum thread) – similar in spirit to the above but with the added twist of letting you save Plex Metadata locally (i.e. it does import/export).

The agent-based approach is also what I’d recommend in case you want to organize your own home photos or videos. For photos there’s an autotagging option but it’s calling a third-party service – which you may not want to do for privacy reasons – you need Plex Pass to be able to use it, and it’s reportedly no match with Google Photos’s face recognition.

For the best result with custom cast members, save square .jpg pictures of close-up mugshots in a dedicated web folder. Common cloud services such as Google Drive or OneDrive make this way too hard for some reason, I serve these images via a local web server on my Synology NAS.

3. Audiobooks & Movies with Commentary; The Elusive Playback Speed

Audiobooks are one of the top open feature requests but so far, they still require that you jump through similar hoops as tutorials for the most part, except as a Music library and using a special-purpose agent. On the frontend side, the official Plex clients are not the best to keep track of progress time across devices and other UX niceties specific to listening to audiobooks. For details see:

Meanwhile, there’s no built-in way to tell apart movies with a commentary track at the library level because the audio stream metadata is not leveraged for navigation. Some people use MKVToolNix or ffmpeg (using ISO codes) to set the commentary soundtrack to a rare language such as Icelandic, while others suggest Tautulli but that seems clunky at best, especially with a Shield server. Alternatively, you could use sharing labels, which require Plex Pass, or create a “Commentary” tag within Genres or Collections (which is how I’m currently doing it). All of these options require some amount of manual work, if you found a way to automate this, let me know in the comments.

Playback speed is something that people often want to control with audiobooks and tutorials, but despite popular demand it’s still not found in any Plex clients. There’s a third-party Chrome extension (which also works in Edge Chromium) but that obviously won’t work from your TV or tablet app.

4. Adding Chapters to Make Long Videos Easier to Navigate Around

Some long tutorials can be cumbersome to navigate, while other types of content, from sport events to concerts may also benefit from having delineated chapters. If you’re ripping DVDs or BluRays, ChapterGrabber will help you grab chapter information from the source, and there’s also the ChapterDB archive for (some) movies.

When chapter information is not already available, you can add your own chapter information within videos with software such as Handbrake or Drax. In any case this needs to be done in the video files before importing them into Plex.

The power user approach to this task relies on ffmpeg, best combined with a helper script so that you can write a simple text file listing your chapters then writing them back to the video’s metadata. The python dependency makes this overkill if you have just a few videos to “chapterize”, but who doesn’t like to spend 5 hours to automate a 15-minute manual job anyway? If like me you’re running on Windows, make sure to save your chapters.txt file with Unix end of line characters (LF), which is easy with Notepad++, otherwise you’ll end up with ugly rectangles at the end of each chapter’s title. Here’s a recap of the procedure tweaked to my own preferences, I do at least a few at a time to get into the groove of things:

[File Explorer] Make a copy of the video to be chapterized to your work directly and rename it input.mp4
[Notepad++ and mpv.net] Write down chapter timestamps in chapters.txt while speed-watching through the video. Doublecheck there are no typos.
[Command prompt] ffmpeg -i input.mp4 -f ffmetadata ffm.txt
[Visual Studio Code or Python-aware CLI] run helper.py
[Notepad++] Open ffm.txt and convert EOL characters to Unix
[Command prompt] ffmpeg -i input.mp4 -i ffm.txt -map_metadata 1 -codec copy output.mp4
[mpv.net] Open output.mp4 and navigate to each chapter to make sure the timestamp is exactly right and triple check for typos
[File Explorer] Rename output.mp4 and move it to the library folder where it’s supposed to go

While you can set art for seasons and episodes, thumbnails for chapters can’t be set manually with local images, they’re automatically generated by Plex based on each chapter’s exact timestamp (related thread). Meaning that you’ll have to tweak your chapter timestamps almost by the frame to get the best results. Well, that’s not entirely true, you could edit the files generated by Plex in the Media folder in the backend, as explained by Noel Plum in the comments below. He’s been doing it for months without issue, but there’s no telling that future changes in the PMS code won’t mess with that eventually.

With MediaInfo GUI you can quickly check whether any given video file already has chapters, and export that list to a text file. You may want to do so in order to edit it and reload it back to its video source in case the existing timestamps don’t quite work for you (e.g. bad preview thumbnails), or to remove or add to the list. The equivalent with the MediaInfo CLI is:

mediainfo.exe input.mp4 > metadata.txt

The output will need to be cleaned up and reformatted a bit if you want to reinject it as per Kyke Howell’s helper script mentioned above, but it’s not too bad. Alternatively you can use ffmpeg to extract that metadata as also shown by Kyle, with the major inconvenience that timestamps are shown as an integer based on a timebase, or you could use mp4box from the command line, which will generate a ttxt XML file (which then needs to be scrubbed) with hh:mm:ss timestamps (that’s the good part):

mp4box.exe "FilePath" -dump-chap >chapters.ttxt

Also, it seems you can’t force the generation of chapter thumbnails so you’ll have to wait for your scheduled process to kick in. Once they’re rendered, here’s what that looks like in the web UI (according to what I read chapter support varies among Plex clients):

This guy is a fountain of grappling knowledge, but also talks slowly and repeats himself constantly. Trust me, you want to chapterize him!

5. Misc Library Customization & Management Tips

  • If you want your library to look ultra clean, consider using custom posters and fanart such as those found on The Poster Database. Looks very cool but I’m waiting for that site to add a Plex agent and direct integration into the Poster tab shown when you edit an item.
  • For music, some people are raving about Plexamp, I haven’t used it. I’m not currently handling music albums in Plex, I’m sure this would turn into a whole chapter in its own right.
  • You’ll probably want to customize which libraries are part of global search and featured in dashboards, i.e. On Deck and Recently Added. That’s done in the Advanced Settings of each library.

6. Library Organization Wrap-Up

As a summary, to get your content properly organized with the minimum amount of friction, it’s essential that you:

  • Choose the right library media type for your content, which can sometimes be counter intuitive. This means your source content needs to be properly organized, and you can’t drop everything in one morass of a Plex library.
  • Follow the official naming conventions for your source folders and files, and organize your content.
  • Figure out whether readily available scanners and agents will do the job, or if you have to handle metadata yourself. There’s for instance an agent to handle Youtube downloads.
  • Set up each library’s advanced settings deliberately as some of the defaults can have big consequences. This is best done when you first set up your library, though that can be edited later.
  • Summary of the summary: RTFM, there’s more to Plex than first meets the eye and it’s well worth understanding what’s going on beneath the hood.

7. Managing & Extending Plex Beyond the UI: Plugins, Maintenance, Data Analysis

7.1. Plugins

While plugins such as Web.Tools are no longer supported in the Plex UI, they still work in case one of them offers something of interest for your specific requirements.

7.2. Maintenance

Plex Media Server occasionally stops for obscure reasons such as version updates. Scheduling server maintenance may save you hours of setup time if your Plex database becomes irremediably corrupted, which can happen in case of abrupt shutdowns, so it wouldn’t be a bad idea to put your server behind a UPS. Restoring from a backup is very easy.

Scheduled backups: A Good Idea ™

7.3. Programmatic & Database Access

There are several ways to automate functions of the Plex server:

  • An API that I haven’t tested yet.
  • Webhooks that require Plex Pass.
  • PlexAPI, a set of unofficial Python bindings whose goal is to “match all capabilities of the official Plex Web Client”, including navigating libraries, performing library actions such as scans, remote control, and listening to notifications. A set of scripts that use this library can be found in this Github repository.
  • Python-PlexLibrary, a “command line utility for creating and maintaining dynamic Plex libraries and playlists based on ‘recipes’.”
  • RPA software that captures how you interact with a website or desktop app, such as Power Automate. I’d pursue this only if all else fails, but it’s an option.

Plex stores its data in an SQLite file, which has this schema that you can query like so. I’ve used this to visualize my library in Power BI as per the screenshot below. If you’re going to do this, work off a copy of the database just to be safe. A low-tech alternative is to use ExportTools to generate a CSV. Many people use Tautulli to monitor their Plex server, though it’s focused more on analyzing viewership than library content.

Plex data in Power BI – two of my favorite things together!

I started a thread on Reddit mentioning this entry, lots of good feedback in there that I’ll try to reflect here as time allows.

10 thoughts on “How to Bend Plex to Your Will to Handle Complex Libraries Without Losing Your Mind

  1. Jason

    I’ve had to abandon Plex since they couldn’t stop messing with it on the very console you mentioned here I have my own Plex server Nas and the Nvidia Shield. But ever since they took out folder view permanently it’s become a waste of $99 usd. Until they fix folder view it’s hot garbage in my eyes.

    Reply
    1. otravers Post author

      I plan to move Plex Media Server from my Shield to a Docker container on my new NAS, which among other things will let me control which version I run. The folder view is indeed underwhelming.

      Reply
    1. otravers Post author

      I have an old Synology NAS with 3TB WD REDs but one of them died. I’m waiting for the delivery of a newer Synology NAS with 12TB WD Elements drive that I’ll schuck. I also have several USB and internal drives.

      Reply
  2. Noel Plum

    I have managed to make custom chapter thumbnails. Wait for Plex to create its set of thumbs then go into the media folder Plex creates for that movie and replace the thumbs with your own.
    I have been doing this for months now and they don’t seem to get replaced, it is just a pain working out which folder is for which movie if you add more than a few in one day.

    Reply
    1. otravers Post author

      Yeah it’s not fun to wade through folders named 0930da16626e93ba5d8f0b8b6d1df7303abac1e.bundle and the like! It’s interesting that Plex won’t replace them, so more power to you if that works for you. I’d still be afraid that sooner or later Plex will just do so randomly, and then I’d have to go through the same tedious process again. I guess you could backup the Media folder, but that begs more questions such as whether these long folder names are permanent.

      Reply
      1. Noel Plum

        What I have found is that Plex generates thumbs when I shift the video file across initially but then recreates them on the next scheduled slot for such things (which i have set for the small hours every night) so I shift a few new videos in, leave it 24 hours and then swap out the thumbs.
        I feel pretty safe by now that i won’t re-hash through all the movies I have chapterised BUT I do fear a major update or me altering a setting that inadvertantly leads to the same outcome!
        As it stands though, I just add a few at once each day and then by sifting the directories by date modified I can easily pick them out.
        You’d think it wouldn’t require such insanity to perform something so simply though, lol

        Reply
  3. Toby

    I also have my Plex server on a Shield. You aren’t kidding about having to eventually rebuild a library from scratch. Thankfully I only have 70 movies. When I upgraded to the new movie scanner, my local subtitles quit showing up. Adding a brand new library pointed at the same folder location fixed the problem. A few weeks later, it decided that my mp4 files were in an unknown container. These files would either transcode or outright refuse to play. Once again I added a new library pointed at my movie folder and the problem was fixed without me making any changes to my movie files.

    I usually don’t have any problems with Plex finding a match. I always look up the movie on TMDB, copy the name and year straight from them and paste it when naming my movies files. For TV Shows the easiest way I’ve found to name them is with a program called Rename My TV Series which pulls data from TheTVDB.

    Reply
    1. otravers Post author

      Good point on automated file renaming, I added a sentence to that effect as there’s a variety of tools to do that.

      Reply
  4. Chris Ellwood

    Very interesting read, thanks. I use plex on a freenas machine, not found any major issues other than subtitles displaying a bit nicer. There is a method of install that separates the meta data (for easier backup), but I’ve not managed to make it work yet.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *