SxE to Absolute in Groovy

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
n0xew
Posts: 2
Joined: 01 Aug 2015, 13:15

SxE to Absolute in Groovy

Post by n0xew »

Hi!

First thing, thanks for this amazing software and all support that come with it!
I now come to ask for some help, just a minor thing not really an issue.

I wrote a simplified script based on your renall script, to renall files (even if I call it after every downloads completed) and after send a pushbullet notification via a personnal python script (i.e. send_pushbullet.py at the end).
The small issue I'm having is : 1) how can I convert my SxE from parseEpisodeNumber() to an absolute format and store it in a string?
And also :2) how can I get the episode's name into a string?

Less important but an answer would be nice too, I had real difficulties finding which method are availables for groovy scripts, is there any link to a complete doc?

Thanks in advance!

Here's my call :

Code: Select all

java -jar filebot.jar -script D:/Downloads/Torrents/automation/filebot_scripts/rename_move.groovy D:/Downloads/Torrents/Series/ --format "D:/Video/Series/{n}{'/Season '+s}/{n.space('.')}.{'S'+s.pad(2)}.{'E'+e.pad(2)}.{t.space('.')}.{vf}.{vc}.{ac}{'-'n.findMatch(group) ? null : group}" -non-strict --db TheTVDB
And here is my script :

Code: Select all

def target = tryQuietly{ target } ?: 'file'
def byfile = tryQuietly{ byfile.toBoolean() }

def name = ''' '''
args.eachMediaFolder {
	name = detectSeriesName(it)+' ' + parseEpisodeNumber(it) + ' - ' + (getMediaInfo(file:it, format:'({vf})'))
	if (it.isDisk()) {
		return rename(file:it) // rename disk folders instead of files regardless of mode
	}
	
	switch(target) {
		case 'file'   :   return byfile ? it.listFiles().findAll{ it.isVideo() || it.isSubtitle() }.findResults{ rename(file:it) } : rename(folder:it) // rename files within each folder
		case 'folder' :   return rename(file:it)   // rename folders as if they were files
	}
}
"C:/Python26/python.exe D:/Downloads/Torrents/automation/send_pushbullet.py Filebot \"${name}\"".execute()
User avatar
rednoah
The Source
Posts: 23953
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: SxE to Absolute in Groovy

Post by rednoah »

1.
You can't. Unless you mean 1x01 -> 101 then it's as easy as removing 'x'. You can only parse information from that filename that's in the filename.

2.
IF xattr is enabled & working then you can get all episode metadata via getMediaInfo (absolute, sxe, e, t, etc). Naturally this will only work AFTER FileBot has successfully renamed and SET the xattr metadata.

You can't parse the episode title from the filename.
:idea: Please read the FAQ and How to Request Help.
n0xew
Posts: 2
Joined: 01 Aug 2015, 13:15

Re: SxE to Absolute in Groovy

Post by n0xew »

Thanks for the quick answer!

1) Well I did this, quite dirty but I think it should work for most of my needs :

Code: Select all

def episode_number = parseEpisodeNumber(it).toString().replaceAll('x', 'E')
	if (episode_number.length() < 5){
		episode_number = 'S0' + episode_number 
	}else{
		episode_number = 'S' + episode_number
	}
2) ...I'm not quite eased with groovy, so how can I fetch the renamed file? And in my code how can I do do it so that it doesn't return this line but iterate with a loop so that I can integrates other code lines? Sorry, really not easily understanding groovy!
User avatar
rednoah
The Source
Posts: 23953
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: SxE to Absolute in Groovy

Post by rednoah »

Something like this:

Code: Select all

def files = rename(...)
files.each{
    println getMediaInfo(file:it, format:'''{n}_{sxe}_{t}''')
}
:idea: Please read the FAQ and How to Request Help.
Post Reply