diff options
Diffstat (limited to 'abs/core/LinHES-system/misc_which_recorder.pl')
-rwxr-xr-x | abs/core/LinHES-system/misc_which_recorder.pl | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/abs/core/LinHES-system/misc_which_recorder.pl b/abs/core/LinHES-system/misc_which_recorder.pl new file mode 100755 index 0000000..f8a1022 --- /dev/null +++ b/abs/core/LinHES-system/misc_which_recorder.pl @@ -0,0 +1,105 @@ +#!/usr/bin/perl -w +# +# Parses the backend log file and includes information on which encoder was used to record shows. + +my ($time, $title, $subtitle, $chanid, $cardid, $sourceid); +my $index = 0; + +sub print_text +{ + print "$time - $title"; + print ": $subtitle" if ($subtitle); + print "\n"; + print " - Encoder ID: $cardid\n"; + print " - Video Source ID: $sourceid\n"; + print " - Channel ID: $chanid\n"; +} + +sub print_xml +{ + print "<a href=\"javascript:void(0)\">$time - $title"; + print ": $subtitle" if ($subtitle); + print " - Encoder: $cardid<br />". + "<span><strong>$title</strong> $time<br />"; + print "<em>$subtitle</em><br />" if ($subtitle); + print "<br />Channel ID: $chanid<br />Encoder ID: $cardid<br />". + "Video Source ID: $sourceid<br /></span></a><hr />"; + # For XML parsers + print "[]:[]capture_info$index\[]:[]time='$time':title='$title'". + ":subtitle='$subtitle':chanid='$chanid':cardid='$cardid'". + ":sourceid='$sourceid'\n"; +} + +my $mode = shift; +my $log_file = shift; + +if (($mode ne "--text") && ($mode ne "--noheader")) +{ + $log_file = $mode; +} + +if ($log_file =~ m/^--.*/i) +{ + die ("Only one option can be used at a time.\n"); +} + +if ($log_file =~ /\.gz$/) +{ +# read top down +# open($fh, "gunzip -c $log_file |") or die "Unable to open log file '$log_file', stopping:"; + open($fh, "gunzip -c $log_file |tac |") or die "Unable to open log file '$log_file', stopping:"; +} +else +{ +# read top down +# open($fh, "<$log_file") or die "Unable to open log file '$log_file', stopping:"; + open($fh, "tac $log_file |") or die "Unable to open log file '$log_file', stopping:"; +} + +while (<$fh>) +{ +# Myth .24 regex to find start of recording +# if (/^(.*)(?:\d(?: I )?|I.* -) (?:Started|Tuning) recording: (.*): channel (\d+) on cardid (\d+), sourceid (\d+)/) + if (/^(\d+-\d+-\d+T\d+\:\d+\:\d+)(?:.*) (?:Started|Tuning) recording: (.*): channel (\d+) on cardid (\d+), sourceid (\d+)/) + { + if ($mode eq "--noheader") + { + print "<div class=\"schedule\">" + if (($index == 0) && ($mode ne "--text")); + } + else + { + print "<h3>Encoder Information</h3><div class=\"schedule\">" + if (($index == 0) && ($mode ne "--text")); + } + $index++; + + ($time, $title, $chanid, $cardid, $sourceid) = ($1, $2, $3, $4, $5); + $time = `date -d $time +%a' '%m/%d' '%H:%M' '%p`; + chomp ($time); + if (($title =~ /"?(.+)"?:"?(.*)"?/) || ($title =~ /(.+) "(.*)"/)) + { + $title = $1; + $subtitle = $2; + } + else + { + $subtitle = ''; + } + $title =~ s/^"//; + $subtitle =~ s/^"//; + $title =~ s/"$//; + $subtitle =~ s/"$//; + if ($mode eq "--text") + { + print_text; + } + else + { + print_xml; + } + } +} +print "</div>" if (($index > 0) && ($mode ne "--text")); + +close $fh; |