Help language development. Donate to The Perl Foundation

File::Metadata::Libextractor cpan:FRITH last updated on 2019-01-09

File-Metadata-Libextractor-0.0.2/

Build Status

NAME

File::Metadata::Libextractor - Use libextractor to read file metadata

SYNOPSIS

use File::Metadata::Libextractor;

#| This program extracts all the information about a file
sub MAIN($file! where { .IO.f // die "file '$file' not found" })
{
  my File::Metadata::Libextractor $e .= new;
  my @info = $e.extract($file);
  for @info -> %record {
    for %record.kv -> $k, $v {
      say "$k: $v"
    }
    say '-' x 50;
  }
}

DESCRIPTION

File::Metadata::Libextractor provides an OO interface to libextractor in order to query files' metadata.

As the Libextractor site (https://www.gnu.org/software/libextractor) states, it is able to read information in the following file types:

Also, various additional MIME types are detected.

new(Bool :$in-process?)

Creates a File::Metadata::Libextractor object.

libextractor interfaces to several libraries in order to extract the metadata. To work safely it starts sub-processes to perform the actual extraction work.

This might cause problems in a concurrent envirnment with locks. A possible solution is to run the extraction process inside the program's own process. It's less secure, but it may avoid locking problems.

The optional argument $in-process allows the execution of the extraction job in the parent's process.

extract($file where .IO.f // fail "file '$file' not found" --> List)

Reads all the possible information from an existing file, or fails if the file doesn't exist. The output List is actually a List of Hashes. Each hash has the following keys:

The possible values for plugin-format are:

The possible values for the plugin-type field are listed in File::Metadata::Libextractor::Constants, in the EXTRACTOR_MetaType enum (231 values as for v3.1.6).

Prerequisites

This module requires the libextractor library to be installed. It has been successfully tested on the following Linux distributions:

It doesn't work with the version of the library that comes with Ubuntu 14.04.

sudo apt-get install libextractor3

This module looks for a library called libextractor.so.3 .

Installation

To install it using zef (a module management tool):

$ zef install File::Metadata::Libextractor

Testing

To run the tests:

$ prove -e "perl6 -Ilib"

AUTHOR

Fernando Santagata nando.santagata@gmail.com

COPYRIGHT AND LICENSE

Copyright 2018 Fernando Santagata

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.