add license file
[undvd.git] / vidstat
blob4685aa66fc6a039fa809cb38caeaaf8f8f8d6d48
1 #!/usr/bin/perl
3 # Author: Martin Matusiak <numerodix@gmail.com>
4 # Licensed under the GNU Public License, version 3.
6 use strict;
7 use Getopt::Long qw(:config no_ignore_case);
9 use FindBin qw($RealBin);
10 use lib $RealBin;
11 use colors;
12 use common qw(:DEFAULT $suite $defaults $tools);
15 my $usage = "Usage: " . s_b($suite->{tool_name}) . " ["
16 . s_bb("<file(s)>") . " | "
17 . s_b("--dev") . " " . s_bb($defaults->{dvd_device}) . " | "
18 . s_b("--dir") . " " . s_bb("/path") . " | "
19 . s_b("--iso") . " " . s_bb($defaults->{disc_image}) . "]
20 <file(s)> files to read
21 -d --dev dvd device to read from (default is " . s_bb($defaults->{dvd_device}) . ")
22 -q --dir dvd directory to read from
23 -i --iso dvd iso image to read from
24 --version show " . $suite->{suite_name} . " version\n";
26 my $dvd_device;
27 my $parse = GetOptions(
28 "d|dev=s"=>\$dvd_device,
29 "q|dir=s"=>\$dvd_device,
30 "i|iso=s"=>\$dvd_device,
31 "version"=>\&print_version,
34 print_tool_banner();
36 if (! $parse) {
37 print "$usage";
38 exit 2;
41 if ((! $dvd_device) and (! @ARGV)) {
42 print "$usage";
43 exit 2;
47 # Build array either of dvd titles or files given as input
49 my @titles = ();
50 if ($dvd_device) {
51 my $titles_count = examine_dvd_for_titlecount($dvd_device);
52 if (scalar $titles_count < 1) {
53 fatal("Could not read from %%%$dvd_device%%% dvd device");
55 for (my $i = 1; $i <= $titles_count; $i++) {
56 push(@titles, $i);
58 } else {
59 @titles = @ARGV;
62 print_title_line(1);
63 foreach my $title (@titles) {
65 if (! $dvd_device and ! -e $title) {
66 nonfatal("File %%%$title%%% does not exist");
67 next;
70 my $data = examine_title($title, $dvd_device);
72 print_title_line(0, $data);