Where is the howto write a scanner document?

I need to know api type things.

I need to know what stacking is.

Well there is a document for agents and channels but the scanner is ran outside this, so it’s easier to read the python code of the scanner. You can find one here: https://support.plex.tv/hc/en-us/articles/201674343-Scanning-Disk-Image-Format-Media

I recommend however reading the code from my absolute series scanner (in signature).
I actually coded all from scratch using my functions only. It actually outputs logs in logs folder for easier troubleshooting

There is a couple of plex scanners on github otherwise:




stacking is when you have multiple parts for a single episode (xxx -part1.ext, xxx-part2.ext), it stacks them together.
The scanner is called once for root call, and once for each folder (skipped if nothing changed in the scan, but give issues if scanner crashed, as it won’t run again for that folder leading to missing media in library during development)

https://pythonhosted.org/plex/tutorial.html
This is the closest thing I have found so far.

I will also want a description of what all the includes do. and how it is called by plex… and how it interfaces with the metadata grabbers. I need to know what plex wants.

I think your scanner does logging (thank you!) so I will try to copy that…

I’ve been reading the python scripts, but the default one has so much cruft… (I thought the naming of the files was very inflexible… but looking at the default scanner (in the plugins-{variable} directory it bends over backwards to try to name the files… in a very unhelpful way at times.

I plan to just split the file name on the " - "'s
first section is series name, second section has season and episode number and any “stacking” or multiepisode notificaitons – third section is episode name, fourth and fifth sections are ignored for now.

I will have arbitrarily deep subfolders. I would also like to detect these subfolders and include them as genre information for the series.

I also want to use an index.jpg file as the folderview icon.

If the filename doesn’t fit the naming convention I don’t want to try to scan it, I will ensure that all the filenames meet the convention. I do want error logging.

I will detect folders that have files because they have the “season #” folders… all other folders are

I also need to know how it interfaces with the metadata agents.

So, I have now installed KDE4 from macports so I have a decent text editor in Kate and the kde4-baseapps gave me Dolphin so now I can navigate to the folders easier.
(finder is perhaps the crappiest file manager I have ever seen… It was bad on the AppleIIgs and worse on macintoshes… and never seems to have gotten better… my Atari ST had a better filemanager…)

So now I can look at these files:
/Applications/Plex Media Server.app/Contents/Resources/Plug-ins-5089475/System.bundle/Contents/Code/
and others to see how it interfaces… Someone who knows could probably write a few paragraphs that answers the question faster than I can read it all and be confused for a few days… but I have to solve this.

Scanner put files into plex into a serie and season with ep number. It is not changeable afterwards

Metadata agent match the serie name to an id in the search part and the update part downoad the metadata for that id.

Pretty sure my scanner would add your series files fine if it wasn’t for the deep folders.

There in an api guide for the agent but not scannerhttps://www.google.ie/url?q=/uploads/default/original/3X/c/4/c474c361f240cf9ffd7330481c995a38c7d32a5b.pdf&sa=U&ved=0ahUKEwjS-p3-57TMAhUHBMAKHW6KBGwQFggLMAA&sig2=XzWCkkNW4mxwM1PaUz7fIA&usg=AFQjCNFkjSUdxPrv5wm9-4cDk-bw3cK-

This post has some insight…

Why are the scanners and agents separate?

It looks like I might need to modify the scanner, plex, and the agent to handle nested folders.

As it is, it appears that the home videos scanner is the only one that lets all of the videos be watched in a sorted/organized manner.

Scanner only need modifying.
The issue is all eps in subfolders get put in a single serie associated with the folders directly in the library root folder.

However if you add files during the root folder scanner call and not the subfolder or series folder inside root scanner call, it’s ok.

I had it implemented in my scanner but removed it for cache issues as plex skip further acans in a folder if it was not modified, but not if you use this method… here is my last version with it supported

I’m currently playing with logging to try to debug the scanner… Since Python appears to not be super strict about types, I am confused about what many things are…
I’m working thru it… I’ll take a look at your older scanner…
We put so much effort into making the metadata be correct that I’m frustrated.

The folder view with the TV Shows is also broken, so for my client I had to import everything as a home video just to make it so he can get to his files.

Please attach the filelist generated by my scanner so i can reproduce your library

“We put so much effort into making the metadata be correct that I’m frustrated.”…
Do you have metadata on disk ? metadata is the AGENT responsability, the scanner does choose the initial serie name, season and ep number, and title for ep until replaced by the agent. initial scanner don’t bother with ep title but mine does. if you give me the file list, i cna figure out the best way forward for you

That’s a very kind offer!
I am developing test cases… using very short snips of video.

I’ve figured out that the scanner does not choose where it goes… I haven’t figured out what calls the scan function in the scanner… it gets called 7 times for a library that is like this:

TV Shows
.Veep
…Season 01
…Season 02
.Weeds
…Season 01
…Season 02
.Horror
…Benson
…Season 01
…Season 02
…Muppet Babies
…Season 01
…Season 02
…Very Scary
…MASH
…Season 01
…Season 02
…Rainbow Bright
…Season 01
…Season 02

I came up with the first shortest names of TVshows I could come up with…
The scanner never even gets called for the Very Scary folders
The idea is that the containing folders between rootRolder and the SeriesFolderName are imported as genres, and stuff in those folder after the hypen " - " are hints like language MASH - en would be mash in english MASH - fr would be in french

Horror - en would be English Horror

I’ll be looking at your scanner in just a bit again.
This is with the stock scanner… I’ve looked up how to see the calling function in Python… but it doesn’t work with the scanner… so I don’t know how plex is calling it… (I just realized I can grep the files for scanner.scan() )

Wow, I’ve installed your scanner a while ago, it worked better than the default one… but your code is much nicer than the stock scanner… (I’ve been having to learn python along the way, and I’ve learned that I hate it when people make huge if else nets with indentation making it hard to read… I’m chugging away.

You cannot assign more than one genre that way. Metadata agents can support multiple genres and you can filter by year or genres.
Use my old agent and series will be added without dumping all eps in a single serie link to the root folder like horror…
Edit a metadata agent and you can add the genre from the folder path.
Scan is called once for root and once per folder if something changes in the folder. If your scanner crash it is not gonna detevt all eps and folders

I couldn’t understand the other scanner, so convoluted coding…
Am self taught python too.
If you use notepad++ it show the identation to make it easier to read…

I’m mostly just trying to simply insert a show hard coded into the plex medialist… then I will write a simple recursive function to crawl the folders… but it looks like plex chooses what folders I look at before I get to look.

@print_caller_name(4)
def Scan(path, files, mediaList, subdirs, language=None, root=None):
logging.info(‘hi’+str(path)+str(files)+str(mediaList)+str(subdirs)+str(language)+str(root))
blasterSix=Media.Episode(‘Benson’,1,2,None, 1999)
logging.info(str(blasterSix))
blasterSix.append(’/Volumes/Yo/Media/TV Shows/Horror/Benson/Season 01/Benson - S01E02.mp4’)
mediaList.append(blasterSix)

I understand I have to write the metadata agent… is that what calls the scanner?
the scan function gets called once per folder in the root… and once for each subdir in that…
but not further.

If you look at my scanner old version, for grouped folders it does it in the first scanner call on library root folder. You can do all scan therem. Even had a version where it did scan all on root call to build a file array then loop to process it. That would help you most

I use kate from macports on OS(kick you in the balls, or your dads if you don’t have any)X kate from kubuntu or kate in windows…

It’s a bit borked in OSX but it has variable finding, indenting, and collapsing of functions and loops… it’s just great.