MediaInfo icon indicating copy to clipboard operation
MediaInfo copied to clipboard

[CLI][JSON] Make JSON structure uniform for 1 and 2+ input files

Open alex3kov opened this issue 7 months ago • 4 comments

Currently --Output=JSON outputs a json object if passed a single file and an array of json objects if passed 2+ files:

$ mediainfo --Output=JSON 1.mkv
{ ... }
$ mediainfo --Output=JSON 1.mkv 2.mkv
[ { ... }, { ... } ] 

This creates a problem in scripts that deal with arbitrary number of files (sometimes 1, sometimes 2+) as an object and an array of objects need to be handled differently.

Suggestion: always output an array of objects (in case of 1 file - an array with a single object).

alex3kov avatar Apr 29 '25 06:04 alex3kov

Hi

I've submitted a PR to MediaArea/MediaInfoLib that should resolve this issue. Please take a look and let me know if you have any comments?

Thanks!

trallen avatar May 12 '25 14:05 trallen

Thanks @trallen, PR description looks good. Tried building from your branch to test but couldn't get ZenLib to work.

alex3kov avatar May 13 '25 04:05 alex3kov

Can refer to https://github.com/MediaArea/MediaInfo/blob/master/.github/workflows/MediaInfo_Checks.yml for how to successfully build CLI.

cjee21 avatar May 14 '25 05:05 cjee21

Can refer to https://github.com/MediaArea/MediaInfo/blob/master/.github/workflows/MediaInfo_Checks.yml for how to successfully build CLI.

Thanks, building with autotools worked (I was trying cmake+ninja before).

alex3kov avatar May 15 '25 04:05 alex3kov