export processed files in json format

Running FileBot from the console, Groovy / FileBot scripting, shell scripts, etc
Post Reply
robfbot
Posts: 9
Joined: 03 Oct 2018, 12:00

export processed files in json format

Post by robfbot »

Is there any way to export the log of files that were just processed in JSON format?

I want to connect my CLI script to feed another script which logs the information.
User avatar
rednoah
The Source
Posts: 19917
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: export processed files in json format

Post by rednoah »

What kind of information are you looking for specifically?

* the console output is generally just line-by-line human-readable and there's no machine-readable option for log files
:idea: Please read the FAQ and How to Request Help.
robfbot
Posts: 9
Joined: 03 Oct 2018, 12:00

Re: export processed files in json format

Post by robfbot »

well the more information the better really. Just a list of the items renamed would be good but ideally, having file name, tvdb id, seperated episode/season etc. etc.
User avatar
rednoah
The Source
Posts: 19917
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: export processed files in json format

Post by rednoah »

After processing files with FileBot, completely unrelated to logging, you'll be able to read episode / movie metadata from xattr:
viewtopic.php?f=3&t=324

e.g.

Code: Select all

filebot -script fn:xattr /path/to/files
:idea: Please read the FAQ and How to Request Help.
robfbot
Posts: 9
Joined: 03 Oct 2018, 12:00

Re: export processed files in json format

Post by robfbot »

yeah i saw that one. But i only want the data of the most recently run rename script.
User avatar
rednoah
The Source
Posts: 19917
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: export processed files in json format

Post by rednoah »

You can have your own post-process script do things, whatever these things may be:

Code: Select all

-exec /path/to/doSomething.sh {f} {json}
doSomething.sh

Code: Select all

#!/bin/sh -xu
echo "FILE: $1"
echo "META: $2"
:idea: viewtopic.php?f=4&t=5047
:idea: Please read the FAQ and How to Request Help.
robfbot
Posts: 9
Joined: 03 Oct 2018, 12:00

Re: export processed files in json format

Post by robfbot »

thats bloody perfect.

cheers mate.
robfbot
Posts: 9
Joined: 03 Oct 2018, 12:00

Re: export processed files in json format

Post by robfbot »

Sorry mate one last thing.
Is there any way to get the number of processed files (other than working it out from the json output etc. within the script?)

Or better yet, is there are reference anywhere of all the output options that can be parsed to the script? f.whatever ?
User avatar
rednoah
The Source
Posts: 19917
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: export processed files in json format

Post by rednoah »

1.
You could use [+] to make -exec combine all arguments into a single call, so the number of arguments will be the number of files processed:

Code: Select all

-exec /path/to/doSomething.sh {f} +
or

Code: Select all

-exec /path/to/doSomething.sh "{f} | {json}" +
:idea: In this case, it's probably easier to read the json metadata from each file in the script, so you don't have to interpret arguments in some complicated way. I'm using | here because it's typically not allowed in file paths.


2.
I've added some docs on how to navigate references here:
viewtopic.php?f=9&t=10824
:idea: Please read the FAQ and How to Request Help.
Post Reply