I am so angry I cannot describe it. This is a warning to other uses of PMS (Plex Media Server). There is a BUG wherein when you go to add a folder to a library apparently sometimes it won’t show you the folders that are already there. It had been a while since I added a folder, so when I added a new folder (on a new hard drive, because the old hard drive was full), I didn’t see any of the old folders. I cancelled out, but then went back in. I still didn’t see the old folder list, but the function is ADD folder, so I said OK, and hit SAVE CHANGES or whatever it said. It proceeded to DELETE FROM ITS DATABASE the movies that were already in the database. It did NOT show me the old folder list when there were folders in the Movies library. It did NOT warn me AT ALL that I was about to delete folders. Basically, it just began to delete all the information I had saved for the media in the old (and now, unfortunately, deleted) directories. Once I realized what was happening – I was in shock – I clicked the three dots and cancelled the scan. That stopped the deletion process. But ALL THE WORK I spent customizing collections, sort keys, posters, etc. have been lost. Yes, I know I have a backup (every three days) but I did a lot of work, for example, today. And since I caught it in the middle of the deletion, I wasn’t sure what to do. So I could’ve tried restoring from the backup, but would’ve lost up to three day’s worth of work. I have backups for all my media, BUT I DO NOT HAVE TIMELY BACKUPS FOR THE DATABASE Plex uses. THE ONE THING I cannot back up in a timely manner is the ONE THING I LOST. You have been warned. I now have to go over each piece of media and rebuild the attributes. And since I didn’t name my movies according to the recommended convention, I lost all the FIX MATCH I did also. I am thoroughly disgusted. And, yes, I’m a relatively new user. Perhaps a more sophisticated user would not have suffered like this. BUT THE SYSTEM SHOULD PROTECT YOU FROM DELETING piles of control information. How long have computers been around? And how long have they been programmed to ask, “Are you sure you want to delete…?”. But PMS just completely wiped out all the control information for what is probably 100’s of movies. I am angry and in a state of disbelief that this could even happen. And I’m not asking a lot. PMS can look at the “old” folder list, compare it to the “new” folder list, and then compute how many media items will be “lost” due to the change, and WARN US. It does not. It should. And why weren’t the old folders shown in the list? I should have a baseball game and a football game on while copying files, and instead I’m sitting here typing this in. I am still in a state of disbelief over what PMS did…at least it didn’t delete the actual media files (which I have backed up) since they are NOT under PMS’s control.
the database doesn’t actually delete unless you optimize database, clear bundles, and empty trash… At least from what I have been told…
Unless you changed it, there are database backups which can be restored.
https://support.plex.tv/articles/202485658-restore-a-database-backed-up-via-scheduled-tasks/
Thanks for your comments. I was sure angry at the time. I have great regard for Plex (and various other utilities). But I still cannot believe it was so easy to do so much damage. I have spent hours putting most everything back the way it was. The biggest problems are non-matches (because in the beginning I did not name entries as recommended by Plex) and loss of Tags and sort keys.
I thought I was aware of the backup possibilities. When I read about that (earlier), I set it up to do the backups every three days. (There’s a checkbox in Settings.) So I figured I would lose up to the last three day’s worth of work. I deemed this unacceptable. For example, I had just added 25 new movies and set up sort keys, etc. I didn’t want to lose that. In retrospect, was this a good idea? It was a wash. Because I had interrupted it (cancelled the deletion “scan” once it occurred to me to do that; recall I was “in shock”), some of the older stuff was still there.
In actuality, according to that link, Plex maintains backups too. I did not recall this, or I did not see it initially. (Not sure which.) I may take a look now, but certainly if this ever occurs again, I will remember these backups may exist. A lot of times I read Plex documentation, and it makes me wonder about other stuff. That link was no exception. As a relative Plex neophyte, I keep saying I am going to go through all the documentation someday soon, now that I sort of know what’s going on. I have not done that yet, unfortunately.
And there is still the issue of “Are you sure you want to delete…?” that should be “fixed.” I feel the wholesale destruction of a large volume of control information merits at least some sort of warning. Make it configurable, so as not to slow down the expert. But turn it on by default and tell us how to turn it off (at our own risk). I don’t know why/how the list of folders, when adding to it, did not show the folders that were already in the list – some sort of bug I suspect that I think should be looked into. This is what caused problem #1 (so to speak), with problem #2 being the no “Are you sure…?” prompt.
I still have a number of questions about Plex. I discovered there’s a Plex Python API, so I am looking into that. It should give me more insight into what’s going on “under the hood.” Indeed, if selected video attributes are programmatically available, for instance, I no longer need some of my lost (and now poorly maintained) Tags (collections). And a good programmable interface could certainly save a lot of GUI time…
P.S. Yes, some info was retained, but I don’t understand why. For example, a movie that was “gone” and lost its sort key and my choice of poster, once restored, remembered I was not done watching it. I don’t understand why/how. (I can imagine, but it would just be speculation.)
depending on the current size of your library, you may want to start using the proper naming convention now. It’s what’s recommended. If you have a large library, using FileBot (you can find the free portable version out there), you can rename them quite quickly with minimal effort.
I have been using the recommended naming convention as of late. It really helps with recognizing the movie (and TV show), for instance. (Before Plex, I had no idea thetvdb even existed.) But changing my naming convention I lose certain “utility” I was (sort of) using. For example, the program I use to “rip” movies numbers “titles.” Sometimes there are multiple titles, all with the same time or close in time – all some version of the movie. Which to copy? (I decided a long time ago just to copy one copy of the movie, and no extras.) I was leaving the title number appended to the movie (file) name, so that if I had to get a different title, I knew which had been used already. I think the presence of the title numbers throws off the scanner for matches. (I would then manually match. I lost a lot of these matches.)
Now, if I change all these file names, won’t that break my database? I read somewhere to copy a database to another location you have to name things the same way on both systems. This tells me, like Windows Media Player, the file name (Get Info) is some sort of a primary key. If I change the name, will I lose all the control information and have to rescan? I really don’t know.
Regarding file names, for newbies: the DVD/BD likely has a copyright date (year), which I have been using of late. (See naming-conventions documentation.) There may be more than one copyright date. See also below on this.
But this gets to an important point for newcomers (if any are reading this): there are a lot of subtleties to learn. The first thing you’re going to want to do is rip something and see if you can get it to play. You’ve probably done this without reading beforehand the recommended file-naming conventions. And once a “bad match” has been found, you probably don’t know (yet) that there is a “fix match” item in a menu somewhere. And if NO match is found, you can ask for a manual match. I guess my main recommendation would be to, sure, play in the beginning, but keep in mind you want to browse the “menu system” (pencil, three dots); get a feel for what you can do when/where; and start browsing the online documentation (there’s lots of it). You are potentially shooting yourself in the foot if you go roaring in blind – and keep doing it.
Once you rename and re-scan, it will go through and re-attach the videos to the proper database entry.
For instance, I had collections setup outside of the ones that plex had. So we’ll use my “Disney Animations” collection as an example.
I went through and renamed all of my Disney movies to the proper naming convention, and it “lost” them temporarily (they became “unavailable” in plex), I did a re-scan of the library, and all the movies came back, it kept the collection information intact, and even the played vs unplayed information intact. So, no, it won’t “break” the database, but it will require a rescan once they’re all renamed properly.
That sounds great, but I wish the powers-that-be would document that that works. I am guessing my simple-minded “file name is primary key” does not work. (I can imagine some possibilities for a mechanism, but they ultimately do not explain why, when moving a server to another system, you have to use the same file names.) From a practical standpoint, do I need to concern myself with renaming all the files I just “re-FIX MATCH” again, etc.? I ask because I am never going to do what I did this last time: if the list of folders does not show up if/when I add a new folder, I will NOT apply any changes. And I will watch backups. FWIW, I have noticed some “magic” when I changed names, moved things around, whatever: I didn’t understand at the time why something worked, nor do I now.) (As an aside, maybe I can get some insight by studying that Plex Python API. That will take some time.)
You can always add your own non-canonical info at the end of the file name, after the hyphen.
It is safer to enclose this with angular brackets.
Movie Title (year) - 1080p [otherstuff].ext
(don’t break up the ‘other stuff’ block into several [bracketed] parts.
The scanner will only ignore everything inside the first bracketed block.)
The potential is there. But again, it is safer if you copy the file with the changed file name and tgrigger a library scan. Plex should recognize the file from its content and add it as a ‘version’ of the original movie.
After you have seen the ‘duplicate’ indicator appearing on the movie poster, you can remove the original file version and trigger another library update, followed by Empty Trash.
I would like to add a follow-up. I have studied quite a bit the Plex Python API. (I had been exposed to Python, but never seriously programmed in it. So the excerpts below might not be how a “power Python” programmer would do it, but it seems to work.) I ended up with some questions I cannot answer. First, I would like to share some simple code. The approach, at least for now, is to generate CSV files that I can import (link) into MS-Office. Efficiency of execution was not a goal, and it doesn’t seem to matter. (I’ve only got 358 movies added so far. anyway) Here’s the code.
is_string = 1
is_numeric = 2
is_boolean = 3
hdr = hdr_is = []
def fix_hdr(s):
return s.replace( '.' , '_' ).replace( 'video_' , 'v_' )
def out_vals(outf,vals):
sep = ''
for i,iz in enumerate( hdr_is ):
outf.write( sep )
if iz == is_string:
lr = '"'
else:
lr = ''
outf.write( lr + str( vals[i] ) + lr )
sep = ','
outf.write( '\n' )
def export_movies():
global is_string, is_numeric, is_boolean, hdr, hdr_is
hdr = [ 'sequels' , 'video.titleSort' , 'video.title' , 'vm.videoCodec' , 'vm.audioCodec' , 'vm.audioChannels' , 'vm.container' , 'vm.aspectRatio' , 'vm.videoResolution' , 'vm.width' , 'vm.height' , 'vm.videoProfile' ]
hdr_is = [ is_boolean , is_string , is_string , is_string , is_string , is_numeric , is_string , is_numeric , is_string , is_numeric , is_numeric , is_string ]
movie_is_not_in_a_series = [ 'Assault on Precinct 13' , 'Cherry 2000' , 'Taking of Pelham 123' ]
with open( 'movies.csv' , 'w' ) as outf:
out_vals( outf , map( fix_hdr , hdr ) )
cnt = 0
memtS = {}
for video in movies.search():
cnt = cnt+1
tS = video.titleSort
if tS in memtS:
print video,"titleSort ERROR 1:",memtS[ tS ]
memtS[ tS ] = video
lvm = len( video.media )
if lvm > 1:
print video,"video.media ERROR 1:",lvm
vm = video.media[0]
sequels = re.search( ' (\d+-\d+|\d+)$' , tS ) and not ( tS in movie_is_not_in_a_series )
out_vals( outf , map( eval , hdr ) )
print cnt,"movies."
hdr = hdr_is = []
export_movies()
You can almost read this even if you don’t know Python. Notice how I pull in a SINGLE VALUE for the audio codecs. I cannot figure out the “Plex Schema” for audio. I use.MKV files. These include one “video” and multiple “audio” tracks (e.g., DTS-MA, DTS 5.1, TrueHD, Dolby). Any given movie probably has more than one audio track. However, the structure of the Plex API objects, etc. (“schema”) I’ve been able to discover and use imply there is one and only one audio track per movie. I don’t get this. When I scan for movies – see code – I get the correct number of movies. Each movie gets one (1) audio codec from the objects. But the “movies” should have a “one-to-many” relationship with audio “streams” (with each stream having its own codec).
Indeed, if you look online at the object hierarchy, it would appear that an audioStreams() function should return these streams. But it always returns – an empty list! This is maddening.
Does anyone know how to get the audioStreams() function to work? Am I missing some code perhaps, and the API doesn’t diagnose that? (I’d find that hard to believe.) Is it something to do with how I access the objects? (I am still reading the Python tutorial.) Thanks for any help.
What is the purpose of these CSV files?
There is already a very similar plugin (still working, btw) which can export libraries and playlists to CSV and Excel format.
You could study its source code.
ExportTools
Never used the 3.Party PlexAPI, only the official rest api build into PMS
So clueless here…
But when said, and adding to @OttoKerner, do take a peak at ExportTools
It’s not only opensource, but also can export directly into native xlsx format as well as csv
Github link: GitHub - ukdtom/ExportTools.bundle: Export tools for Plex
And for level 6 for movies, I do export the streams:
I’ll look into this stuff just mentioned. Earlier I did browse a little, and spotted the Python Plex API. I’ve always wanted to lean Python since it became so popular, so I decided I’d try it. The reason for the CSV files was so I could just deal with a relational database; customize reports; etc. I link it to MS-Access.
I wrote somewhere in some thread here that I am new to Plex. I have not read all the online documentation. In fact, it never seems to answer the real questions I have. For example, I still cannot get dual-WAN to work the way I want it to work. I also have an odd situation with how I play Plex files locally. Before I knew about the API, I needed an easy way to segregate, for example, VC1 files. So I created a VC1 collection. Then I lost a lot of my database, and with it all that control information. (I’ve been told the information was probably still there, but I was clueless, and was already rebuilding.) In any case, now I can pull the VC1 attribute from my CSV file (one line per movie) and just generate a report. I don’t know about the average Plex user, but I have one player that can’t play VC1 files; one that cannot do DTS; etc. I have bandwidth limits on players (even though I have GB ethernet; presumably the built-in player components cannot process the bandwidth needed sometimes, so limits its ranges). NONE of them can productively do all HD audio formats because of HDCP issues (although FIRE TV does a decent job with DTS). Along these lines, I bought a popular “game console” that can play Plex. If is VERY FAST, and I am happy with it. It’s an NVIDIA. My experience with it so far is that it can pass HD formats fine (e.g., DTS-MA, TRUEHD) as long as the receiving device is HDCP 2.2-compliant. My AVR (for this player) is not. So I have a player that can support the bandwidth I want but cannot receive HD audio when plugged into my regular system. I have plugged it into a newer AVR, and it sends the signals fine, but the speakers are not in that test AVR. So if anyone knows how to get NVIDIA to send HD audio (the HD video works fine) through to a HDCP 2.0 devices, I’d love to know how. I also limit the output to 1080p, but that doesn’t bother me. 4K is overkill as far as I’m concerned.
I included the code above as a contribution to help those learning the ropes. I can see now it was a waste (but still functional for me). (Perhaps when I said I was going to do it someone could’ve told me not to bother.) I sort of wonder why there even is a Python Plex API if there are better ways to do things already. Finding and using them presents another problem. As mentioned, I stumbled upon the Python Plex API before I learned about the export utilities (see above), which I will look into, since maybe they will give me some insight into my current real question: how can I “iterate” through the audio streams “in” a movie? I’m still wondering. And if I could figure that out, I’d be done with any pressing needs. I am currently hoping those export utilities will somehow make it obvious how to figure out how to access audio streams. (That is a goal because some players can play THIS but not THAT, etc., so I just want to sort out the mess so I can say PLAY X on Y using audio codec Z. I’d put that in a report printout.)
I looked at ExportTools. And I see a lot (probably all) of what I can do with my Python code is already in ExportTools. If I knew about ExportTools, I might have used it. (Still, forcing myself to learn Python is not without merit, nor is working to understand the Plex “schema.” The Python Plex API makes it easy to grab fields, etc.)
While I did not install ExportTools, I did browse its documentation. (I’m only allowed to write to those in charge if I find errors, not if I have questions.) It LOOKS LIKE it is able (at one of the most comprehensive output levels) to show details of a video’s individual audio steams, which is my goal. But it does not show the mechanism for getting that information. If I had the mechanism , I could just patch my Python code. The Plex API objects don’t seem to always do what it would seem logically they should do. I assume it’s because I don’t understand the “schema.”
I might install ExportTools and see what I can find out. IT APPEARS that I might be able to generate a “record” for a video that would include entries for each audio stream (basically my goal). These so-called records would have variable numbers of fields (columns), depending on the video and numbers of each type of stream.
That’s how I started out, but at that time, the 3.Party Plex API wasn’t yet there, thus why I went native
ExportTools is opensource, so it’s on the github link I send you
I appreciate your comments and recognize your ID from what I’ve been reading. I am just so weary from all the research I have to do just to stream video I own. It looks like I will have to figure out the internals of ExportTools so I can figure out how to access the multiple audio streams connected with a “movie.” Even though I partially “reinvented the wheel,” I have just about everything I want and need from the automation except for how to access the various collections of streams using the Python Plex API. I assume it’s not an installation problem and not a bug – I either don’t understand how to do it in Python (yet; recall I’m just learning Python) -OR- I don’t understand how Plex’s database is set up. Based on the Python Plex API documentation, it sure looks like I should just be able to use an audioStreams() function, but it doesn’t work right (it seems to me). If I ever get this to work, I will probably remember to document it here. Unless this thread is “closed” at that time, which the interface keeps threatening.
FWIW, I installed ExportTools and at Level 6 (or maybe lower would do it; don’t care) I can see what it is doing. By default it is giving me the audio streams separated by " - ". I can work with this. (Yes, I know I can change the separator.) I would still like to be able to figure out why the Python Plex API makes it impossible (as far as I can tell) to get the same information. I have a lot to learn about Python and even Plex, so maybe that explains it. I may browse the ExportTools code to see if I can divine how to access the audio streams while using the Python Plex API, although I really don’t have a problem using ExportTools as is.
Regarding ExportTools, so far it has seemingly worked very well. I do have some observations. I first chose the CSV format. When loading it into MS-Office 2016 (which autoloads MS-Excel, although I’d ultimately use MS-Access), it has a hard time showing fields. It thinks some fields are numbers, when they’re not, etc. I switched to XLSX format, and this problem seems to have gone away. (I assume the XLSX format allows one to set attributes for columns.)
I’m not sure if I needed to do both of these, but I unchecked “Wrap lines” and set “Max lines length” to 4000. I just want all the information possible in a single field. (In an earlier CSV format, I noticed truncation that went away when I set these variables. I then switched to XLSX.)
I have a feeling I will use ExportTools and give up on the Python Plex API. That’s too bad, because this has been forcing me to learn Python. The real goal is showing what plays on various players (see earlier comments: it depends on both video codec and which audio codecs are available), whether there are subtitles (which I think will be possible from earlier reading, but not from today’s playing), etc.
Well, first of all, I’m glad you like ExportTools, and as already said, I sadly can’r help with the 3.Party API you are using, since unknown to me
Do however admire the fact, that you wanna not only learn Python, and also do hope, that the combined source code of both ExportTools, as well as your API leads to a solution for you
dane22, I thought you’d want to know this. The “Title” and “Sort title” columns are the same! (At least in my database Movies export.) I export at level 6. I have both title options unchecked – I would rather see blank or N/A if the field is empty. (A large percentage of my sort titles end in successive numbers showing original and sequels together and in proper order.)
I am using PMS Version 1.16.5.1554, but this also happened in whatever PMS version I was using before I just upgraded. This does NOT happen when I export the database using the Python Plex API, so I suspect it’s an ExportTools issue.
I use the sort title in queries, etc., so it’s an important field for me.
You found what might look like a bug