File: APIs

package info (click to toggle)
libmediascan 0~20220401.git.34fc2d-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 7,208 kB
  • sloc: ansic: 17,054; sh: 4,228; objc: 261; perl: 225; makefile: 101
file content (86 lines) | stat: -rw-r--r-- 2,548 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
Perl
----

my $s;
$s = Media::Scan->new(
  [ '/Users/andy/Music', '/Users/andy/Movies', '/Users/andy/Pictures' ], # or single scalar
  {
    ### Options
    async => 1, # if 0, new() will return after all files are scanned
    ignore => [ qw(wav png VIDEO) ], # list of file extensions to ignore, special all-caps keywords ignore all files of that type (AUDIO, IMAGE, VIDEO)
    thumbnails => [
      { format => 'AUTO', width => 100, height => 100, keep_aspect => 1, bgcolor => 0xffffff, quality => 90 },
      ...
    ], # $result will contain generated thumbnail(s) of any/all images. For video, uses random(?) frame
    
      
    ### Callbacks
    on_file => sub {
      my $result = shift; # result object (see below)
    
    },
    on_error => sub {
      my $error = shift; # string
      undef $s; # abort scan
    },
    progress => sub { # optional
      my $p = shift; # Progress object
    },
  }
);

For async mode:
my $h = AnyEvent->io( fh => $s->async_fd, poll => 'r', cb => sub {
  $s->async_poll; # will invoke callbacks
} );

Media::Scan::Progress
  

Media::Scan::Image
  width() # width in pixels
  height() # height in pixels
  mime_type() # image/jpg, etc
  filename() # could be video/audio filename if embedded/thumbnail
  mtime()
  dlna_profile()
  offset() # byte offset to start of image (0 for standalone images, undef for videos, >0 for embedded audio image)
  size() # size in bytes of image
  data() # for generated thumbnails, or embedded artwork that can't be referenced with offset/size such as Vorbis
  thumbnails() # array of Image objects, if requested
  tags() # array of Tag objects, since file could have multiple tags, for example ID3v2 & APEv2

Media::Scan::Tag
  type() # EXIF, ID3v2.3, etc
  all() # return a big hashref of all tag data
        # Note: image tags like APIC are not included in the Tag object, but in Image objects

Media::Scan::Audio
  mime_type()
  codec() # MPEG 1 Layer 3, HE-AACv2, etc
  filename()
  mtime()
  size()
  bitrate()
  vbr() # bool
  samplerate()
  duration()
  channels()
  dlna_profile() # undef if not matching a profile
  images() # array of Image objects
  tags() # array of Tag objects

Media::Scan::Video
  mime_type() # type of container
  codec() # h.264, WMV9, etc
  filename()
  mtime()
  size()
  bitrate()
  duration()
  width()
  height()
  dlna_profile()
  audio_streams() # array of Audio objects
  thumbnails() # array of Image objects, if requested
  tags() # array of Tag objects, most video does not have tags but ASF has minimal info, for example