Bug: Plex scanner may ignore or destroy directory depending on contents

Server Version#: 1.32.7.7621
Player Version#: 4.108.0

Depending on the contents of a directory, plex might ignore it or actively destroy it. This behavior is very weird so I’ll provide an example (I can provide logs if requested) below.

Consider my directory:
/anime/Chivalry_of_a_Failed_Knight/Season_01 which contains:

Chivalry_of_a_Failed_Knight-S01E01, The_Worst_One_I-[Doki-Bluray-1080p].mkv
Chivalry_of_a_Failed_Knight-S01E02, The_Worst_One_II-[Doki-Bluray-1080p].mkv
Chivalry_of_a_Failed_Knight-S01E03, The_Worst_One_III-[Doki-Bluray-1080p].mkv
Chivalry_of_a_Failed_Knight-S01E04, The_Worst_One_IV-[Doki-Bluray-1080p].mkv
Chivalry_of_a_Failed_Knight-S01E05, The_Experience_of_the_Princess-[Doki-Bluray-1080p].mkv
Chivalry_of_a_Failed_Knight-S01E06, Sword_Eater_I-[Doki-Bluray-1080p].mkv
Chivalry_of_a_Failed_Knight-S01E07, Sword_Eater_II-[Doki-Bluray-1080p].mkv
Chivalry_of_a_Failed_Knight-S01E08, Sword_Eater_III-[Doki-Bluray-1080p].mkv
Chivalry_of_a_Failed_Knight-S01E09, Princess'_Vacation-[Doki-Bluray-1080p].mkv
Chivalry_of_a_Failed_Knight-S01E10, Witch_of_the_Deep_Ocean_vs_Raikiri-[Doki-Bluray-1080p].mkv
Chivalry_of_a_Failed_Knight-S01E11, Another_One-_The_Uncrowned_Sword_King_I-[Doki-Bluray-1080p].mkv
Chivalry_of_a_Failed_Knight-S01E12, Another_One-_The_Uncrowned_Sword_King_II-[Doki-Bluray-1080p].mkv

Plex will not see show this directory or the files in the library. However, if I do copy Chivalry_of_a_Failed_Knight-S01E12, Another_One-_The_Uncrowned_Sword_King_II-[Doki-Bluray-1080p].mkv into Chivalry_of_a_Failed_Knight-S01E13.mkv (so there are now 13 episodes in the directory) plex picked up on all 13 files!

If I then remove this 13th file, in the plex logs the scanner will show:

Library section 5 (Anime) will be updated because of a change in "/anime/Chivalry_of_a_Failed_Knight/Season_01/Chivalry_of_a_Failed_Knight-S01E13.mkv"

At this point (at least this time) the plex library is as one would expect, the original 12 episodes. However, if I then enter plex and tell plex to rescan the library again the entire series will be deleted. From the logs:

...
Nov 17, 2023 07:47:35.548 [140398782876472] DEBUG - Was connected to metadata item 90273, count is now 0.
Nov 17, 2023 07:47:35.549 [140398782876472] DEBUG - Destroying metadata item 90273 (Princess' Vacation)
Nov 17, 2023 07:47:35.549 [140398782876472] DEBUG - Updating deletion state for metadata item 90264, is has a dead item count of 0.
Nov 17, 2023 07:47:35.550 [140398782876472] DEBUG - Updating deletion state for metadata item 90263, is has a dead item count of 0.
Nov 17, 2023 07:47:35.550 [140398373428024] DEBUG - [LibraryTimeline] Scanner activity on section 5: 0 added, 9 deleted
Nov 17, 2023 07:47:35.551 [140398782876472] DEBUG - Deleting media item 146279.
Nov 17, 2023 07:47:35.551 [140398782876472] DEBUG - Was connected to metadata item 90274, count is now 0.
Nov 17, 2023 07:47:35.551 [140398782876472] DEBUG - Destroying metadata item 90274 (Witch of the Deep Ocean vs Raikiri)
Nov 17, 2023 07:47:35.552 [140398782876472] DEBUG - Updating deletion state for metadata item 90264, is has a dead item count of 0.
Nov 17, 2023 07:47:35.552 [140398782876472] DEBUG - Updating deletion state for metadata item 90263, is has a dead item count of 0.
Nov 17, 2023 07:47:35.553 [140398373428024] DEBUG - [LibraryTimeline] Scanner activity on section 5: 0 added, 10 deleted
Nov 17, 2023 07:47:35.553 [140398782876472] DEBUG - Deleting media item 146280.
Nov 17, 2023 07:47:35.553 [140398782876472] DEBUG - Was connected to metadata item 90275, count is now 0.
Nov 17, 2023 07:47:35.553 [140398782876472] DEBUG - Destroying metadata item 90275 (An Uncrowned Champion I)
Nov 17, 2023 07:47:35.554 [140398782876472] DEBUG - Updating deletion state for metadata item 90264, is has a dead item count of 0.
Nov 17, 2023 07:47:35.555 [140398782876472] DEBUG - Updating deletion state for metadata item 90263, is has a dead item count of 0.
Nov 17, 2023 07:47:35.555 [140398373428024] DEBUG - [LibraryTimeline] Scanner activity on section 5: 0 added, 11 deleted
Nov 17, 2023 07:47:35.555 [140398782876472] DEBUG - Deleting media item 146281.
Nov 17, 2023 07:47:35.556 [140398782876472] DEBUG - Was connected to metadata item 90276, count is now 0.
Nov 17, 2023 07:47:35.556 [140398782876472] DEBUG - Destroying metadata item 90276 (An Uncrowned Champion II)
Nov 17, 2023 07:47:35.557 [140398782876472] DEBUG - Destroying metadata item 90264 (Season 1)
Nov 17, 2023 07:47:35.557 [140398782876472] DEBUG - Destroying metadata item 90263 (Chivalry of a Failed Knight)
Nov 17, 2023 07:47:35.558 [140398373428024] DEBUG - [LibraryTimeline] Scanner activity on section 5: 0 added, 12 deleted
Nov 17, 2023 07:47:35.559 [140398373428024] DEBUG - [LibraryTimeline] Scanner activity on section 5: 0 added, 13 deleted
Nov 17, 2023 07:47:35.559 [140398373428024] DEBUG - [LibraryTimeline] Scanner activity on section 5: 0 added, 14 deleted
Nov 17, 2023 07:47:35.641 [140398782876472] DEBUG - Removing 2 directories that were left.
Nov 17, 2023 07:47:35.642 [140398782876472] DEBUG - Deleting directory [Chivalry_of_a_Failed_Knight] (7958)
Nov 17, 2023 07:47:35.676 [140398782876472] DEBUG - Deleting directory [Chivalry_of_a_Failed_Knight/Season_01] (7959)

Any help about what is going on and how to fix it would be appreciated!

As an update. If I add a blank .plexmatch to the directory, the scanner detects the change in the directory, the series is added to plex. If I then manually invoke a scan (the empty .plexmatch) files still there, the series is once more deleted.

Try with a directory named Chivalry of a Failed Knight (2015) {tmdb-67154}
And season directory as Season 01

It may be that you renamed the files several times after initial mismatches.
In this case, you will sometimes need to perform the Plex Dance with all involved video files.

P.S.: you might want to drop the comma after the episode number.
https://support.plex.tv/articles/categories/your-media/

@dane22 I do not control how things are named in this directory so this is not a viable option for me. For debugging purposes however: doing as you suggested did allow plex to detect the files even on rescans. Is there an alternative solution for this that doesn’t require renaming (as I do not control that)? I did try using a .plexmatch file with a specified tvdb id but this did not survive the rescan.

@OttoKerner The dance did not solve this issue unfortunately.

The big issue is it isn’t even showing up as unmatched, it is just not showing up. It’d be one problem if the metadata was wrong and I could match it either with a .plexmatch file or manually, but plex doesn’t even show any unmatched files.

If this is the case,

then I doubt you will even be able to perform a proper Plex Dance at all.

@OttoKerner Sorry if I was unclear; for debugging purposes I am capable of altering the directory for a short period of time so I was able to remove / edit the files / directory for the plex dance. But during normal usage, I am not in control of how things are named. But for debugging purposes, I was able to follow the instructions listed at the provided link.

If you can’t follow the naming guide https://support.plex.tv/articles/naming-and-organizing-your-tv-show-files/ then your only option is maybe this:
https://support.plex.tv/articles/plexmatch/

I did try a .plexmatch file in multiple variations. One empty, one with just tvdbid: 299506 one including the title. I also tried one in the Season_01 directory including all the above and episode information:

Title: Chivalry of a Failed Knight
Year: 2015
Season: 2
tvdbid: 299506

Episode: 01: Chivalry_of_a_Failed_Knight-S01E01, The_Worst_One_I-[Doki-Bluray-1080p].mkv

But plex will not show the episode’s existence either matched or unmatched.

The fact that it won’t show up even as unmatched and that .plexmatch doesn’t help fix this is worrysome. Is this a bug? I have logs if desired.

Bad contents!

Title: Chivalry of a Failed Knight
Year: 2015
tmdbid: 67154

Put above in the show directory

Filter for duplicate episodes, then inspect the Plex media info of these, if found.

@dane22 I tried the .plexmatch you suggested in the show directory, the show briefly appeared but did not survive the rescan. After the rescan, once more, the show does not show up anywhere, matched, unmatched, or as a duplicate for something else. It’s just not there.

@OttoKerner This is a really useful feature! It helped me remove a duplicate from a different show. Thanks!

Unfortunately, I now have 0 duplicates in the library, so it does not seem to be this. :frowning:

This is a bug, correct? It is not intended? It should show up as something no matter what, even if unmatched; the fact that it is not appearing in any capacity is a bug?

I suggest proper naming. When named properly, it just works.
Note: Anime is tough to match. Using TheTVDB ID takes all the guesswork out of it and PMS does not miss.

Here is a dummy file set I just created

[chuck@lizum ~.1990]$ ls -la /glock/qa/tv/Chivalry\ of\ a\ Failed\ Knight\ \{thetvdb\:\ 299506\}/
total 60
drwxr-xr-x   3 chuck chuck    31 Nov 20 20:12 ./
drwxr-xr-x 966 chuck chuck 32768 Nov 20 20:12 ../
drwxr-xr-x   2 chuck chuck  4096 Nov 20 20:12 Season 01/
[chuck@lizum ~.1991]$ ls -la /glock/qa/tv/Chivalry\ of\ a\ Failed\ Knight\ \{thetvdb\:\ 299506\}/Season\ 01/
total 44
drwxr-xr-x 2 chuck chuck 4096 Nov 20 20:12 ./
drwxr-xr-x 3 chuck chuck   31 Nov 20 20:12 ../
-rw-r--r-- 1 chuck chuck  338 Nov 20 20:12 Chivalry of a Failed Knight {thetvdb: 299506} - S01E01.mkv
-rw-r--r-- 1 chuck chuck  338 Nov 20 20:12 Chivalry of a Failed Knight {thetvdb: 299506} - S01E02.mkv
-rw-r--r-- 1 chuck chuck  338 Nov 20 20:12 Chivalry of a Failed Knight {thetvdb: 299506} - S01E03.mkv
-rw-r--r-- 1 chuck chuck  338 Nov 20 20:12 Chivalry of a Failed Knight {thetvdb: 299506} - S01E04.mkv
-rw-r--r-- 1 chuck chuck  338 Nov 20 20:12 Chivalry of a Failed Knight {thetvdb: 299506} - S01E05.mkv
-rw-r--r-- 1 chuck chuck  338 Nov 20 20:12 Chivalry of a Failed Knight {thetvdb: 299506} - S01E06.mkv
-rw-r--r-- 1 chuck chuck  338 Nov 20 20:12 Chivalry of a Failed Knight {thetvdb: 299506} - S01E07.mkv
-rw-r--r-- 1 chuck chuck  338 Nov 20 20:12 Chivalry of a Failed Knight {thetvdb: 299506} - S01E08.mkv
-rw-r--r-- 1 chuck chuck  338 Nov 20 20:12 Chivalry of a Failed Knight {thetvdb: 299506} - S01E09.mkv
-rw-r--r-- 1 chuck chuck  338 Nov 20 20:12 Chivalry of a Failed Knight {thetvdb: 299506} - S01E10.mkv
[chuck@lizum ~.1992]$ 

A renaming tool (FileBot, TheRenamer, etc) really helps here to avoid these problems before they start.

Unfortunately that is not an option for me; I was hoping to correct this either with a .plexmatch file or manually in the website UI. (Side note, the name doesn’t need to be correct for it to show up and match properly, if I just name the directory Chivalry_of_a_Failed Knight instead of Chivalry_of_a_Failed_Knight it works).

The problem I have found is that these files will not appear in the library at all as if the files don’t exist, and the .plexmatch file does not match. My other concern is that (if this is a bug) I have other things that are also missing from my plex library that should be there. My library contains well over 20,000 video files and I’m now concerned about how many just are not there; it’d be one thing if they were showing up as unmatched, but they are not appearing in the library in any form as far as I can tell. Since they do not show up in the library I can’t exactly filter for ‘not showing up’ like I can unmatched. Consequently, I also couldn’t even match then manually if they failed to match. Plus my concern is if this will happen in the future without me noticing.

Also: the logs do indicate they series is correctly matching.

My concern is mostly: is this a bug? Or is there a reason it is not showing up (even as unmatched), because if the second is the case I might be able to change some setting or more easily mitigate this. If I know the reason it’s not happening (and it is intended behavior), since I cannot rename the files, I can at least try to address it in a different way. Either .plexmatch files or library settings or something else. It’d be nice to know if this is something I did wrong in configuring plex (like if there is a setting it ignore certain files) or if this is a bug; and if it is a bug, is there anything I can do to help?

May I ask how/why you cannot control the naming of the media files ?

Are you in control of media being added to your server ?

Things the scanner mistakes as a possible movie title are engineered not to show up all in a TV library and vice versa

However the scanner is mistaking this title from a correct match has possibly got roped into that

Just a guess

If you really can’t fix your naming you may have to look into a 3rd party software that will allow you to use .nfo files for matching

Most of the media I control entirely, for this particular library however I do not own the drive the content is on. I can make temporary edits but since it’s not my HDD I’m not going to make any permanent changes. Just to be clear, for my other libraries I am switching everything to use the {tvdb-} naming scheme as recommended but I discovered this issue in a library that is not off an HDD I own.