my %defaults = (
'schedule' => {
'attrs' => [ qw/title startTime NODE_TEXT subTitle/ ],
-- 'template' => "__startTime__ - __title__"
++ 'template' => "__startTime__ - __title__"
. (defined $episode ? " - __subTitle__" : '')
. (defined $description ? "\n__NODE_TEXT__" : ''),
'filter' => {
'/state/' =>{ '^0$' => "${safe}Idle${normal}",
'^1$' => "${warning}Watching LiveTV${normal}",
'^2$' => "${warning}Watching Pre-recorded${normal}",
-- '^3$' => "${warning}Watching Recording${normal}",
-- '^4$' => "${warning}Recording${normal}" },
++ '^3$' => "${warning}Watching Recording${normal}",
++ '^4$' => "${warning}Recording${normal}" },
}
},
'hide' => 'after',
'subs' => {
'find_next' => sub {
-- my $vars = shift;
++ my $vars = shift;
return
-- if defined $next_time && $next_time eq 'now';
++ if defined $next_time && $next_time eq 'now';
my $date = ParseDate($vars->{'startTime'});
-- if (! defined $next_time || Date_Cmp($date, $next_time) < 0) {
-- $next_time = $date
-- };
++ if (! defined $next_time || Date_Cmp($date, $next_time) < 0) {
++ $next_time = $date
++ };
}
}
},
'sub' => \&process_conflicts
},
- $vars->{'_total_used'} / $vars->{'_total_total'} * 100);
- if ($percent >= $disk_space_warn) {
- return "$warning$percent\%$normal";
- } else {
- return "$safe$percent\%$normal";
- }
+ # Diskspace, before storage groups
+ {
+ 'name' => 'Total Disk Space',
+ 'type' => 'xpath',
+ 'xpath' => '//Status/MachineInfo/Storage',
+ 'xml_version' => [ "<= 31" ],
+ 'attrs' => [ qw/_total_total _total_used/ ],
+ 'commify' => [ qw/_total_total _total_used/ ],
+ 'template' => "Total space is ___total_total__ GB, with ___total_used__ GB used (__percent__)",
+ 'format' => 'one line',
+ 'subs' => {
+ 'percent' => sub {
+ my $vars = shift;
+ my $percent = sprintf("%.1f",
- $vars->{'drive_total_used'} / $vars->{'drive_total_total'} * 100);
- if ($percent >= $disk_space_warn) {
- return "$warning$percent\%$normal";
- } else {
- return "$safe$percent\%$normal";
- }
++ $vars->{'_total_used'} / $vars->{'_total_total'} * 100);
++ if ($percent >= $disk_space_warn) {
++ return "$warning$percent\%$normal";
++ } else {
++ return "$safe$percent\%$normal";
++ }
+ }
+ }
+ },
+
+ # Diskspace, with storage groups
+ {
+ 'name' => 'Total Disk Space',
+ 'type' => 'xpath',
+ 'xpath' => '//Status/MachineInfo/Storage',
+ 'xml_version' => [ ">= 32" ],
+ 'attrs' => [ qw/drive_total_total drive_total_used/ ],
+ 'commify' => [ qw/drive_total_total drive_total_used/ ],
+ 'template' => "Total space is __drive_total_total__ GB, with __drive_total_used__ GB used (__percent__)",
+ 'format' => 'one line',
+ 'subs' => {
+ 'percent' => sub {
+ my $vars = shift;
+ my $percent = sprintf("%.1f",
++ $vars->{'drive_total_used'} / $vars->{'drive_total_total'} * 100);
++ if ($percent >= $disk_space_warn) {
++ return "$warning$percent\%$normal";
++ } else {
++ return "$safe$percent\%$normal";
++ }
+ }
+ }
+ },
+
# How many hours till the next recording.
{
- 'name' => 'Time till next recording',
+ 'name' => 'Next Recording In',
'type' => 'sub',
'format' => 'one line',
'template' => '__next_time__',
'rewrite' => {
'&next_time' => sub {
return "Never"
-- unless defined $next_time;
++ unless defined $next_time;
my $str = Delta_Format(DateCalc('now', $next_time, undef, 1), 0, '%hh Hours, %mv Minutes');
$str =~ s/\b1 (Hour|Minute)s/1 $1/;
$str =~ s/^0 Hours, (.*)$/$warning$1$normal/;
$str =~ s/ 0 Minutes//;
-- return $str;
++ return $str;
}
},
'filter' => {
To => \@email,
Subject => $title . ($schedule_conflicts_present ? ' - CONFLICTS' : ''),
Data => $output
-- );
++ );
$mail->send('sendmail');
}
if ($show->{'recstatus'} == $recstatus_conflict) {
my %vars = (
-- 'title' => $show->{'title'},
++ 'title' => $show->{'title'},
'startTime' => strftime("%FT%T", localtime($show->{'starttime'})),
'NODE_TEXT' => $show->{'description'},
'subTitle' => $show->{'subtitle'}
my ($name, $sub);
while (($name, $sub) = each %{ $block->{'subs'} }) {
- &$sub($vars);
+ $value = &$sub($vars);
+
+ $template =~ s/__${name}__/$value/g
+ if defined $value;
}
--
++
return defined $skip ? undef : $template;
}