Advice on Automation

Any questions? Need some help?
Post Reply
dseto
Posts: 9
Joined: 26 Dec 2015, 13:24

Advice on Automation

Post by dseto »

I am working to setup automation for 3 folders (k:\movies\hd, k:\movies\uhd, k:\movies\webdl) I have Radarr setup to download to each folder based on the radarr quality profile, but i just don't like the naming convention of radarr for the actual file. so i go back and manually run file bot on new files with a preset i have for each, but the format expression is long and not sure the best way or if it is realistic.



example;
k:\movies\webdl\

webdl format expression:

Code: Select all

{n} ({y}) - {any{hd}{'HD'}} - {vs} - {vf} - {mbps} - {video[0].'framerate'} - {any{hdr}{'SDR - 8'}} - {aco} - {((audio[0].'BitRate' as float) / 1e6).round()} Mbps
example;
k:\movies\hd\

hd format expression;

Code: Select all

{n} ({y}) - {"HD - BluRay"} - {vf} - {mbps} - {video[0].'framerate'} - {"SDR - 8"} - {aco} - {((audio[0].'BitRate' as float) / 1e6).round()} Mbps
example;
k:\movies\uhd\

uhd format expression; (This one is pretty long, I don't recall the reason this one is longer)

Code: Select all

{n} ({y}) - {"UHD - BluRay"} - {vf} - {mbps} - {video[0].'framerate'} - {HDR} - { any{video[0].MaxCLL.replace('cd/m2','nits')}{'1000 nits'} } - 

{def preferredLang = 'Eng'; 
def filter = { [it.codec,] }; 
def codecList = [

'PCM' : 'PCM',
'AC 3' : 'AC3',
'Dolby Digital' : 'Dolby Digital',
'AC 3 Dep' : 'Dolby TrueHD with Dolby Atmos',
'E AC 3' : 'Dolby TrueHD with Dolby Atmos',
'E AC 3 JOC' : 'Dolby TrueHD with Dolby Atmos',
'AC 3 Dep JOC' : 'Dolby TrueHD with Dolby Atmos',
'DTS' : 'DTS-HD Master Audio',
'DTS ES' : 'DTS-HD Master Audio',
'DTS ES XXCH' : 'DTS-HD Master Audio',
'DTS XBR' : 'DTS-HD Master Audio',
'DTS ES XBR' : 'DTS-HD Master Audio',
'DTS XBR AC 3' : 'DTS-HD Master Audio',
'DTS ES XXCH XBR' : 'DTS-HD Master Audio',
'DTS XLL' : 'DTS-HD Master Audio',
'DTS ES XLL' : 'DTS-HD Master Audio',
'DTS ES XLL AC 3' : 'DTS-HD Master Audio',
'DTS ES XXCH XLL' : 'DTS-HD Master Audio',
'DTS-HD Master Audio' : 'DTS-HD Master Audio',
'DTS XLL X' : 'DTS X',
'MLP FBA' : 'Dolby TrueHD with Dolby Atmos',
'MLP FBA 16 ch' : 'Dolby TrueHD with Dolby Atmos',
'AC 3 MLP FBA 16 ch' : 'Dolby TrueHD with Dolby Atmos',
]; 

def audioStreams = []
		def audioClean = { it.replaceAll(/\p{Punct}/, ' ') }
		def channelClean = { it.replaceAll(/Debug.+|Object\sBased\s?\/?|(\d+)?\sobjects\s\/\s|0.(?=\d.\d)|20/).replaceAll(/6.0/,'5.1').replaceAll(/8.0/,'7.1') }
		def listStream = { it.sort{ a, b -> b.bitrate <=> a.bitrate }.collect{ filter(it) }.unique()*.join(' ') }
		def oneStream = { listStream(it)[0] }
		def dString = { it.toDouble().toString() }
		def toInt = { it.toInteger() }

		any{audio.collect{ au ->
			def codec = audioClean(any{ au['CodecID/Hint'] }{ au['Format'] })
			def format_profile = any{ audioClean(au['Format_AdditionalFeatures'])}{}
			def String ch = any{ channelClean(au.ChannelPositionsString2).tokenize('\\/')*.toDouble().sum() }
				{ channelClean(au.ChannelLayout_Original).split().collect{ it == 'LFE' ? 0.1 : 1 }.sum() }
				{ channelClean(dString(au.ChannelsOriginal)) } { channelClean(dString(au.Channels)) }
			def combined = allOf{codec}{format_profile}.join(' ')

			audioStreams << ['index' : codecList.findIndexOf { it.key == combined }, 'default' : any {au['default'][0].toBoolean() }{ audio.size == 1 ? true : '' },
			'codec' : codecList.get(combined, 'Add "' + combined + '" to codecList'), 'combined' : combined, 'ch' : ch,
			'bitrate' : any{ toInt(au.BitRate) }{ toInt(au.BitRate_Maximum) }{ au.FrameRate.toDouble() }{null}, 'lang' : any{ au.'LanguageString2'.upper() }{null} ]
		}

			def addToList = audioStreams.codec.findAll{ it.contains('to codecList') }.unique().sort()
			any{addToList}{( audioStreams.findAll{ it.lang == preferredLang }.sort{ a, b -> b.bitrate <=> a.bitrate } + audioStreams.findAll{ it.bitrate == audioStreams.bitrate.max() }.sort{ a, b -> b.default <=> a.default }.unique{ it.bitrate } ).unique{ it.lang }.unique{ it.codec }.collect{ filter(it) }*.join(' ').join(' & ')}
		}{'NO_AUDIO'}
} - 
		
		
{((audio[0].'BitRate' as float) / 1e6).round()} Mbps
User avatar
rednoah
The Source
Posts: 23056
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Advice on Automation

Post by rednoah »

:?: Do you mean to unify your 3 formats into one single smarter format that will give you the target file path you want depending on the file at hand?


:?: Do you mean to use the filebot command-line tool and then set up some sort of automation to rename files in the above given folders as part of a scheduled task?




:arrow: My general advice would be to not rename away / move away files from under the "owner" (e.g. Plex, Radarr, etc) that relies on files being where they're supposed to be. I'd use FileBot to hardlink (i.e. have the same file twice or multiple times at different file paths) the files into a new pristine structure that matches your preferences, and keep the original files untouched as they are at the same time.
:idea: Please read the FAQ and How to Request Help.
dseto
Posts: 9
Joined: 26 Dec 2015, 13:24

Re: Advice on Automation

Post by dseto »

Thanks for the feedback , that is helpful. Once Radarr finishes it does delete from radarr, i don't index all movies in the pooled folder. it is the only way i can do multi versions, without running more than one instance of radarr, not sure this is the best way, just the only way i have found, as radarr deletes upon upgrade vs. leaving the old file.

yes to the second, rename new files in a folder as a task, i am just a little confused as I have 3 different folders, with 3 different formats. I maybe just over thinking it.
User avatar
rednoah
The Source
Posts: 23056
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Advice on Automation

Post by rednoah »

dseto wrote: 02 May 2024, 17:21 yes to the second, rename new files in a folder as a task, i am just a little confused as I have 3 different folders, with 3 different formats. I maybe just over thinking it.
You'd just have 3 slightly different filebot commands, one for each input folder / custom format.


e.g.

Shell: Select all

filebot -rename -r "k:\movies\webdl" --db TheMovieDB --format "{n} ({y}) - {any{hd}{'HD'}} - {vs} - {vf} - {mbps} - {video[0].'framerate'} - {any{hdr}{'SDR - 8'}} - {aco} - {((audio[0].'BitRate' as float) / 1e6).round()} Mbps"
:!: NOTE: This example does not solve the "only process not yet processed files" problem (this is a separate topic; there are many ways to go about it; using --output to move files to another folder is one; How do I process only specific kinds of files? has some ideas too)
:idea: Please read the FAQ and How to Request Help.
dseto
Posts: 9
Joined: 26 Dec 2015, 13:24

Re: Advice on Automation

Post by dseto »

Thank you so much for the advice, and sorry i didn't do a better job of sharing the details of the plex server originally (Windows 10). to share; when Radarr downloads, it went to a folder that was not monitored on plex, i only did this to safe guard when someone share a file, and labels it for something, but it is actually something adult related, i only had this happen a couple of times , but it was enough i didn't want friends or family have one of there kids see that. so based on this attempt to setup some automation, I still have the final destination set up as previously mentioned for the 3 quality types, but created 3 download folders for each, that radarr will download, i have manually tested filebot, to rename files in each folder type and then move according to the final folder.

my last thing to learn is how to have filebot monitor those 3 radarr folders, then rename based on the format and move files to destination folder.


Radarr 3 download folders

k:\radarr webdl\
k:\radarr hd\
k:\radarr uhd\

monitor and rename base on each of the three format expressions, then move to final folder plex will then scan and add to libabray

k:\movies\webdl\
k:\movies\hd\
k:movies\uhd\
User avatar
rednoah
The Source
Posts: 23056
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Advice on Automation

Post by rednoah »

The command above does what you need. You'll have to create one command for each input folder / custom format. The custom format can be read from an external file to avoid complexity on the command-line. You'll also want to add --output to move / rename files into a different target folder.


e.g.

Shell: Select all

filebot -rename -r "k:\radarr\webdl" --output "k:\movies\webdl" --db TheMovieDB --format "k:\webdl.format.groovy"

filebot itself does not monitor folders for changes. How do I monitor a folder and call filebot on newly added files? will teach you how you can monitor a folder for changes on Windows. You'll want to write a PowerShell script that monitors for changes and then calls filebot as needed.
:idea: Please read the FAQ and How to Request Help.
dseto
Posts: 9
Joined: 26 Dec 2015, 13:24

Re: Advice on Automation

Post by dseto »

Thanks for all the support, I have created the format.groovy for each of the three, and decided to create a .bat file for each of the three as well to run the command line. Many different options for Windows 10 to monitor the folders and call the .bat, I have found that Watch 4 Folder to be the quickest to call the .bat's, without having to do a lot of programing, I will still dig in to see if i can learn how to create \use the FileSytemWatcher and Watcher.ps1

Thanks again for all the help!
Post Reply