<commit_before>package main

// #include "types.h"
import "C"
import (
	"fmt"
	"github.com/amarburg/go-lazyquicktime"
)

//export MovInfo
func MovInfo(path *C.char) C.MovieInfo {

	file, err := sourceFromCPath(path)

	if err != nil {
		fmt.Printf("Error opening path: %s", err.Error())
		return C.MovieInfo{}
	}

	qtInfo, err := lazyquicktime.LoadMovMetadata(file)

	if err != nil {
		fmt.Printf("Error getting metadata: %s", err.Error())
		return C.MovieInfo{}
	}

	return qtInfoToMovieInfo(qtInfo)
}

func qtInfoToMovieInfo(qtInfo *lazyquicktime.LazyQuicktime) C.MovieInfo {
	return C.MovieInfo{
		duration:   C.float(qtInfo.Duration()),
		num_frames: C.int(qtInfo.NumFrames()),
		valid:      1,
	}
}
<commit_msg>Check for nil file as well.<commit_after>package main

// #include "types.h"
import "C"
import (
	"fmt"
	"github.com/amarburg/go-lazyquicktime"
)

//export MovInfo
func MovInfo(path *C.char) C.MovieInfo {

	file, err := sourceFromCPath(path)

	if file == nil || err != nil {
		fmt.Printf("Error opening path: %s", err.Error())
		return C.MovieInfo{}
	}

	qtInfo, err := lazyquicktime.LoadMovMetadata(file)

	if err != nil {
		fmt.Printf("Error getting metadata: %s", err.Error())
		return C.MovieInfo{}
	}

	return qtInfoToMovieInfo(qtInfo)
}

func qtInfoToMovieInfo(qtInfo *lazyquicktime.LazyQuicktime) C.MovieInfo {
	return C.MovieInfo{
		duration:   C.float(qtInfo.Duration()),
		num_frames: C.int(qtInfo.NumFrames()),
		valid:      1,
	}
}

{'fraction_non_alphanumeric': 0.1501028101439342, 'fraction_numerical': 0.0013708019191226869, 'mean_word_length': 4.159010600706714, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '52931', 'n_tokens_mistral': 588, 'n_tokens_neox': 549, 'n_words': 117}