Post-Processing script -> Refresh Plex

All your suggestions, requests and ideas for future development
Post Reply
FTW
Posts: 39
Joined: 28 Jan 2022, 09:47

Post-Processing script -> Refresh Plex

Post 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 :lol: 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 :)
User avatar
rednoah
The Source
Posts: 23469
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Post-Processing script -> Refresh Plex

Post by rednoah »

:?: Are you using the GUI or the CLI?


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


:idea: 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.
:idea: Please read the FAQ and How to Request Help.
FTW
Posts: 39
Joined: 28 Jan 2022, 09:47

Re: Post-Processing script -> Refresh Plex

Post 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
User avatar
rednoah
The Source
Posts: 23469
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Post-Processing script -> Refresh Plex

Post by rednoah »

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



:idea: 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
}
:idea: Please read the FAQ and How to Request Help.
FTW
Posts: 39
Joined: 28 Jan 2022, 09:47

Re: Post-Processing script -> Refresh Plex

Post 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?
FTW
Posts: 39
Joined: 28 Jan 2022, 09:47

Re: Post-Processing script -> Refresh Plex

Post 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 :P

can't wait to try the Duplicate script too :)
User avatar
rednoah
The Source
Posts: 23469
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Post-Processing script -> Refresh Plex

Post 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.


:idea: The GUI notably uses an equivalent of --apply prune by default to auto-delete left-behind empty folders.
:idea: Please read the FAQ and How to Request Help.
FTW
Posts: 39
Joined: 28 Jan 2022, 09:47

Re: Post-Processing script -> Refresh Plex

Post by FTW »

okk thanks :)
Post Reply