Creating a TV Bouquet

From MythTV Official Wiki
Revision as of 13:57, 4 November 2010 by Wagnerrp (talk | contribs) (shift link)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


These days with a lot of Satellites providing 100's of channels and having multiple satellites connected to your MythTV it becomes very tedious to browse through the various channels to get to the ones you want to watch. Settop boxes provide Bouquets which let you categorize your channels into favorites for you and your family. This doc provides a means of setting up manually 2 different bouquets (as an example) for your wife and your kids. This also lets you hide unwanted channels from others.

Get a list of all channels

The first step once you have all your satellite channels scanned is to connect to the database and dump all channels to a text file like so:

$ mysql -s -e 'select chanid,name from channel'  mythconverg >all.chan

I'm assuming you have the 'user' and 'password' setup in your [client] section in /etc/my.cnf or ~/.my.cnf for the mythtv user so you don't have to provide a user or pass on the command line.

This should give you a list in the file 'all.chan' of all the channels you have

Create the bouquet of channels

Next extract from the 'all.chan' file, with a text editor, all the channels for your wife and kids and create separate files - lets call these files 'wife.chan' and 'kids.chan'

I put all these files in /home/mythtv/scripts (along with other scripts) but you may chose your location.

Create a bouquet changing script

The following script (which we will call 'changebouquet' and also place in the /home/mythtv/scripts directory) needs to be created.

Script.png /home/mythtv/scripts/changebouquet

 #!/bin/bash
 CPATH=/home/mythtv/scripts
 SQL=$CPATH/sql.txt
 
 if [ -f $CPATH/$1 ]; then
   echo "start transaction;" >$SQL
   echo "update channel set visible=0;" >>$SQL
   while read chan desc
   do
    echo "update channel set visible=1 where chanid=$chan;" >>$SQL
   done  < $CPATH/$1
   echo "commit;" >>$SQL
   mysql mythconverg <$SQL
 else
   mysql -e 'update channel set visible=1;' mythconverg
 fi

Make the script executable

$ chmod +x /home/mythtv/scripts/changebouquet

Create a menu ui item for these bouquets

Next you can either create a menu item in the TV menu or assign a button on your remote to do the same thing. Here i will assign three menu items. One for the wife, one for the kids and the last is to revert back to all channels which gives you back all your channels as before

First make a copy of the menu

$ cp /usr/share/mythtv/tvmenu.xml ~/tvmenu.xml.orig

Next open the file /usr/share/mythtv/tvmenu.xml with a text editor (as root) and put the following section somewhere in between another <button> block where you'd like it to appear.

Script.png /usr/share/mythtv/tvmenu.xml

...

    <button>
       <type>TV_SCHEDULE</type>
       <text>Wife's boring bouquet</text>
       <action>EXEC /home/mythtv/scripts/changebouquet wife.chan</action>
    </button>
    <button>
       <type>TV_SCHEDULE</type>
       <text>Kids fun bouquet</text>
       <action>EXEC /home/mythtv/scripts/changebouquet kids.chan</action>
    </button>
    <button>
       <type>TV_SCHEDULE</type>
       <text>All channels</text>
       <action>EXEC /home/mythtv/scripts/changebouquet default</action>
    </button>

...

EDIT: Fixed a typo which will hang or restart the frontend. </action> was </text> fixed now. Nice howto works nice, thumps Up

Use the new bouquet

Restart the frontend and start surfing your bouquet ! You should now be able to see your bouquet in the TV menu.

You can extend the script to automatically jump to watching tv with your new bouquet if you have the Frontend control socket interface by just adding the line

echo 'jump livetv' | netcat -q 0 localhost 6546

to the end of the 'changebouquet' script shown above