9 BEGIN { binmode STDOUT, ":utf8"; }
11 (my $prog = $0) =~ s:^.*/::;
12 sub HELP_MESSAGE ($;@) {
14 print $fh "usage: $prog [-ps] DISC-ID ...\n";
16 my $ROOT = "/mnt/dvd/archive";
20 getopts("hps", \%opt) or $bogusp = 1;
21 if ($opt{"h"}) { HELP_MESSAGE \*STDOUT; exit 0; }
23 if ($bogusp) { HELP_MESSAGE \*STDERR; exit 2; }
24 $opt{"p"} || $opt{"s"} or $opt{"p"} = 1;
26 my $DB = DBI->connect("dbi:Pg:host=roadstar", "", "",
32 ("SELECT s.name, d.disc, d.path
33 FROM dvd_disc AS d JOIN dvd_set AS s ON d.set_id = s.id
34 WHERE d.disc_id = ?");
39 my @r = $st->fetchrow_array; $st->finish;
40 if (!@r) { print STDERR "$prog: unknown id `$id'\n"; $rc = 1; }
42 my ($name, $disc, $path) = @r;
43 @ARGV > 1 and print "$id: ";
44 if ($opt{"s"}) { print "$name (#$disc)"; }
45 if ($opt{"p"} && $opt{"s"}) { print " ["; }
46 if ($opt{"p"}) { print $path; }
47 if ($opt{"p"} && $opt{"s"}) { print "]"; }