Is Threaded Plex Media Scanner support via PMS Scanner command line possible?


#1

I am certainly aware of the PlexUpdate Plugin but find it to be a very inefficient solution for updating my Plex library as it sends URL based command to re-scan the entire library every time you execute a beet import command. This can take way too much time and tie up system resources re-scanning files which haven’t been updated before scanning the desired new files.

As beets is after all a command line program shouldn’t it be possible for there to be a command line solution which will use the available Plex Media Scanner command line options which can be found at https://support.plex.tv/hc/en-us/articles/201242707-Plex-Media-Scanner-via-Command-Line and which can be used to scan new folders without re-scanning everything.

It would be fantastic first of all if when importing new files beets could initiate a PMS scan for every folder it creates as the last thing it does after adding all files to that folder. This would be a very valuable feature to me and I’m sure would be to many other users.

It would also be desirable if update, move and remove commands could also use the PMS scanner to update just the parts of the Plex database that are actually required. This could be overly ambitious to start but feel simply scanning new folders as they are processed would be a very possible idea to make happen. Both are well beyond my limited programming abilities but I am simply asking does this sound like a good idea worth pursuing and is there anyone out there who does have the ability who might also desire to see this implemented?

Although both my beets installation and my plex server reside on the same computer the actual library resides on a separate NAS drive. Both beets and Plex are configured to use the actual network path rather than a mapped network drive number. I think this would likely be required for such features to work properly.

Thanks in advance for any help in this matter.


#2

Good idea; this would certainly make the plugin better! Please feel free to file a feature request on GitHub with a detailed design. For example, a great design writeup would say stuff like “when X happens, the plugin should execute exactly the command Y.”

You alluded to this, but to reemphasize: the current HTTP API-based rescan invocation works if beets and Plex are running on different boxes, while a CLI invocation would not. So the feature would probably need to be optional, and we’d keep around the old functionality too.


#3

adrian,
Thanks for the advice.

I was thinking about creating an entirely new plugin separate from the currently available one. Primarily wanting to gauge interest in such a plugin before posting to GitHub. I’m not really ready to post to GitHub because I don’t yet know everything I would need to know to make such a detailed feature request. What I really need to do it dig into the documentation to see exactly what is actually happening when a release is imported and read all about plugin development so I can just write the thing myself.

A quick google search for “run cmd.exe on remote computer” tells me that it relatively easy to run a command on a remote computer so maybe they don’t have to be on the same system. I do think having the same path stored in both the beets database and the plex library would be helpful however.


#4

Great. Please keep this thread updated and file a GitHub ticket whenever you’re ready. This should eventually be a single plugin with an option, but feel free to start separately.

Running a command on a remote server would require establishing an SSH connection or something similar. Let’s pretty complicated, so let’s leave it out for v1.0.


#5

(It would also be worth doing a little homework to find out if there’s a (hidden) option to refresh a specific directory through the HTTP API.)


#6

I’ve certainly looked and am unaware of one. I would be nice if there was one.

I guess adding an optional ability for the existing plugin to listen for the album_imported event would be the first thing required followed by then acting on that event to trigger a scan of that folder.


#7

Either that or wait for the import command to finish and then sequentially scan any folders changed with the lib objects paths list.