Author Topic: Mythtv channels  (Read 6969 times)

Pnuts

  • Veteran
  • ***
  • Posts: 130
    • View Profile
Mythtv channels
« on: May 04, 2009, 07:53:36 pm »
Hopfully a simple question for someone.

I found the following script online for exporting a channels.conf file from the mythtv database. I want to be able to do this so if I reinstall LMCE, I can import all of my channels again. I know I will have to update user\pass for it to work.

Code: [Select]
#!/usr/bin/perl -w

use strict;
use DBI;
use Getopt::Long;

my $dbhost="127.0.0.1";
my $database="mythconverg";
my $user="mythtv";
my $pass="mythtv";
my $sourceid = 1;
my $hidden = 0;

GetOptions('dbhost=s'=>\$dbhost,
           'database=s'=>\$database,
           'user=s'=>\$user,
           'pass=s'=>\$pass,
           'sourceid=i'=>\$sourceid,
           'hidden!'=>\$hidden
           ) || die "Usage:";

my $dbh = DBI->connect("dbi:mysql:database=$database:host=$dbhost","$user","$pass") || die "Cannot connect to database ($!)\n";

my $sql = sprintf("SELECT callsign, frequency, modulation, serviceid
                   FROM channel JOIN dtv_multiplex USING (mplexid)
                   WHERE channel.sourceid = ? %s
                   ORDER BY frequency",
                  ($hidden ? "" : "AND channel.visible = 1")
                  );
my $sth = $dbh->prepare($sql);
$sth->execute($sourceid);

while (my @row=$sth->fetchrow_array) {
    my $callsign = $row[0];
    my $frequency = $row[1];
    my $modulation = uc $row[2];
    my $serviceid = $row[3];

    printf "$callsign:$frequency:$modulation:0:0:$serviceid\n";
}

$dbh->disconnect;

Reason I want to do this:
For my area (Bay Area, California, Comcast Digital Cable), only 6 channels are identified and the rest are unknown. In addition, if I choose to exclude encrypted channels, several channels are not scanned. So basically I am scanning everything and then manually correcting each respective channel and removing the encryted ones. Once finished, I want to be able to export this so if i ever perform a reinstall, I will not have to do it again.

Also, If I am going about this the wrong way, let me know before i get to far into manually editing the channels.

Thanks,
Greg

Pnuts

  • Veteran
  • ***
  • Posts: 130
    • View Profile
Re: Mythtv channels
« Reply #1 on: May 04, 2009, 11:00:35 pm »
While I'm on this thought path, I think it might be easier for me to simply make an image of the drive once I finish and I can use that if I ever need to reinstall as it would be faster and have the channels populated correctly already in the image.

The only issue with that is when LMCE 810 is released officially, im going to do a clean install on newer hardware that currently issnt supported in 710. I'll have to figure out a way then to export or move the data over then.

I'll do some testing with the above script tonight and see if it gets teh job done. I was surprised to find so little info about exporting a channel.conf from mythtv, just a lot of exporting it from other programs for mythtv.

ccoudsi

  • Guru
  • ****
  • Posts: 244
    • View Profile
Re: Mythtv channels
« Reply #2 on: July 21, 2009, 01:01:08 am »
I'm also having same problem, did you guys have a chance to test the script???
Cheers |[BEER]
Charlie,

Pnuts

  • Veteran
  • ***
  • Posts: 130
    • View Profile
Re: Mythtv channels
« Reply #3 on: July 21, 2009, 06:17:38 pm »
It worked for me on 810 without any issues. I did not try it on 710, but it probably will still work.

-Pnuts

ccoudsi

  • Guru
  • ****
  • Posts: 244
    • View Profile
Re: Mythtv channels
« Reply #4 on: July 21, 2009, 06:22:23 pm »
Pnuts,
Thanks for the update, I'm also here in the BayArea with Comcast Cable & ScheduleDirect, can you please list your file I'm having difficulties assigning the XMLid code to the scanned channel, I just got about 10% of the channels right.

Thanks.
Cheers |[BEER]
Charlie,

Pnuts

  • Veteran
  • ***
  • Posts: 130
    • View Profile
Re: Mythtv channels
« Reply #5 on: July 21, 2009, 06:25:41 pm »
ill try to remember to do this tonight for ya, meeting with wifes ganny after work so it might be late.

ccoudsi

  • Guru
  • ****
  • Posts: 244
    • View Profile
Re: Mythtv channels
« Reply #6 on: July 21, 2009, 06:41:01 pm »
No rush, just when you get a chance. :)
Cheers |[BEER]
Charlie,