[mythtv] [PATCH] nuvexport and mythname.pl

Stefan Frank sfr+lists at 6913304088794.gnuu.de
Sun Aug 22 08:43:53 EDT 2004


Hi,

attached are two patches for nuvexport and mythname.pl.
It adds the mysql.txt parsing code from nuvexport to mythname.pl but
slightly modified. The 2nd patch adds this minor modification to
nuvexport (also search for mysql.txt in /etc/mythtv as that is the
location in Matt's debian packages).

Bye, Stefan

-- 
PENGUINICITY!!
-------------- next part --------------
Index: nuvexport
===================================================================
RCS file: /var/lib/mythcvs/nuvexport/nuvexport,v
retrieving revision 1.16
diff -u -r1.16 nuvexport
--- nuvexport	16 Aug 2004 07:26:03 -0000	1.16
+++ nuvexport	22 Aug 2004 10:16:51 -0000
@@ -201,8 +201,9 @@
 # could be in a couple places, so try the usual suspects
     open(CONF, "$ENV{HOME}/.mythtv/mysql.txt")
         or open(CONF, "/usr/share/mythtv/mysql.txt")
+        or open(CONF, "/etc/mythtv/mysql.txt")
         or open(CONF, "/usr/local/share/mythtv/mysql.txt")
-        or die ("Unable to open /usr/share/mythtv/mysql.txt:  $!\n\n");
+        or die ("Unable to locate mysql.txt:  $!\n\n");
     while (my $line = <CONF>) {
         chomp($line);
         $line =~ s/^str //;
-------------- next part --------------
Index: mythname.pl
===================================================================
RCS file: /var/lib/mythcvs/mythtv/contrib/mythname.pl,v
retrieving revision 1.1
diff -u -r1.1 mythname.pl
--- mythname.pl	17 Apr 2003 18:19:48 -0000	1.1
+++ mythname.pl	22 Aug 2004 10:17:45 -0000
@@ -28,7 +28,7 @@
 
 ## get command line args
 
-my ($database, $host, $user, $pass, $verbose, $dir);
+my ($db_name, $db_host, $db_user, $db_pass, $verbose, $dir);
 
 my $argc=@ARGV;
 if ($argc == 0) {
@@ -49,17 +49,47 @@
 exit(0);
 }
 
-GetOptions('verbose+'=>\$verbose, 'database=s'=>\$database, 'host=s'=>\$host, 
-'user=s'=>\$user, 'pass=s'=>\$pass, 's+'=>\$sub, 'replace=s'=>\$rep, 
+# Read the mysql.txt file in use by MythTV.
+# could be in a couple places, so try the usual suspects
+    open(CONF, "$ENV{HOME}/.mythtv/mysql.txt")
+        or open(CONF, "/usr/share/mythtv/mysql.txt")
+        or open(CONF, "/etc/mythtv/mysql.txt")
+        or open(CONF, "/usr/local/share/mythtv/mysql.txt")
+        or die ("Unable to locate mysql.txt:  $!\n\n");
+    while (my $line = <CONF>) {
+        chomp($line);
+        $line =~ s/^str //;
+        my ($var, $val) = split(/\=/, $line, 2);
+        next unless ($var && $var =~ /\w/);
+        if ($var eq 'DBHostName') {
+            $db_host = $val;
+        }
+        elsif ($var eq 'DBUserName') {
+            $db_user = $val;
+        }
+        elsif ($var eq 'DBName') {
+            $db_name = $val;
+        }
+        elsif ($var eq 'DBPassword') {
+            $db_pass = $val;
+        }
+        elsif ($var eq 'LocalHostName') {
+            $hostname = $val;
+        }
+    }
+    close CONF;
+
+GetOptions('verbose+'=>\$verbose, 'database=s'=>\$db_name, 'host=s'=>\$db_host, 
+'user=s'=>\$db_user, 'pass=s'=>\$db_pass, 's+'=>\$sub, 'replace=s'=>\$rep, 
 'sublen=s'=>\$sublen, 'legal+'=>\$legal);
 
-if (!$host) { $host="127.0.0.1"; }
-if (!$database) { $database="mythconverg"; }
-if (!$user) { $user="mythtv"; }
-if (!$pass) { $pass="mythtv"; }
+if (!$db_host) { $db_host="127.0.0.1"; }
+if (!$db_name) { $db_name="mythconverg"; }
+if (!$db_user) { $db_user="mythtv"; }
+if (!$db_pass) { $db_pass="mythtv"; }
 
 my $dbh = 
-DBI->connect("dbi:mysql:database=$database:host=$host","$user","$pass") or
+DBI->connect("dbi:mysql:database=$db_name:host=$db_host","$db_user","$db_pass") or
 		 die "Cannot connect to database ($!)\n";
 
  ($show, $path, $suffix)  = fileparse(@ARGV[0],"\.nuv");


More information about the mythtv-dev mailing list