Page 1 of 1
Post-Processing script -> Refresh Plex
Posted: 03 Dec 2023, 17:11
by FTW
Hi, is there a way to mod this script to do only Partial Scan (Scan only the movie/serie folder instead of the whole directory)
here a great web site explaining how the Parti-Scan work
https://www.plexopedia.com/plex-media-s ... n-partial/
and you can find PlexNotify.bash script from this github
https://github.com/RandomNinjaAtk/arr-s ... otify.bash for Radarr that work pretty good to asking Plex to scan only the movie/serie folder
this one for sonarr ->
https://github.com/RandomNinjaAtk/arr-s ... otify.bash
I don't know how to incorporate myself this script in Filebot

that's why I am coming here asking to you if you can update your Refresh plex to do Partial Scan that would reduce a lot of useless scan from Plex that could create Sqlite3: Sleeping for 200ms to retry busy DB. issue with Plex if there a lot of folder to scan
Thank you
Best Regards

Re: Post-Processing script -> Refresh Plex
Posted: 03 Dec 2023, 18:48
by rednoah

Are you using the GUI or the CLI?

If you already have a bash script then you could
just call that.

If you're using the
amc script then what you're asking for is
built-in behaviour. The
Custom Post-Processing Scripts › Refresh Plex example favors simplicity
(3 lines; easy to understand and modify) over complexity. The code for a partial rescan would only be legible / modifiable to developers.
Re: Post-Processing script -> Refresh Plex
Posted: 03 Dec 2023, 21:54
by FTW
1- I am using the GUI
2- the bash script are from Radarr and Sonarr, not sure it's compatible with your filebot without changing few line in it... I guess
3- well, I am looking for the partial Scan which will help refreshing only the releases we are renaming with filebot instead of trigger to refresh the whole library after every rename done. Would also be a good add-on with the AMC
Thanks
Re: Post-Processing script -> Refresh Plex
Posted: 04 Dec 2023, 07:51
by rednoah

The
amc script already
does what you are asking for by default.

If you need a post-processing script for the GUI, then something like this might work:
Groovy: Select all
def host = 'http://127.0.0.1:32400'
def auth = 'YOUR_PLEX_TOKEN'
def xml = curl "${host}/library/sections", 'X-Plex-Token':auth
def libraryRoot = [:].withDefault{ [] }
xml.'Directory'.'Location'.collect{ location ->
def key = location.'..'.'@key'.text()
def path = location.'@path'.text()
def root = path.split(/[\\\/]/).last()
libraryRoot[root] += [key: key, path: path]
}
def requests = [] as Set
args.collect{ f -> f.dir.path.split(/[\\\/]/).tail() }.unique().each{ components ->
components.eachWithIndex{ c, i ->
libraryRoot[c].each{ r ->
def sectionKey = r.key
def remotePath = r.path
// scan specific library path
if (i < components.size() - 1) {
remotePath += '/' + components[i+1..-1].join('/')
}
requests += "${host}/library/sections/${sectionKey}/refresh".toURL(path:remotePath)
}
}
}
requests.each{ url ->
curl url, 'X-Plex-Token':auth
}
Re: Post-Processing script -> Refresh Plex
Posted: 04 Dec 2023, 19:32
by FTW
oh yeah nice, thanks a lot
going to test it
is there any logs that can show me if it work now not?
Re: Post-Processing script -> Refresh Plex
Posted: 04 Dec 2023, 19:45
by FTW
also is there a script to 'Clean' the folder from the source path after successfully import (with the GUI)
I know for the AMC is --def clean=y but looking for the GUI
I love this new addon of Post Process script! nice work
can't wait to try the Duplicate script too

Re: Post-Processing script -> Refresh Plex
Posted: 04 Dec 2023, 20:22
by rednoah
FTW wrote: ↑04 Dec 2023, 19:32
is there any logs that can show me if it work now not?
You will see logs in Plex for each refresh request.
FTW wrote: ↑04 Dec 2023, 19:45
also is there a script to 'Clean' the folder from the source path after successfully import (with the GUI)
No, but you can write your own script. Deleting files is easy. Just make sure you don't accidentally delete the wrong files. The
Custom Post-Processing Scripts › Delete duplicates example gives gives you all the building blocks you need.

The GUI notably uses an equivalent of
--apply prune by default to auto-delete left-behind empty folders.
Re: Post-Processing script -> Refresh Plex
Posted: 06 Dec 2023, 09:12
by FTW
okk thanks
