<commit_before>package pman.async;

import tannus.io.*;
import tannus.ds.*;
import tannus.geom.*;
import tannus.sys.*;
import tannus.node.*;

import gryffin.core.*;
import gryffin.display.*;
import gryffin.audio.*;

import pman.core.*;
import pman.media.*;

import Std.*;
import tannus.math.TMath.*;
import js.Browser.window;
import electron.Tools.defer;
import gryffin.Tools.now;

using tannus.math.TMath;
using StringTools;
using tannus.ds.StringUtils;
using Lambda;
using tannus.ds.ArrayTools;
using Slambda;

class MP4MetadataLoader extends MediaMetadataLoader {
    override function action(done : Void->Void):Void {
        var il = new Mp4InfoLoader();
        var ip = il.load( path );
        ip.then(function(info) {
            // general data
            meta.duration = info.nduration;

            // video/audio specific data
            var vt = info.videoTracks[0];
            if (vt != null) {
                if (vt.video != null) {
                    meta.video = {
                        width: vt.video.width,
                        height: vt.video.height
                    };
                }
                if (vt.audio != null) {
                    meta.audio = {};
                }
            }

            done();
        });
        ip.unless(function(error) {
            throw error;<commit_msg>Fixed minor flaw in the metadata loader for mp4 files<commit_after>package pman.async;

import tannus.io.*;
import tannus.ds.*;
import tannus.geom.*;
import tannus.sys.*;
import tannus.node.*;

import gryffin.core.*;
import gryffin.display.*;
import gryffin.audio.*;

import pman.core.*;
import pman.media.*;

import Std.*;
import tannus.math.TMath.*;
import js.Browser.window;
import electron.Tools.defer;
import gryffin.Tools.now;

using tannus.math.TMath;
using StringTools;
using tannus.ds.StringUtils;
using Lambda;
using tannus.ds.ArrayTools;
using Slambda;

class MP4MetadataLoader extends MediaMetadataLoader {
    override function action(done : Void->Void):Void {
        var il = new Mp4InfoLoader();
        var ip = il.load( path );
        ip.then(function(info) {
            // general data
            meta.duration = info.nduration;

            // video/audio specific data
            var vt = info.videoTracks[0];
            if (vt != null) {
                if (vt.video != null) {
                    meta.video = {
                        width: vt.video.width,
                        height: vt.video.height
                    };
                }
            }

            var at = info.audioTracks[0];
            if (at != null && at.audio != null) {
                meta.audio = {};
            }

            done();
        });
        ip.unless(function(error) {
            throw error;
{'fraction_non_alphanumeric': 0.11843534951104673, 'fraction_numerical': 0.002897500905469033, 'mean_word_length': 1.7455268389662029, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5919125', 'n_tokens_mistral': 835, 'n_tokens_neox': 812, 'n_words': 193}