Modified Movie Scanner to Exclude Names in Files

This came about because of the default scanners problems with handling certain names in files.  For example I was using 1080HP51, qHD, HD, DVD in my file names to designate information about the file for myself.  I use Serviio as well as Plex and I did not want to rename all my files specifically for Plex to be able to decode them for use with the Metadata Agents.

 

My quest first took me to the #Plex channel on IRC Freenode.  Someone was able to point me to the VideoFiles.py file as being the one that I needed to manipulate.  Changing this file, specificially, adding the terms I wanted to exclude in the "format = [" section in the beginning of the file resulted in my files being properly added and Metadata being looked up for each file.  Hurray.  However, in a few hours, those changes were overwritten.  I found out that is by design as the default scanners and such that come with Plex will be kept as they were deployed by the package.

 

Doing more research and coming to this forum I came across this thread with someone trying to do something in the same vein that I was trying:

http://forums.plexapp.com/index.php/topic/58512-how-to-overrideupdate-videofilespy/

 

Time dig into python if I wanted to solve this.  I got this working on Linux correctly as I intended and I updated the thread with my changes.

 

I wanted to help the Windows users fix this as well.  I've attached the files need to add the modified custom scanner this this post.

 

Extract the file to your Local AppData for Plex.  For myself, I had to extract it here:

C:\Users\administrator\AppData\Local\Plex Media Server\Scanners\

 

You will need to modify sys.path.append in Plex_Movie_Scanner_Custom.py and Stack.py.  It's at the beginning of the file.

 

Once this is done, Plex should pick it up (you might need to restart Plex).  You can then modify your movie section to use the new scanner called Plex_Movie_Scanner_Custom.py.

 

For myself, it would not pick up the files that had already been added to a Movie folder section.  I had to delete that Movie section, re-add it, select the Custom scanner and everything was peachy.  Hopefully this helps someone else.

 

To the Devs:  This seems like a really core piece of customizable information for a scanner.  It would be nice to have options to edit a Scanner through the PMS Web Interface.  Doing it in this manner seems very kludgey to me.

 

Edit:  Originally the file did not attach.  I've just reattached it.

I'm curious why you encountered this problem to begin with, and think something else may have been going on that merits further investigation in your setup.  All of my files and file names contain quality codes.  I use SB for TV Shows and have it set to append the quality to the end of the file automatically for example: TV Show Name - x01x02 - 720WEBL, HDTV, 1080P, DVD rip etc.  My Movie sections contain the same indicators in the file names - none of which are incorrectly matched nor does the scanner include this data in the UI.

I was actually watching what it was submitting to the agent.  99% of the time there was not a match if I had qHD in the name.  TV Shows seemed to be a lot less susceptible to different names in the files and I did not have to patch the TV Show scanner.  As for movies, there was already a lot of excludes already there in VideoFiles.py.  Such as:

source_dict = {'bluray':['bdrc','bdrip','bluray','bd','brrip','hdrip','hddvd','hddvdrip'],'cam':['cam'],'dvd':['ddc','dvdrip','dvd','r1','r3'],'retail':['retail'],
               'dtv':['dsr','dsrip','hdtv','pdtv','ppv'],'stv':['stv','tvrip'],'r5':['r5'],'screener':['bdscr','dvdscr','dvdscreener','scr','screener'],
               'svcd':['svcd'],'vcd':['vcd'],'telecine':['tc','telecine'],'telesync':['ts','telesync'],'workprint':['wp','workprint']}

audio = ['([^0-9])5\.1[ ]*ch(.)','([^0-9])5\.1([^0-9]?)','([^0-9])7\.1[ ]*ch(.)','([^0-9])7\.1([^0-9])']
subs = ['multi','multisubs']
misc = ['cd1','cd2','1cd','2cd','custom','internal','repack','read.nfo','readnfo','nfofix','proper','rerip','dubbed','subbed','extended','unrated','xxx','nfo','dvxa']
format = ['ac3','dc','divx','fragment','limited','ogg','ogm','ntsc','pal','ps3avchd','r1','r3','r5','720i','720p','1080i','1080p','x264','xvid','vorbis','aac','dts','fs','ws','1920x1080','1280x720','h264']
edition = ['dc','se'] # dc = directors cut, se = special edition
yearRx = '([\(\[\.\-])([1-2][0-9]{3})([\.\-\)\]_,+])'

So terms like 1080p, HDTV are already excluded.  If your files have different terms, then these will be passed to the agents and in all probability result in no match.

Strange, the file I uploaded does not seem to be attached to my original post.  Does the file have to approved by the moderators?

Out of curiosity, the quality tag your appending to the files, is it separated by a space or dash? Or is it connected to the name i.e., MyMoveqHD.mkv.  How exactly are you naming them?  The Plex scanners are pretty awesome at what they do, but they of course have limits, so your naming structure is going to have to fall within a certain sensible range of use.

Example:

Close_Encounters_of_the_Third_Kind_1977_HD.mkv

Close_Encounters_of_the_Third_Kind_1977_qHD.mkv

The qHD files are not matched.  I know Plex does a decent job scanning files.  But it did not match 1080HP51/1080HP20 variations either.  I'm just saying it would be good to add an exclude names under advanced in each section instead of going through the kludge that I did.

We’d be happy to improve the scanner rules, please list some full, exact filenames so we can reproduce :slight_smile:

(In addition to the one above, that is :slight_smile: )

Thanks, that would be great.  Looking at the files, I think just adding a few excludes such as HD, 1080HP51, 1080HP20, HP51, HP20, qHD, SD51, SD20, etc.  I just have the name of the movie and then a descriptive pieces on what type of video/audio contents are in the file.

Though it's really easy for you to add them to the VideoFiles.py file, I think it would be nice to be able to add them in the Advanced Dialog for the Section in general.  That way as things change,people can just add them.  Extensions I see in the future are things like: 10bit, h.265, etc.

I've been trying to setup my Custom scanner on a new installation.  Everytime I try to select the scanner, it shows "Scanner" in red then "A scanner is required."

So I'm at a bit of a loss why the Scanner won't take when selected.  My two previous installations still work correctly.  If I create a new Library and select the Custom Scanner it still works.

Is there any way to debug this.  I'm not finding anything in the logs that is standing out at me.

Is there some place to make a wish list or bug request to add the ability to Ignore/skip certain characters in a file.

I still need to exclude qHD, HD, DVD, MPEG.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.