Validating format files

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
devster
Posts: 417
Joined: 06 Jun 2017, 22:56

Validating format files

Post by devster »

I was wondering if there's a way to only validate format files? An equivalent of:

Code: Select all

$ visudo -cf file
file: parsed OK
$ echo $?
0
for format files, something like:

Code: Select all

$ filebot -script fn:validate formatFile.groovy
OR
$ filebot -validate formatFile.groovy
I only work in black and sometimes very, very dark grey. (Batman)
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Validating format files

Post by rednoah »

You can probably do filebot -list like what you're doing in your other thread and then check the output. We could in theory check for syntax errors ahead-of-time, but checking for runtime errors requires test runs. Some runtime errors may be specific to the code path taken. You are probably interested in the latter.


:idea: You could make your own unit tests, e.g. by using make and a makefile with test commands:

Code: Select all

TEST_MOVIE_FORMAT = filebot -list --q 19995 --db TheMovieDB --format

run-tests:
	$(TEST_MOVIE_FORMAT) "{n}" | grep "Avatar"
	$(TEST_MOVIE_FORMAT) "{n}" | grep "Avatar 2"

Code: Select all

$ make run-tests
filebot -list --q 19995 --db TheMovieDB --format "{n}" | grep "Avatar"
Avatar
filebot -list --q 19995 --db TheMovieDB --format "{n}" | grep "Avatar 2"
make: *** [run-tests] Error 1
:idea: Please read the FAQ and How to Request Help.
devster
Posts: 417
Joined: 06 Jun 2017, 22:56

Re: Validating format files

Post by devster »

Is there a way to do it including actual files (this would be useful for video and audio mediainfo)?
I'd like the output to be as simple as possible, like a single line with the final file name.
I only work in black and sometimes very, very dark grey. (Batman)
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Validating format files

Post by rednoah »

You can use filebot -mediainfo /files --format ... to validate MediaInfo-based custom formats:

Code: Select all

filebot -mediainfo -r "/path/to/files" \
--filter "f.video && minutes > 15" \
--format "{vc} | {vf} | {ac} | {af} | {bitrate} | {bytes} | {f}"
:idea: Please read the FAQ and How to Request Help.
devster
Posts: 417
Joined: 06 Jun 2017, 22:56

Re: Validating format files

Post by devster »

But this last command does not query any DB, right?
I'd have to split name and media information into separate bits.
I only work in black and sometimes very, very dark grey. (Batman)
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Validating format files

Post by rednoah »

{episode} and {movie} bindings will work if the file at hand as been identified already. See Metadata and Extended Attributes and Re-organize previously organized files using local xattr metadata for details.


:arrow: filebot -mediainfo will do what you want, but you still need to do filebot -rename on the files first once to store xattr metadata.




EDIT:

Code: Select all

$ filebot -rename Avatar.2009.mp4 --log INFO
[MOVE] from [Avatar.2009.mp4] to [Avatar (2009).mp4]

Code: Select all

$ filebot -mediainfo *.mp4 --format "{n} | {y} | {tmdbid} | {vc} | {vf} | {f.name}"
Avatar | 2009 | 19995 | ATEME | 2160p | Avatar (2009).mp4
:idea: Please read the FAQ and How to Request Help.
Post Reply