I’m new to python… Pretty much only know the basics.
Anyways… I’m trying to get plex to update just the series, when a show finishes downloading. I played with it for 5 hours…trying different ways… Only to realize Sonarr wouldn’t execute “subprocess.call()”, or os.system.
No errors show up in sonarrs log, the file gets created, with the command that looks right (If I run it in a dos prompt, it’ll scan). But it won’t scan by itself.
I’ve also tried to dumb it down… I made a .bat file with the command “C:\PROGRA~2\Plex\PLEXME~1\PLEXME~2.EXE --scan --refresh --section 02 --directory c:\blahblahtvshow” It runs in dos… However if I make a very simple:
import os
import sys
import logging
import subprocess
test="d:\\Newsgroups\\scripts\\newfile.bat"
subprocess.call([test])
Sonarr still will not execute the .bat file… However if I open it with python, again it works perfectly.
Am I going about it the wrong way? Or is it a bug / limitation, etc? Banging my head against the wall… I don’t think I have the patience for programming ;p
Doesn’t work for me. I use a pooling software…(15 HD’s, 50+ TB), And anytime a new show is added, even with partial scans… Plex will update the whole library… which as you can imagine, takes a long time.
Narrowed it down… the error is from plex media scanner… “[“Error: Section doesn’t exist.\r\n”, ‘\r\n’” Even though it does. It’ll run in a bat… but when trying to do it automatically through sonar, it wont work for some reason.
Hmm… Drivebender is what I’m using, but it scans it all.
Are you sure on the PMS version #? I have 0.9.12… Cant find 0.9.13 posted anywhere.
I do have partial scan selected… also had library automatically though. I’ll try with just run partial.
I also found out why plex was having issues. It seems when Sonarr is running as a windows service… it won’t execute files. I disabled the service, opened the exe, and now it works with plex. Though, if partial scan works… of course I’d prefer that, so I’ll give it a try.
[Edit] I was mistaken… I did only have partial scan checked. And no, everytime sonarr tells it I have a new episode, it begins to scan my whole library.
Sorry, not 0.9.13.0, I meant 0.9.12.13 - the latest is currently: 0.9.12.13.1464-4ccd2ca, there might be an earlier release that also works, but that one does have it for sure.
If you turn on trace logs in Sonarr you will see the responses from Plex, which will indicate whether it found the series in a section and if it will be doing a partial or full scan of the section.
lordjynx7h
ikarazu:
C:\PROGRA~2\Plex\PLEXME~1\PLEXME~2.EXE
OP related - you need ‘\’ in python. '' is an escape character for python.
LJ
Surprisingly, it still worked. I fixed it just to be sure, but the problem wasn't executing plex... it was plex not accepting the arguments, or acting like it didn't get them.
I did manage to get it to work, though.
import os
import subprocess
import sys
# command to call
cmd = os.path.join(r"C:\Program Files (x86)\Plex\Plex Media Server",
"Plex Media Scanner.exe")
# get first argument passed to script
arg = os.environ.get('Sonarr_Series_Path')
# convert first character of argument to upper case
arg = arg[0].upper() + arg[1:]
# call the new command
subprocess.call([cmd, "--scan", "--section", "02", "--directory", arg])
I was ready to give up, then had a friend re-send me the script I used to use for mp3s and Sabnzbd…noticed it looked mighty familiar, so I changed it around and bit… and what do you know, it worked.
I realize it’s almost a year old… but has something changed? I thought if sonarr triggers a scan, it’ll re-scan the whole category (IE: All TV shows).
I’ve tried to have sonarr not integrate with plex at all… had update library automatically, and run partial scan turned on, but it always re-scanned the whole thing again.
It may be something to do with my specific setup… I don’t know. I’m happy with this little script though… And glad custom scripts are being supported now, I’ve been waiting / hoping for this for a long time, So thanks for all the work on adding it!