Mailing List archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[vdr] Perl script to list recordings
Hi,
here is a small Perl script which lists recordings on the disk
under Linux in the following form:
C.S.I._Den_Tätern_auf_der_Spur/(USA,_2000)_"Eisig 1:11:54 2.3 GB 4.3 Mbps
Dawson?s_Creek/Meilensteine 1:05:59 2.0 GB 4.2 Mbps
Dawson?s_Creek/Nachwuchs 1:05:59 2.0 GB 4.2 Mbps
Der_Grinch 1:56:57 2.9 GB 3.3 Mbps
...
Total recordings 135 219:34:23 352.2 GB 3.6 Mbps
Usage: /usr/local/bin/vdrsize [-l|-r|-s] [<primary video path>]
Options: -l sort by length
-r sort by rate
-s sort by size
The default path can be changed in the following line:
!@ARGV && (@ARGV = ( "/video" ));
Enjoy,
Emil
cut here ---------------------------------------------------------------
#!/usr/bin/perl
use File::Find ();
use Getopt::Std;
$Usage = qq {
Usage: $0 [-l|-r|-s] [<primary video path>]
Options: -l sort by length
-r sort by rate
-s sort by size
};
die $Usage if (!getopts('lrs') || ($opt_l && $opt_r) || ($opt_l && $opt_s)
|| ($opt_r && $opt_s));
!@ARGV && (@ARGV = ( "/video" ));
# for the convenience of &wanted calls, including -eval statements:
use vars qw/*name *dir *prune/;
*name = *File::Find::name;
*dir = *File::Find::dir;
*prune = *File::Find::prune;
foreach $file (@ARGV) {
# Traverse desired filesystems
File::Find::finddepth({wanted => \&wanted}, $file);
}
if (found) {
$_ = 'abc.rec';
name = '';
wanted();
}
@list = sort({$a->{name} cmp $b->{name} } @list);
$opt_l && (@list = sort({$a->{length} <=> $b->{length} } @list));
$opt_r && (@list = sort({$a->{rate} <=> $b->{rate} } @list));
$opt_s && (@list = sort({$a->{size} <=> $b->{size} } @list));
for ($i = 0; $i < @list; $i++) {
printf("%-49.49s %3d:%02d:%02d %5.1f GB %3.1f Mbps\n",
$list[$i]->{name},
$list[$i]->{hour},
$list[$i]->{minute},
$list[$i]->{second},
$list[$i]->{size},
$list[$i]->{rate});
}
$nrecordings && printf("%-16s %-3d %3d:%02d:%02d %5.1f GB %3.1f Mbps\n",
"Total recordings",
$nrecordings,
$sumlength / 60 / 60,
($sumlength / 60) % 60,
$sumlength % 60,
$sumsize,
$sumrate / $nrecordings);
exit;
sub wanted {
if ($_ =~ m/.*.rec/ && $oldpath !~ m/$name/) {
if ($found) {
$file =~ m#^/# && ($iname =~ s#$file##);
$iname =~ s#^/*##;
$iname =~ s#^\./##;
$iname =~ s#/\d\d\d\d-\d\d-\d\d.*\.rec/.*##;
push(@list, {
name => $iname,
length => $length,
hour => $length / 60 / 60,
minute => ($length / 60) % 60,
second => $length % 60,
size => $size / 1024 / 1024 / 1024,
rate => $size / $length * 8 / 1024 / 1024
});
$sumsize += ($size / 1024 / 1024 /1024);
$sumrate += ($size / $length * 8 / 1024 / 1024);
$sumlength += $length;
$nrecordings++;
}
$found = $size = $length = 0;
$oldpath = $name;
}
/index.vdr/s && ($length = (-s $_) / 8 / 25)
&& ($iname = $name)
&& ($found = 1);
/\d\d\d.vdr/s && ($size += -s $_);
}
--
Info:
To unsubscribe send a mail to listar@linuxtv.org with "unsubscribe vdr" as subject.
Home |
Main Index |
Thread Index