Channel Sorting by Script

From MythTV Official Wiki
Jump to: navigation, search

Overview

Channel sorting with the MythTV interface or even with mythweb is a little bit tiresome and especially annoying if you need to repeat it again after another channel scan.

The following script allows you to:

  • retrieve the current channel name list from the mythtv database
  • edit the channel order with your favourite text editor
  • apply the new channel order to the myth database

Channels that are discovered in future channel scans can be easily merged with your current channel sorting.

Download

You can checkout the script from the subversion repository:

svn co https://svn.systemausfall.org/svn/codekasten/mythtv

Or you can directly download the script.

Workflow

The following workflow is recommended:

  1. backup the current channel settings:
    ./channel_sort_mythtv.sh dump >mythtv_channels_dump.sql
  2. retrieve the current list of channel names:
    ./channel_sort_mythtv.sh get >channels.list
  3. sort the channels in 'channels.list' with your favourite text editor
  4. upload the new channel order (starting from channum=1):
    ./channel_sort_mythtv.sh set <channels.list

Adding more channels

If you want to add channels, that were discovered in a later channel scan, then you can run the following:

./channel_sort_mythtv.sh merge <channels.list >channels_new.list

This outputs your previous channel order with all new channels appended to the buttom. Now you can reorder the channels (with your text editor) and apply the new order with the 'set' action again (see above).

Internals

The script uses the database settings from mysql.txt. This file is usually found in /etc/mythtv/mysql.txt (on your backend) or in ~/.mythtv/mysql.txt. You can override these search locations by supplying the environment variable MYSQL_CONF_FILE.

The channel order is applied by changing the channum column of the specific channel in the channel table of the mythtv database. This works for mythtv v0.23. If you are using a newer version of MythTV you should check, if this procedure still works.

All channels in the database, that are not listed in your input order file, are set to a default channel number (by default: 10000). You can change this behaviour in the script. Just look for DEFAULT_CHANNEL.

Channel sort examples

The listings below can be used as templates for applying a suitable channel order to your mythtv database. Just pick the appropriate section for your configuration, save the lines to a file and reorder the lines according to your taste:

Germany (DVB-S)

Das Erste
ZDF

RTL Television
SAT.1
ProSieben
RTL2
kabel eins
VOX
TELE 5
DAS VIERTE
Super RTL
SIXX

3sat
arte
Phoenix
KiKa
NDR FS MV
rbb Berlin
MDR Sachsen
WDR Dortmund
hr-fernsehen
SR Fernsehen
SWR Fernsehen BW
Bayerisches FS Nord
BR-alpha
ZDFinfokanal
zdf_neo
ZDFtheaterkanal
EinsExtra
Einsfestival
EinsPlus

N24
n-tv
BBC World
Sky News Intl
EuroNews
CNBC Europe
CNN Int.
Al Jazeera English
Russia Today
Bloomberg Europe TV
Cartoon Network
Discovery Channel
National Geographic
Disney Channel
MTV Germany
France 24 (en Français)
France 24 (in English)
DSF
Eurosport