View unanswered posts    View active topics

All times are UTC - 6 hours

Post new topic Reply to topic  [ 3 posts ] 
Print view Previous topic   Next topic  
Author Message
Search for:
PostPosted: Sat Apr 26, 2008 3:39 pm 
Joined: Thu Jun 01, 2006 8:27 pm
Posts: 36
Comcast did it to me again - moved the broadcast HD channels around, so I had to rescan them using mythtv-setup.

I wrote a script that I run every morning to scan the channels, and compare to an existing list. Any differences are printed out. So hopefully, this will allow me to know if I need to rescan before I find out by getting a zero length recording.

To use it, you would first create a reference scan file named scan0.txt.old using
hdhomerun_config FFFFFFFF scan /tuner0 scan0.txt.old

This takes about 10 minutes. Keep this file around.

Then when you want to run this script, create another scan file using hdhomerun_config, then use the two scan file names as arguments to this script.
hdhomerun_config FFFFFFFF scan /tuner0 scan0.txt
python scan0.txt.old scan0.txt

Any differences get printed out like this:
Didn't find  101 1 67.2 MPT Sel
Didn't find  101 2 13.1 PN-2
Didn't find  101 3 67.3 MPT V-M
Didn't find  101 6 67.1 MPTHD

Comments and improvements are welcome.

#!/usr/bin/env python

import os
import string
import sys

class Channel:
    def __init__(self, channel, program, name): int(channel)
        self.program = int(program) = name

    def __cmp__(self, other):
        if ( <
            return -1
        if ( >
            return 1
        if (self.program < other.program):
            return -1
        if (self.program > other.program):
            return 1
        return cmp(,

    def str(self):
        return str( + " " + str(self.program) +

def read_channel_scan(file):
    f = open(file)
    lines = f.readlines()

    channels = [ Channel(0, 0, '0') ]

    for l in lines:
        this_line = l.split()
        if (this_line[0] == "SCANNING:"):
            channel_str = this_line[2]
            this_channel = channel_str[0:-1].split(':')[1]
        if (this_line[0] == "PROGRAM:"):
            this_line = l.split(':')
            this_program = this_line[1]
            if (len(this_line) > 2):
                this_name = this_line[2][:-1]
                hdchan = this_name.split()[0]
                if (hdchan != "0.0" and hdchan != "1008.0"):
                    channels.append(Channel(this_channel, this_program,

    channels = channels[1:]
    return channels

def write_channel_scan(channels, file):
    f = open(file, "w")
    for c in channels:

def compare_channel_scan(channels0, channels1):
    if (len(channels0) != len(channels1)):
        print "lists are of different lengths: ", len(channels0), ", ", len(channels1)
    for c0 in channels0:
        found = 0
        for c1 in channels1:
            if (c0 == c1):
                found = 1
        if (found == 0):
            print "Didn't find ", c0.str()

if __name__ == "__main__":

# Create channel scan
    if (len(sys.argv) < 3):
        print 'Usage:'
        print '\tTo compare two scan files:'
        print '\t\t', sys.argv[0], ' scan0.txt.old scan0.txt'

    if (len(sys.argv) == 3):
        channels0 = read_channel_scan(sys.argv[1])
        channels1 = read_channel_scan(sys.argv[2])
        compare_channel_scan(channels0, channels1)

 Post subject:
PostPosted: Sat Apr 26, 2008 4:11 pm 
Joined: Fri Oct 20, 2006 12:04 pm
Posts: 905
Location: LA, CA
This looks real nice. Have you tried running it from cron maybe with the script? I was thinking of bumping any changes to an email. That way I don't have to babysit the script, but it tells me when it needs my attention.

 Post subject:
PostPosted: Sun Apr 27, 2008 10:37 am 
Joined: Thu Jun 01, 2006 8:27 pm
Posts: 36
I do run it from a cron job on my main desktop. Since the HDHomeRun is just a device on the network, you don't have to run this script from the myth box!


Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours

Who is online

Users browsing this forum: No registered users and 1 guest

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group

Theme Created By ceyhansuyu