/usr/bin/tv_count is in xmltv-util 0.5.69-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 87 88 89 90 91 92 93 94 95 96 97 98 99 | #!/usr/bin/perl -w
=pod
=head1 NAME
tv_count - Count (and print) the number of channels and programmes
in an XMLTV file.
=head1 SYNOPSIS
tv_count FILE
=head1 DESCRIPTION
Read XMLTV listings and print a count of the number of channels and
number of programmes in the file.
=head1 EXAMPLE
Use C<tv_count listings.xml> to count programmes in the file called
F<listings.xml>.
=head1 SEE ALSO
L<xmltv(5)>
=head1 AUTHOR
Copyright Geoff Westcott, February 2013.
This code is distributed under the GNU General Public License v2 (GPLv2) .
=cut
my $_version = '$Id: tv_count,v 1.2 2015/07/12 00:46:37 knowledgejunkie Exp $';
use strict;
use XML::TreePP; # http://search.cpan.org/~kawasaki/XML-TreePP-0.41/lib/XML/TreePP.pm
use Date::Parse;
use POSIX qw(strftime);
use Getopt::Std;
use Data::Dumper;
# Process command line arguments
my %opts = (); # hash to store input args
getopts("dDhi:o:m:q",\%opts); # load the args into %opts
my $input_file = ($opts{'i'}) ? $opts{'i'} : $ARGV[0]; # main file
my $debug = ($opts{'d'}) ? $opts{'d'} : ""; # print out debugging when set to true (1)
my $debugmore = ($opts{'D'}) ? $opts{'D'} : ""; # print out debugging when set to true (1)
my $quiet_mode = ($opts{'q'}) ? $opts{'q'} : "";
if ((!%opts && ! -r $ARGV[0]) || $opts{'h'}) {
# Print usage message
usage();
}
# Parse the XMLTV file
my $tpp = XML::TreePP->new();
$tpp->set( force_array => [ 'channel', 'programme' ] ); # force array ref for some fields
my $xmltv = $tpp->parsefile( $input_file );
if ($debugmore) { print Dumper($xmltv); }
my $ccount = scalar @{ $xmltv->{'tv'}->{'channel'} };
my $pcount = scalar @{ $xmltv->{'tv'}->{'programme'} };
if (!$quiet_mode) { print "Count : $ccount channels $pcount programmes \n"; }
###############################################################################
###############################################################################
sub usage {
#
# print Usage message
#
my $filename = (split(/\//,$0))[-1];
print STDERR << "EOF";
Count (and print) the number of channels and programmes in an XMLTV file
Usage: $filename [-dDh] -i input_xmltv_file
-h : this (help) message
-d : print debugging messages
-D : print even more debugging messages
-q : quiet mode (no STDOUT messages)
-i file : input XMLTV file (or filename as first arg to script)
example: $filename -i xmltv.xml
EOF
exit;
}
|