[mythtv-users] Crude VCR like functionality of on-demand programming using mythtv

Gagan Prakash gpcabe at gmail.com
Wed Apr 14 07:27:30 UTC 2010


I did some work to get on-demand programming to work on my mythtv. So I
thought I might as well share.
Hopefully this is helpful for someone.

Probably too much work for what its worth but I was able to record
reasonable amount
of showtime stuff during the free on-demand showtime weekend on comcast.


My setup:
1) Only have a master-backend running (Mythbuntu 0.22-fixes). I use mythweb
to do all program scheduling.
2) I use Hauppage HD-PVR to do the recording in HD
3) I have a Motorola DCX3200 from comcast (But I imagine this may work with
anything)
4) I use IguanaIR usb based IRBlaster for changing channels on my hd comcast
box.

This does require recompiling the mythtv from source for one minor change.

Basic idea:

1) Use certain channels as map to files which contain the navigation
information to start the on-demand program
2) Use all the button configured in the IRBlaster to navigate on the cable
box
3) Setup recording using a manual recording schedule

Non-automated parts and other Issues:
1) No useful programming information in the recording although my script
lets me output the information to a directory structure, I am not yet using
it
2) Requires manual recording schedule for each on-demand item
3) Requires figuring out the length of the on-demand program by hand
4) Requires figuring out the navigation for each on-demand program by hand
and that needs to be put into a file

So the first thing is to recompile mythtv for one minor change (I wish this
timeout was configurable and you wouldn't have to recompile then)
1) I used the http://www.debian.org/doc/FAQ/ch-pkg_basics.en.html section
7.14 to figure out how to rebuild
2) The change is in lib/libmythtv/channelbase.cpp

        line 658 in my source otherwise just search for 30 since there is
only one place where timeout is used
       Change:   uint timeout = 30; // how long to wait in
seconds
       to: uint timeout = 120; // how long to wait in seconds
   although I am finding that i need that change to something longer so you
may want to start with 180 or 240
3) Install your local build.

We use the familiar change-channel-lirc.sh to change channels with some
modifications.
If the channel is being changed to something greater than 900 (those are
music channels on comcast), I go and look for a file with that name.

Sample navigation file looks like this:


/mediastore/videos/downloads/on-demand-commands/901:
RecordType = series
Name = The Tudors
Season = 1
Episode = 4
Channel = 001
Navigate = 20 enter 7 pgdn 7 right 5 enter 5 down 5 enter 5 enter 7 down 5
down 5 down 5 down 5 enter 7 enter 15

or

/mediastore/videos/downloads/on-demand-commands/966:
RecordType = movies
Name = The Bank Job
Channel = 001
Navigate = 20 down 4 down 4 enter 5 down 4 down 4 enter 5 right 4 enter 5
enter 5 enter 5 pgdn 5 down 4 down 4 down 4 down 4 enter 5 enter 15


Main thing to remember is that all the numbers are sleep times between
commands and the first number is usually
very critical since it takes a certain amount of time for the on-demand
channel to show up and start accepting
remote commands. The command names match the commands in your
/etc/lirc/lircd.conf file for your remote

So this navigation file with the following script (with hard coded paths
changed appropriately for your setup).


change-channel-lirc.sh looks as follows:

Change  the following to match your setup. Where $cmdpath is the path of the
navigation file
and $BaseDirPath is where I dump the programming info from the navigation
file.

BaseDirPath=/mediastore/videos/recordings/on-demand
cmdpath=/mediastore/videos/downloads/on-demand-commands/$1


/usr/local/bin/change-channel-lirc.sh
#!/bin/bash

REMOTE_NAME=dcx3200
#REMOTE_NAME=rng110
#irsend --device=/dev/lircd SEND_ONCE $REMOTE_NAME enter

if [ "$1" -lt "900" ]; then
  sleep 0.5
  for digit in $(echo $1 | sed -e 's/./& /g'); do
  irsend --device=/dev/lircd SEND_ONCE $REMOTE_NAME $digit
  sleep 0.5
  done
  irsend --device=/dev/lircd SEND_ONCE $REMOTE_NAME enter
  exit 0
fi

cmdpath=/mediastore/videos/downloads/on-demand-commands/$1

if [ ! -f $cmdpath ]; then
  echo Unable to find cmd file at $cmdpath
  exit -1
fi

# Use the channel as the file name
RecordType=
Name=
Season=
Episode=
Channel=
Navigate=
while read line
do
  #echo Line is: $line
  if [[ $line == *RecordType*=* ]]; then
    temp=${line##*=}
    RecordType=$(echo "$temp" | sed -e 's/^ *//g;s/ *$//g')
  fi

  if [[ $line == *Name*=* ]]; then
    temp=${line##*=}
    Name=$(echo "$temp" | sed -e 's/^ *//g;s/ *$//g')
  fi

  if [[ $line == *Season*=* ]]; then
    temp=${line##*=}
    Season=$(echo "$temp" | sed -e 's/^ *//g;s/ *$//g')
  fi

  if [[ $line == *Episode*=* ]]; then
    temp=${line##*=}
    Episode=$(echo "$temp" | sed -e 's/^ *//g;s/ *$//g')
  fi

  if [[ $line == *Channel*=* ]]; then
    temp=${line##*=}
    Channel=$(echo "$temp" | sed -e 's/^ *//g;s/ *$//g')
  fi

  if [[ $line == *Navigate*=* ]]; then
    temp=${line##*=}
    Navigate=$(echo "$temp" | sed -e 's/^ *//g;s/ *$//g')
  fi
done <$cmdpath

BaseDirPath=/mediastore/videos/recordings/on-demand/
BaseRecordingPath=${BaseDirPath}recording_info/

if [ -z "$RecordType" ]; then
  echo RecordType not present in file $cmdpath
  exit -1
fi

if [ -z "$Name" ]; then
  echo Name not present in file $cmdpath
  exit -1
fi

if [ -z "$Channel" ]; then
  echo Channel not present in file $cmdpath
  exit -1
fi

if [ -z "$Navigate" ]; then
  echo Navigate not present in file $cmdpath
  exit -1
fi

fullPath=$BaseDirPath"$RecordType"
fileName=${BaseRecordingPath}${RecordType}_"${Name}"

if [ ! -d "$fullPath" ]; then
  mkdir "$fullPath"
  chmod 777 "$fullPath"
fi

fullPath="${fullPath}"/"$Name"
if [ ! -d "$fullPath" ]; then
  mkdir "$fullPath"
  chmod 777 "$fullPath"
fi

if [ ! -z "$Season" ]; then
  fullPath="$fullPath"/"$Season"
  if [ ! -d "$fullPath" ]; then
    mkdir "$fullPath"
    chmod 777 "$fullPath"
  fi
  fileName="${fileName}"_Season"${Season}"
  if [ ! -z "$Episode" ]; then
    fullPath="$fullPath"/"$Episode"
    if [ ! -d "$fullPath" ]; then
      mkdir "$fullPath"
      chmod 777 "$fullPath"
    fi
    fileName="${fileName}"_Episode"${Episode}"
  fi
fi

#echo fullPath = $fullPath
#echo fileName = $fileName

sleep 0.5
for digit in $(echo $Channel | sed -e 's/./& /g'); do
  echo doing irsend $digit
  irsend --device=/dev/lircd SEND_ONCE $REMOTE_NAME $digit
  sleep 0.5
done
#irsend --device=/dev/lircd SEND_ONCE $REMOTE_NAME enter

for button in $Navigate; do
  if [ -z $button ]; then
    continue
  fi

  if [ $button -eq $button 2> /dev/null ]; then
    echo doing sleep $button
    sleep $button
  else
    echo doing irsend $button
    irsend --device=/dev/lircd SEND_ONCE $REMOTE_NAME $button
  fi
done

record_reference=`printf "%03d" $1`
record_reference=2${record_reference}_`date +%Y%m%d%I%M%S`
touch "$fileName"
chmod 777 "$fileName"
echo RecordRef=$record_reference > "$fileName"

exit 0


GP
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mythtv.org/pipermail/mythtv-users/attachments/20100414/c849f516/attachment.htm>


More information about the mythtv-users mailing list