Sonarr version (exact version):
Mono version (if Sonarr is not running on Windows):
OS:
Debug logs:
Description of issue:
Hey Guys -
I have a fairly large library which includes almost 1,000 series that I host for home use on Plex and manage wirth Sonarr. Although I’ve enabled the Plex option to only perform partial scanning when updating libraries, it still takes much longer than it should. Therefore, I’m playing around with a script which initiates scanning on the path an episode was added to using Plex Media Scanner and Sonarr variables. Something still doesn’t seem to work exactly right and I can’t put my finger on it yet.
Below is the current version of the PowerShell script. Before using it, I wanted to get any opinions or suggestions for it. It’s based off an example I saw a while back yet also adds support for updating two different TV Show libraries as you will see.
#Wait 30 seconds before starting
sleep -s 30
# Define Variables
$tvseriespath = $env:sonarr_series_path
$episodepath = $env:sonarr_episodefile_path
$seriestitle = $env:sonarr_series_title
$plexdatafolderroot = "E:\Plex Media Server Cache"
$database = "$plexdatafolderroot\Plex Media Server\Plug-in Support\Databases\com.plexapp.plugins.library.db"
$plexscanner = "C:\Program Files (x86)\Plex\Plex Media Server\Plex Media Scanner.exe"
$logfile = "D:\- Log Files -\Sonarr\SonarrPlexScan.log"
$tvmain = "*TV Shows\*"
$tvchild = "*Children's Shows\*"
#Determine Plex Library to Update
# Set to Main TV Path (1) if path from Sonarr matches else set library ID to Children's Shows (23)
If ($episodepath -like $tvmain ) { $libraryid = 1 }
If ($episodepath -like $tvchild ) { $libraryid = 23 }
#Execute Library Scan for Show Path
& "$plexscanner" --scan --refresh --section $libraryid --directory $sonarr_series_path
write-output "$seriestitle" "$testepisodepath" "$libraryid" | add-content $logfile
Any suggestions? Thanks