rsmediainfo 0.2.0

Rust wrapper for MediaInfo library
//! Example that builds a [`MediaInfoContext`] once and parses every
//! media file listed on the command line through the same context.
//!
//! This is the recommended shape for batch workloads — asset scanners,
//! import pipelines, directory walks — because the MediaInfo shared
//! library is loaded exactly once instead of on every call.
//!
//! Run with:
//!
//! ```text
//! cargo run --example batch_parse -- tests/data/sample.mp4 tests/data/sample.mkv
//! ```

use rsmediainfo::MediaInfoContext;
use std::env;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let paths: Vec<String> = env::args().skip(1).collect();
    if paths.is_empty() {
        eprintln!("usage: batch_parse <media_path> [<media_path> ...]");
        std::process::exit(2);
    }

    // One library load for the whole run — every subsequent parse
    // reuses the same loaded copy.
    let ctx = MediaInfoContext::new()?;
    println!("loaded library version {}", ctx.library_version_string());

    for path in &paths {
        match ctx.parse_media_info_path(path) {
            Ok(info) => {
                println!("{}: {} tracks", path, info.tracks().len());
                for track in info.tracks() {
                    println!("  - {}", track.track_type());
                }
            }
            Err(err) => {
                eprintln!("{}: {}", path, err);
            }
        }
    }

    Ok(())
}