I guess I could say that all of my plugin parts that are "mis-behaved" are because the framework is "mis-behaved"... I do try to do things right, and when I can't I start to be a little more creative. I came to this forum to make sure there wasn't a "proper" way to do these things.
The copying thing is simply so the end-user doesn't have to copy the scanner file into scanner bundle. There is no other way, to my understanding, for a bundle/plugin to add a new scanner. Everyone has to manually copy this file into the appropriate directory.
Being able for the scanner to read Prefs and persistent Data seems well-behaved, but there is no standard way to do that as those modules are unavailable to scanners. Although I was only planning to use persistent data for a "Turbo Scan" which isn't going to happen anyways.
The external database of music files is generated by another program but I want to make it accessible via Plex. It is not maintaining a database, simply reading it. This is how Plex normally operates - it reads the filesystem and periodically looks for changes. I am just looking in a database instead of filesystem.
For the Turbo vs Deep scan, I simply wanted my Virtual scanner to take advantage of this fact. If the Scan method was called in "Turbo" mode I would be able to skip adding most media files or something similar and thus speed up the scanner and the resulting matching of media/Agent processing. I wasn't looking to change how it worked for other scanners, but had a very nice setup for my own scanner. If there is no difference and only "Deep Scans" are ever done, then I will always return the complete set of media objects.
My understanding of how the scanner and agent work together are as follows:
- The specific scanner script generates a list of Media objects, each with basic information about the media
- The overall scanner program takes the list and saves it (presumably serializes the object)
- The main framework loads the list (presumably deserializes)
- Each item is matched against items already in the database, and if it has never been seen before is sent to the Agent
- The Agent receives a Media object with basic information and creates a new ObjectContainer with corrected/complete information about the media
So, I was thinking that if I saved a Media object with an extra attribute that by the time it got to the Agent it would still have that extra attribute. Most Agents would ignore that extra attribute and not use it was trying to find the corrected/complete attribute. However I could make an Agent that would check for that extra attribute and use it as necessary (with a fallback if it isn't there). This extra attribute would never show up in the final ObjectContainer, no other Agents would have to be aware of it, and the Agent would not be doing the serialization/deserialization - the Framework presumably already does it.
I am not a haphazard coder. I do write "well-behaved" code and try not to do things that shouldn't be done. Everything I want to do seems like it should be possible (installing a scanner non-manually, access to minimal Framework functions from scanner, reading an external file/database that the user directly pointed to, take advantage of modes other scanners used to be able to, and sending one additional int from scanner to agent). If you would also like to know, I try to trap all my exceptions and check return values...