I am trying to Scan/Refresh a single directory under my TV section “programmatically”. From looking at the documentation, there appears to be 2 options to interact with the Plex Media Scanner (Command Line or Server URL Commands). Based on the examples provided by Plex Support, the following Command Line should accomplish this:
/path/to/Plex\ Media\ Scanner --scan --refresh --section 2 -d /media/tv/show1
However, issuing this command on a Plex Home Server via Command Line errors with “Error: Section doesn’t exist.”
I believe this is because interaction with a Plex Home Server instance requires an authentication token (X-Plex-Token) to be included along with the request. However, I see no way to include this in the Command Line documentation.
So my question is…
- Can an authentication token (X-Plex-Token) be included in a Command Line request? If so, what is the syntax?
- Alternately if using URL Commands (http://127.0.0.1:32400/library/sections/2/refresh?X-Plex-Token=XxXxXxXxXxXxXxXxXx), is there a way to specify a directory under the section to scan/refresh using URL Commands?
Any help would be greatly appreciated.
did you do the --list command first to see which section your tv shows are? it will probably be a different # for you
"C:\Program Files (x86)\Plex\Plex Media Server\Plex Media Scanner.exe" --list
also this is what works for me on directory
“C:\Program Files (x86)\Plex\Plex Media Server\Plex Media Scanner.exe” --verbose --scan --refresh --section 1 --directory “C:\Media\TV Shows\Arrow”
@Kraevin
Thanks for your response. Yes, when issuing /path/to/Plex\ Media\ Scanner --list from the Command Line, no results are returned. After googling, I was able to determine this was a result of my server being in a Plex Home. This requires an authentication token (X-Plex-Token) to be sent along with every request. I was able to get a list of my Libraries/Sections via the following Plex URL Command:
http://192.x.x.x:32400/library/sections?X-Plex-Token=XxXxXxXxXxXxXxXxXx
Which returned Id=2 for my TV Library/Section. However, to the best of my knowledge the Plex URL Command interface does not support providing a directory to the scan/refresh command. Providing a directory is only documented under the Command Line interface (as in the sample you provided). My belief is that when I executed the following Command Line interface command:
/path/to/Plex\ Media\ Scanner --scan --refresh --section 2 -d /media/tv/show1
The error returned (“Error: Section doesn’t exist.”) is really a bogus error masking the real error being “Access Denied” since I didn’t include an authentication token (X-Plex-Token). Executing any command via the Command Line interface (other than --help) either returns nothing or a bogus error masking “access denied”. Therefore, that leaves me 2 options to execute a scan/refresh at a DIRECTORY level:
Passing an authentication token (X-Plex-Token) via the Command Interface (which supports providing a directory)…BUT I don’t know IF an authentication token can be passed (or the appropriate syntax).
-OR-
Using URL Commands (which support passing an authentication token (X-Plex-Token) )…BUT not sure how to provide a directory with the scan/refresh command.