From 7e5ce60d93b3f9151df01f1917bc870ed6154fa8 Mon Sep 17 00:00:00 2001 From: James Meyer Date: Sat, 1 Sep 2012 20:27:53 -0500 Subject: Merge remote-tracking branch 'origin/testing' into testing # By Britney Fransen (5) and others # Via Britney Fransen * origin/testing: LinHES-system: Add scripts for misc status in MythWeb. closes #845. linhes-scripts: tweak myth2mkv. Update version to 0.25-004 dvb-firmware: add xc5000c firmware. change xc5000 modprobe options. closes #844 v4l-dvb: update to snapshot from 20120828. refs #844 LinHES-system: update myth_status.py to work with tuners in error. closes #843 curlftpfs: Initial Inclusion. linhes-scripts: minor changes to myth2mkv mythtv:Bumped to latest fixes. Added ./configure items to close #842. LinHES-config:7.4 rdt 9th anniversary release. Conflicts: abs/core/LinHES-config/LinHES-release abs/core/LinHES-config/PKGBUILD abs/core/LinHES-system/PKGBUILD abs/core/linhes-scripts/PKGBUILD abs/core/linhes-scripts/myth2mkv abs/core/mythtv/stable-0.25/mythtv/PKGBUILD --- abs/core/LinHES-system/LinHES-system.install | 12 + abs/core/LinHES-system/PKGBUILD | 16 +- abs/core/LinHES-system/misc_recent_recordings.pl | 194 ++++++++++++ abs/core/LinHES-system/misc_status_config.py | 15 + abs/core/LinHES-system/misc_status_info.sh | 23 ++ abs/core/LinHES-system/misc_upcoming_recordings.pl | 328 +++++++++++++++++++++ abs/core/LinHES-system/misc_which_recorder.pl | 105 +++++++ abs/core/linhes-scripts/myth2mkv | 2 +- 8 files changed, 691 insertions(+), 4 deletions(-) create mode 100644 abs/core/LinHES-system/LinHES-system.install create mode 100755 abs/core/LinHES-system/misc_recent_recordings.pl create mode 100755 abs/core/LinHES-system/misc_status_config.py create mode 100755 abs/core/LinHES-system/misc_status_info.sh create mode 100755 abs/core/LinHES-system/misc_upcoming_recordings.pl create mode 100755 abs/core/LinHES-system/misc_which_recorder.pl diff --git a/abs/core/LinHES-system/LinHES-system.install b/abs/core/LinHES-system/LinHES-system.install new file mode 100644 index 0000000..f2185cd --- /dev/null +++ b/abs/core/LinHES-system/LinHES-system.install @@ -0,0 +1,12 @@ +## arg 1: the new package version +post_install() { + /usr/LH/bin/misc_status_config.py +} + +## arg 1: the new package version +## arg 2: the old package version +post_upgrade() { + /usr/LH/bin/misc_status_config.py +} + +# vim:set ts=2 sw=2 et: diff --git a/abs/core/LinHES-system/PKGBUILD b/abs/core/LinHES-system/PKGBUILD index 0c956b6..d4f2173 100755 --- a/abs/core/LinHES-system/PKGBUILD +++ b/abs/core/LinHES-system/PKGBUILD @@ -1,10 +1,10 @@ pkgname=LinHES-system pkgver=2 -pkgrel=75 +pkgrel=76 arch=('i686' 'x86_64') MVDIR=$startdir/pkg/usr/LH BINDIR=$startdir/pkg/usr/bin -#install=LinHES.install +install=LinHES-system.install pkgdesc="scripts and things related to having an automated system" depends=(linhes-sounds xdotool tilda keylaunch python_aosd 'linhes-scripts>=7-24' 'udisks' 'LinHES-config>=2.3-59' 'sudo' 'python2-dbus' 'unclutter') backup=(etc/modprobe.d/alsa-base) @@ -23,7 +23,12 @@ binfiles="LinHES-start optimize_mythdb.py diskspace.sh cacheclean lh_message.sh lh_backend_control.sh switch_web.sh create_media_dirs.sh - msg_client.py msg_daemon.py gen_is_xml.py gen_lib_xml.py" + msg_client.py msg_daemon.py gen_is_xml.py gen_lib_xml.py + misc_recent_recordings.pl + misc_status_config.py + misc_status_info.sh + misc_upcoming_recordings.pl + misc_which_recorder.pl" source=(LinHES-session LinHES-profile.sh $binfiles alsa-base myth_mtc.lr diskspace cacheclean.cron readme_is_xml add_storage.readme) @@ -89,6 +94,11 @@ md5sums=('4921a6e21c71b263b8d23c51c24b939c' '5148fe4c6ac27fff8152c819c4d2b47a' 'ea315f41dcd6c978e546c95fc05546cf' 'ac61cc460d9e97ba1f5ef69e92cdfbe5' + '06a628469051237943b7c874f2e29b8a' + '0512f859cd5ea1d9eb972840caef2f0e' + '45f46d1f9193c8dde18e56369ec29a1e' + 'a8edbe7bc37e9932e8749d9f5f89c16f' + '14cea9e87654441b766a97576233ba5a' 'eb879fee9603a05d5420d4ce8ed9e450' 'f1870a9522c79e6b248fcbf81dec3280' '84492954db16740f949d795b74383189' diff --git a/abs/core/LinHES-system/misc_recent_recordings.pl b/abs/core/LinHES-system/misc_recent_recordings.pl new file mode 100755 index 0000000..92dda8a --- /dev/null +++ b/abs/core/LinHES-system/misc_recent_recordings.pl @@ -0,0 +1,194 @@ +#!/usr/bin/perl -w +# +# Outputs information about the most-recently-recorded shows. +# +# Automatically detects database settings. +# + +# Includes + use DBI; + use Getopt::Long; + use MythTV; + +# Some variables we'll use here + our ($num_recordings, $live, $heading, $plain_text, $text_format, $usage); + our ($hours, $minutes, $seconds); + our ($dnum_recordings, $dheading, $dtext_format); + our ($dhours, $dminutes, $dseconds); + our ($status_text_format, $status_value_format); + our ($dstatus_text_format, $dstatus_value_format); + +# Default number of recent recordings to show + $dnum_recordings = 5; +# Default period in which to show recordings + $dhours = -1; + $dminutes = -1; + $dseconds = -1; +# Default status output heading + $dheading='Recent Recordings:\n'; +# Default format of plain-text output + $dtext_format='%n/%j, %g:%i %A - %cc\n%T - %S\n%R\n\n'; +# Default format of status output display text + $dstatus_text_format= '%n/%j %g:%i %A - %cc - %T - %S
'. + '%T %n/%j, %g:%i %A
'. + '%S

%R

'; +# Default format of status output value + $dstatus_value_format = '%n/%j, %g:%i %A - %T - %S'; + +# Provide default values for GetOptions + $num_recordings = $dnum_recordings; + $hours = $dhours; + $minutes = $dminutes; + $seconds = $dseconds; + $heading = $dheading; + $text_format = $dtext_format; + $status_text_format = $dstatus_text_format; + $status_value_format = $dstatus_value_format; + +# Load the cli options + GetOptions('num_recordings|recordings=s' => \$num_recordings, + 'hours|o=i' => \$hours, + 'minutes=i' => \$minutes, + 'seconds|e=i' => \$seconds, + 'live' => \$live, + 'heading=s' => \$heading, + 'plain_text' => \$plain_text, + 'text_format=s' => \$text_format, + 'status_text_format=s' => \$status_text_format, + 'status_value_format=s' => \$status_value_format, + 'usage|help' => \$usage + ); + +# Print usage + if ($usage) { + print < 0); + $start_after = $start_after - ($minutes * 60) if ($minutes > 0); + $start_after = $start_after - $seconds if ($seconds > 0); + $start_after = 0 if (!($start_after < $now)); + +# Fix the heading. + if (defined($plain_text)) { + $heading =~ s/\\r/\r/g; + $heading =~ s/\\n/\n/g; + } + else { + # Remove line break format specifiers from heading for status output + $heading =~ s/(\\r|\\n)//g; + } + +# Connect to mythbackend + my $Myth = new MythTV(); + +# Get the list of recordings + my $count = 0; + my %rows = $Myth->backend_rows('QUERY_RECORDINGS Delete'); + our $show; + foreach my $row (@{$rows{'rows'}}) { + last unless (($count < $num_recordings) || ($num_recordings < 0)); + $show = new MythTV::Program(@$row); + # Skip LiveTV recordings? + next unless (defined($live) || $show->{'recgroup'} ne 'LiveTV'); + # Within the period of interest? + last if (($start_after) && ($show->{'recstartts'} < $start_after)); + # Print the recording information in the desired format + if (defined($plain_text)) { + text_print($count); + } + else { + status_print($count); + } + $count++; + } + +# Print the output for use in the backend status page. + sub status_print { + my $count = shift; + my $text = $show->format_name($status_text_format, ' ', ' ', 1, 0 ,1); + my $value = $show->format_name($status_value_format, ' ', ' ', + 1, 0 ,1); + print("$heading
") if ($count == 0); + print("$text"); + print("
") if ($count == ($num_recordings - 1)); + print("[]:[]recording$count"); + print("[]:[]$value\n"); + } + +# Print the output in plain text format + sub text_print { + my $count = shift; + my $text = $show->format_name($text_format, ' ', ' ', 1, 0 ,1); + $text =~ s/\\r/\r/g; + $text =~ s/\\n/\n/g; + print("$heading") if ($count == 0); + print("$text"); + } diff --git a/abs/core/LinHES-system/misc_status_config.py b/abs/core/LinHES-system/misc_status_config.py new file mode 100755 index 0000000..0a0ba6c --- /dev/null +++ b/abs/core/LinHES-system/misc_status_config.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python2 + +# This script will configure the myth db to use the misc_status_info scripts + +from socket import gethostname +from MythTV import MythDB +mythdb = MythDB() +localhostname = gethostname() + +# mythtv-setup +if mythdb.settings[localhostname].MiscStatusScript == u'': + mythdb.settings[localhostname].MiscStatusScript = u'/usr/LH/bin/misc_status_info.sh' + print 'The MythTV database setting MiscStatusScript was updated to /usr/LH/bin/misc_status_info.sh.' +else: + print 'The MythTV database setting MiscStatusScript is already set and will not be updated.' diff --git a/abs/core/LinHES-system/misc_status_info.sh b/abs/core/LinHES-system/misc_status_info.sh new file mode 100755 index 0000000..14a972c --- /dev/null +++ b/abs/core/LinHES-system/misc_status_info.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +# Show all upcoming conflicts +/usr/LH/bin/misc_upcoming_recordings.pl --recordings -1 \ + --no_show_scheduled \ + --heading '

Recording Conflicts

' \ + --no_conflicts_message '

No Recording Conflicts

' + +# Show all the shows recorded today +/usr/LH/bin/misc_recent_recordings.pl --recordings=-1 --hours=24 \ + --heading '

Shows Recorded In The Last 24 Hours

' + +# Get Encoder that was used for recordings from the backend log +firstrun=1 +loglist=`find /var/log/ -name *_mythbackend.*.log*` +for i in `ls -t $loglist` +do + if [ $firstrun -eq 1 ]; then + echo "

Encoder Information

'. + '%T %n/%j, %g:%i %A
'. + '%S

%R

'; +# Default format of status output value + $dstatus_value_format = '%n/%j %g:%i %A - %T - %S'; + +# Provide default values for GetOptions + $num_recordings = $dnum_recordings; + $hours = $dhours; + $minutes = $dminutes; + $seconds = $dseconds; + $scheduled = $dscheduled; + $duplicates = $dduplicates; + $deactivated = $ddeactivated; + $conflicts = $dconflicts; + $heading = $dheading; + $text_format = $dtext_format; + $no_conflicts_message = $dno_conflicts_message; + $status_text_format = $dstatus_text_format; + $status_value_format = $dstatus_value_format; + +# Load the cli options + GetOptions('num_recordings|recordings=s' => \$num_recordings, + 'hours|o=i' => \$hours, + 'minutes=i' => \$minutes, + 'seconds|s=i' => \$seconds, + 'show_scheduled|_show_scheduled|scheduled|_scheduled|e!' + => \$scheduled, + 'show_duplicates|_show_duplicates|duplicates|_duplicates|p!' + => \$duplicates, + 'show_deactivated|_show_deactivated|deactivated|_deactivated|v!' + => \$deactivated, + 'show_conflicts|_show_conflicts|conflicts|_conflicts!' + => \$conflicts, + 'heading=s' => \$heading, + 'plain_text' => \$plain_text, + 'text_format=s' => \$text_format, + 'no_conflicts_message=s' => \$no_conflicts_message, + 'status_text_format=s' => \$status_text_format, + 'status_value_format=s' => \$status_value_format, + 'usage|help' => \$usage + ); + +# Print usage + if ($usage) { + # Make default "--show_*" options readable + $dscheduled = ($dscheduled ? '--show_scheduled' : + '--no_show_scheduled'); + $dduplicates = ($dduplicates ? '--show_duplicates' : + '--no_show_duplicates'); + $ddeactivated = ($ddeactivated ? '--show_deactivated' : + '--no_show_deactivated'); + $dconflicts = ($dconflicts ? '--show_conflicts' : + '--no_show_conflicts'); + print < 0); + $start_before = $start_before + ($minutes * 60) if ($minutes > 0); + $start_before = $start_before + $seconds if ($seconds > 0); + $start_before = 0 if (!($start_before > $now)); + +# Fix the heading. + if (defined($plain_text)) { + $heading =~ s/\\r/\r/g; + $heading =~ s/\\n/\n/g; + } + else { + # Remove line break format specifiers from heading for status output + $heading =~ s/(\\r|\\n)//g; + } + +# Connect to mythbackend + my $Myth = new MythTV(); + +# Get the list of recordings + my $count = 0; + my %rows = $Myth->backend_rows('QUERY_GETALLPENDING', 2); + my $has_conflicts = $rows{'offset'}[0]; + if ((!$has_conflicts) && + (($conflicts) && + (!(($scheduled) || ($duplicates) || ($deactivated))))) { + $no_conflicts_message =~ s/\\r/\r/g; + $no_conflicts_message =~ s/\\n/\n/g; + print "$no_conflicts_message"; + exit 0; + } + my $num_scheduled = $rows{'offset'}[1]; + our $show; + foreach my $row (@{$rows{'rows'}}) { + last unless (($count < $num_recordings) || ($num_recordings < 0)); + $show = new MythTV::Program(@$row); + last if (($start_before) && ($show->{'recstartts'} > $start_before)); + next if ((!$scheduled) && (is_scheduled($show->{'recstatus'}))); + next if ((!$duplicates) && (is_duplicate($show->{'recstatus'}))); + next if ((!$deactivated) && (is_deactivated($show->{'recstatus'}))); + next if ((!$conflicts) && (is_conflict($show->{'recstatus'}))); + + # Print the recording information in the desired format + if (defined($plain_text)) { + text_print($count); + } + else { + status_print($count); + } + $count++; + } + +# Returns true if the show is scheduled to record + sub is_scheduled { + my $recstatus = (shift() or 0); + return (($MythTV::recstatus_willrecord == $recstatus) || + ($MythTV::recstatus_recorded == $recstatus) || + ($MythTV::recstatus_recording == $recstatus)); + } + +# Returns true if the show is a duplicate + sub is_duplicate { + my $recstatus = (shift() or 0); + return (($MythTV::recstatus_repeat == $recstatus) || + ($MythTV::recstatus_previousrecording == $recstatus) || + ($MythTV::recstatus_currentrecording == $recstatus)); + } + +# Returns true if the recording is deactivated + sub is_deactivated { + my $recstatus = (shift() or 0); + return (($MythTV::recstatus_inactive == $recstatus) || + ($MythTV::recstatus_toomanyrecordings == $recstatus) || + ($MythTV::recstatus_cancelled == $recstatus) || + ($MythTV::recstatus_deleted == $recstatus) || + ($MythTV::recstatus_aborted == $recstatus) || + ($MythTV::recstatus_notlisted == $recstatus) || + ($MythTV::recstatus_dontrecord == $recstatus) || + ($MythTV::recstatus_lowdiskspace == $recstatus) || + ($MythTV::recstatus_tunerbusy == $recstatus) || + ($MythTV::recstatus_neverrecord == $recstatus) || + ($MythTV::recstatus_earliershowing == $recstatus) || + ($MythTV::recstatus_latershowing == $recstatus)); + } + +# Returns true if the show cannot be recorded due to a conflict + sub is_conflict { + my $recstatus = (shift() or 0); + return ($MythTV::recstatus_conflict == $recstatus); + } + +# Print the output for use in the backend status page. + sub status_print { + my $count = shift; + my $text = $show->format_name($status_text_format, ' ', ' ', 1, 0 ,1); + $text =~ s/%rs/$MythTV::RecStatus_Types{$show->{'recstatus'}}/g; + my $value = $show->format_name($status_value_format, ' ', ' ', + 1, 0 ,1); + $value =~ s/%rs/$MythTV::RecStatus_Types{$show->{'recstatus'}}/g; + print("$heading
") if ($count == 0); + print("$text"); + print("
") if ($count == ($num_recordings - 1)); + print("[]:[]recording$count"); + print("[]:[]$value\n"); + } + +# Print the output in plain text format + sub text_print { + my $count = shift; + my $text = $show->format_name($text_format, ' ', ' ', 1, 0 ,1); + $text =~ s/%rs/$MythTV::RecStatus_Types{$show->{'recstatus'}}/g; + $text =~ s/\\r/\r/g; + $text =~ s/\\n/\n/g; + print("$heading") if ($count == 0); + print("$text"); + } 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 "$time - $title"; + print ": $subtitle" if ($subtitle); + print " - Encoder: $cardid
". + "$title $time
"; + print "$subtitle
" if ($subtitle); + print "
Channel ID: $chanid
Encoder ID: $cardid
". + "Video Source ID: $sourceid

"; + # 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 "
" + if (($index == 0) && ($mode ne "--text")); + } + else + { + print "

Encoder Information

" + 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 "
" if (($index > 0) && ($mode ne "--text")); + +close $fh; diff --git a/abs/core/linhes-scripts/myth2mkv b/abs/core/linhes-scripts/myth2mkv index 447e3c4..aedccff 100644 --- a/abs/core/linhes-scripts/myth2mkv +++ b/abs/core/linhes-scripts/myth2mkv @@ -2,7 +2,7 @@ # # Convert video to AVC-1 / h264 # -# version 0.25-003 +# version 0.25-004 # # Prerequisites: # - mythtv >= 0.25 -- cgit v0.12