I’m not sure of the correct place for someone like me, who manages a smallish Plex server for family and a couple friends to share tips, tricks, or tools that have been found or developed for performing PMS tasks that are not handled by the base package. I have a small one, but I find it very useful and I’m posting it here in the hope that someone will direct it to the correct category.
Creating a Plex Media report
This is for Windows, but I suspect it will work the same on linux. The scripts require the GNU utilities grep and sed to be downloaded and installed in the path. (I also add the PMS folder to my path to make the Plex Media Scanner commands a little shorter.)
The end product is a text listing of movie/tv show titles [year] and album artists with indented album titles for each artist. I use a set of three CMD files (a master and a file for tv/movies and a file for music) to run Plex Media Scanner and post-process the output. My scripts are hard-coded to create a new report in F:\PlexMedia.txt every time it is run, obviously that would change for other installations.
The MASTER cmd file is created by manually manipulating the output from the
"Plex Media Scanner" --list
command to produce something like this:
@echo off
echo Scanning and exporting all Plex Movies, TV Shows and Music to F:\PlexMedia.txt
echo ***************************************************** > F:\PlexMedia.txt
echo Plex TV Shows >> F:\PlexMedia.txt
echo ***************************************************** >> F:\PlexMedia.txt
call PlexMovie 4 "1950s TV"
call PlexMovie 5 "1960s TV"
call PlexMovie 6 "1970s TV"
echo ***************************************************** >> F:\PlexMedia.txt
echo Plex Movies >> F:\PlexMedia.txt
echo ***************************************************** >> F:\PlexMedia.txt
call PlexMovie 11 "Movies"
echo ***************************************************** >> F:\PlexMedia.txt
echo Plex Music >> F:\PlexMedia.txt
echo ***************************************************** >> F:\PlexMedia.txt
call PlexMusic 13 "Albums"
call PlexMusic 35 "Albums (Dad's)"
call PlexMusic 36 "Christmas Albums"
echo ***************************************************** >> F:\PlexMedia.txt
echo All finished.
The names and numbers on the lines that call PlexMovie or PlexMusic come from the --list option of Plex Media Scanner and I used my favorite text editor to change that output into the master command file. I call it PlexReport.cmd
The MOVIE cmd file write the name of the library between a couple rows of equal signs as a section heading, and then all the real work is done on the last line:
echo ===================================================== >> F:\PlexMedia.txt
echo %2 >> F:\PlexMedia.txt
echo ===================================================== >> F:\PlexMedia.txt
"C:\Program Files (x86)\Plex\Plex Media Server\Plex Media Scanner" -t -c %1 | grep -E "^\*" | grep "\[" | sed "s/\*\ //g" >> F:\PlexMedia.txt
That arcane looking line asks the scanner to report info about a single library and then chooses only lines that both begin with an asterisk AND include a left square bracket (used by the scan report for move/tv show year) and then converts the asterisks to a space because I think it looks better. (smile)
The MUSIC cmd file is very similar, but also includes lines that begin with four spaces THEN an asterisk and no check is done for a bracket. Again, the asterisks are changed to spaces for my preference:
echo ===================================================== >> F:\PlexMedia.txt
echo %2 >> F:\PlexMedia.txt
echo ===================================================== >> F:\PlexMedia.txt
"C:\Program Files (x86)\Plex\Plex Media Server\Plex Media Scanner" -t -c %1 | grep -E "^(\*| \*)" | sed "s/\*\ //g" >> F:\PlexMedia.txt
When the script is run, I get a plain text output file that looks like this (but mine is quite a bit longer):
*****************************************************
Plex TV Shows
*****************************************************
=====================================================
"1950s TV"
=====================================================
The Abbott and Costello Show [1952]
Amos 'n' Andy [1951]
Boris Karloff's The Veil [1958]
The Colgate Comedy Hour [1950]
*****************************************************
Plex Movies
*****************************************************
=====================================================
"Movies"
=====================================================
4: Rise of the Silver Surfer [2007]
10 [1979]
12 Angry Men [1997]
12 Rounds [2009]
21 Grams [2004]
21 Jump Street [2012]
22 Jump Street [2014]
The 39 Steps [1935]
47 Meters Down [2017]
48 Hrs. [1982]
50 First Dates [2004]
50 Years of Star Trek [2016]
*****************************************************
Plex Music
*****************************************************
=====================================================
"Albums"
=====================================================
AAPO HAKKINEN
Medici Harpsichord Book [2006]
Aerosmith
1980-06-12 Hartford CT : Nightclubbing [1980]
Aerosmith [1973]
Draw The Line [1977]
Get Your Wings [1974]
Live! Bootleg [1993]
*****************************************************
I hope someone finds this useful and if anyone has the time and skill to automate the master cmd file generation, I would love to see it!