[mythtv-users] Default recording/storage group

Rich West Rich.West at wesmo.com
Thu May 3 16:07:31 UTC 2007


aaron wrote:
> On 30/04/07, Rich West <Rich.West at wesmo.com> wrote:
>   
>> We recently broke apart all of our recordings in to separate groups so
>> that the Kids stuff all ended up in one group.  As such, the need for
>> the Default really isn't there for us any longer (I have a group of
>> stuff I like to watch, my wife has a group set to herself, and we have a
>> group for the stuff we both like to watch together).  Is there a way to
>> effectively rename the "Default" group?
>>     
>
> Seems like we ignored your actual question and went on to other things....
>
> This assumes recording group, rather than store group... And someone
> please step in and correct me if I'm spewing nonsense or overly
> out-of-date information; it's been ages since I looked at this stuff
> in any detail.
>
> >From my understanding, the "group" that a recording belongs to is just
> a field in the database. In the days before the popup keyboard, I kept
> having trouble moving recordings into groups that weren't named with
> numbers, so I'd have to bring up the frontend on another machine with
> a keyboard to move recordings.
>
> Anyway, I believe a group disappears when there are no more recordings
> in it. The Default group might be special, though.
>
> To move a recording from one group to another you can just update the
> appropriate field in the database.
>
> So, technically, I think you should just be able to update the
> rebuilddatabase script to use a different group for the recordings it
> adds. I haven't looked at this script so I'm not sure how easy that
> would be to do. The last time I needed to "rebuild" my database the
> script didn't exist.

Thanks!  In fact, that is exactly what I did.  I updated the
myth.rebuilddatabase.pl script to ask for the recording group as part of
its series of questions, with the default group hardcoded to "Default". 
It worked exactly as I had hoped, and it really didn't require many changes.

I've attached a unified patch which outlines my changes.

-Rich


--- myth.rebuilddatabase.pl.old      2007-04-24 18:41:20.000000000 -0400
+++ myth.rebuilddatabase.pl.new        2007-05-03 11:55:11.000000000 -0400
@@ -188,7 +188,7 @@
 my $dbh = DBI->connect("dbi:mysql:database=$database:host=$dbhost",
                "$user","$pass") or die "Cannot connect to database ($!)\n";
 
-my ($starttime, $endtime, $title, $subtitle, $channel, $description);
+my ($starttime, $endtime, $title, $subtitle, $channel, $description,
$recgroup);
 my ($syear, $smonth, $sday, $shour, $sminute, $ssecond, $eyear,
$emonth, $eday,
                $ehour, $eminute, $esecond);
 
@@ -213,7 +213,7 @@
 $dir =~ s/\/$//;
 
 if ($show_existing) {
-       $q = "select title, subtitle, starttime, endtime, chanid from
recorded order by starttime";
+       $q = "select title, subtitle, starttime, endtime, chanid,
recgroup from recorded order by starttime";
        $sth = $dbh->prepare($q);
        $sth->execute or die "Could not execute ($q)\n";
 
@@ -225,6 +225,7 @@
                $starttime = $row[2];
                $endtime = $row[3];
                $channel = $row[4];
+               $recgroup = $row[5];
 
 ## get the pieces of the time
                if ($starttime =~ m/$db_date_regx/) {
@@ -243,6 +244,7 @@
                print "End time:   $emonth/$eday/$eyear -
$ehour:$eminute:$esecond\n";
                print "Title:      $title\n";
                print "Subtitle:   $subtitle\n\n";
+               print "Group:      $recgroup\n\n";
        }
 }
 
@@ -357,6 +359,7 @@
         $newsubtitle = GetAnswer("... subtitle", $newsubtitle);
         $newdescription = GetAnswer("Description", $newdescription);
         $starttime = GetAnswer("... start time (YYYY-MM-DD HH:MM:SS)",
$starttime);
+        $recgroup = GetAnswer("... Recording Group", "Default");
 
         if ($endtime) {
             $duration = (str2time($endtime) - str2time($starttime)) / 60;
@@ -377,14 +380,14 @@
         $mythfile = sprintf("%s_%s.%s", $channel, $time1, $ext);
     }
 
-    my $sql = "insert into recorded (chanid, starttime, endtime, title,
subtitle, description, hostname, basename, progstart, progend) values
((?), (?), (?), (?), (?), (?), (?), (?), (?), (?))";
+    my $sql = "insert into recorded (chanid, starttime, endtime, title,
subtitle, description, hostname, basename, progstart, progend, recgroup)
values ((?), (?), (?), (?), (?), (?), (?), (?), (?), (?), (?))";
 
     if ($test_mode) {
 
         $sql =~ s/\(\?\)/"%s"/g;
         my $statement = sprintf($sql, $channel, $starttime, $endtime,
$newtitle,
                                 $newsubtitle, $newdescription, $host,
$mythfile,
-                                $starttime, $endtime);
+                                $starttime, $endtime, $recgroup);
         print("Test mode: insert would have been been:\n");
         print($statement, ";\n");
 
@@ -393,7 +396,7 @@
         $sth = $dbh->prepare($sql);
         $sth->execute($channel, $starttime, $endtime, $newtitle,
                       $newsubtitle, $newdescription, $host, $mythfile,
-                      $starttime, $endtime)
+                      $starttime, $endtime, $recgroup)
             or die "Could not execute ($sql)\n";
 
         if ($mythfile ne $showBase) {



More information about the mythtv-users mailing list