Page 1 of 1

Validating format files

Posted: 16 Jan 2023, 20:16
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

Re: Validating format files

Posted: 17 Jan 2023, 03:55
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

Re: Validating format files

Posted: 22 Jan 2023, 23:37
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.

Re: Validating format files

Posted: 23 Jan 2023, 03:26
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}"

Re: Validating format files

Posted: 24 Jan 2023, 00:46
by devster
But this last command does not query any DB, right?
I'd have to split name and media information into separate bits.

Re: Validating format files

Posted: 24 Jan 2023, 03:06
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