From 81afe96d4f26dbbce47069a772e6fc0cb2fb8a19 Mon Sep 17 00:00:00 2001 From: jobrien2001 Date: Tue, 27 Jun 2017 06:45:56 -0500 Subject: [PATCH] Updated Custom Post Processing Scripts (markdown) --- Custom-Post-Processing-Scripts.md | 32 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/Custom-Post-Processing-Scripts.md b/Custom-Post-Processing-Scripts.md index 865abc4..afd0139 100644 --- a/Custom-Post-Processing-Scripts.md +++ b/Custom-Post-Processing-Scripts.md @@ -58,44 +58,40 @@ Sample script to have Plex scan destination folder only and "analyze deeply" the ``` # This script will add the movie to plex and scan the destination folder (it will not scan the entire library) # C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe\PowerShell.exe -ExecutionPolicy Bypass "C:\Users\Server\Desktop\radarrcustom.ps1" - -#set log file location -$logfile = "C:\Users\Server\Desktop\radarrimport.txt" - -#Set-ExecutionPolicy Unrestricted $movie_path = $env:radarr_movie_path - +#PSQlite location +Import-Module C:\Users\Server\Desktop\scripts\PSSQLite +#set file locations +$logfile = "C:\Users\Server\Desktop\radarrimport.txt" +$database = "C:\Users\Server\AppData\Local\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" #set your plex library ID $libraryid = 0 - #If you have multiple root folders and library IDs you can set them like so -If ($movie_path -like '*Movies Release\*' ) { $libraryid = 19 } +#If ($movie_path -like '*Movies Release\*' ) { $libraryid = 19 } + #Scan the movie folder -& "C:\Program Files (x86)\Plex\Plex Media Server\Plex Media Scanner.exe" --scan --refresh --section $libraryid --directory $movie_path -write-output "C:\Program Files (x86)\Plex\Plex Media Server\Plex Media Scanner.exe --scan --refresh --section $libraryid --directory $movie_path" | add-content $logfile +& "$plexscanner" --scan --refresh --section $libraryid --directory $movie_path +write-output """$plexscanner"" --scan --refresh --section $libraryid --directory $movie_path" | add-content $logfile sleep 20 -#PSQlite needed to query the plex db -Import-Module C:\Users\Server\Desktop\scripts\PSSQLite - #Query the plex db for the item ID $likemoviepath = $movie_path + "%" -$database = "C:\Users\Server\AppData\Local\Plex Media Server\Plug-in Support\Databases\com.plexapp.plugins.library.db" $query = "SELECT mi.metadata_item_id FROM media_parts mp LEFT JOIN media_items mi on mp.media_item_id=mi.id WHERE mp.file LIKE '$likemoviepath'" $itemid = Invoke-SqliteQuery -Query $query -DataSource $database $itemid = $itemid.metadata_item_id #Analyze the ItemID -& "C:\Program Files (x86)\Plex\Plex Media Server\Plex Media Scanner.exe" --analyze --item $itemid -write-output "C:\Program Files (x86)\Plex\Plex Media Server\Plex Media Scanner.exe --analyze --item $itemid" | add-content $logfile +& "$plexscanner" --analyze --item $itemid +write-output """$plexscanner"" --analyze --item $itemid" | add-content $logfile sleep 20 #Analyze deeply the item ID -& "C:\Program Files (x86)\Plex\Plex Media Server\Plex Media Scanner.exe" --analyze-deeply --item $itemid -write-output "C:\Program Files (x86)\Plex\Plex Media Server\Plex Media Scanner.exe --analyze-deeply --item $itemid" | add-content $logfile +& "$plexscanner" --analyze-deeply --item $itemid +write-output """$plexscanner"" --analyze-deeply --item $itemid" | add-content $logfile #write-output $movie_path $likemoviepath $itemid.metadata_item_id | add-content $logfile ```