[mythtv] Mythtv Show Verification Script !!! DO NOT USE !!!

Nathan Langley mythtv-dev@snowman.net
Tue Jan 14 15:36:50 EST 2003


--=-Tkr1nXCJavmLTlp5WZWw
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Attached to this email is a non destructive version of the script I
submitted earlier.  This one just prints a report and does not actually
delete anything.

On Tue, 2003-01-14 at 02:05, Bruce Markey wrote:
> TIME OUT!
> 
> Nathan, what happens if the tables change? or a query times
> out? or the server crashes or is shutdown after the connect
> succeeds? This WILL blindly delete ALL OF YOUR FILES!
Actually it should not because it exits on database errors
> 
> You may not mind this risk yourself but you have no business
> imposing it on others!
I am not imposing it, I am offering it.  I never said you _must_ use
this.  If you don't want to use it, don't.  Who ever said you have to
use every script posted to this mailing list.  Some people might find it
helpful some might not.  
> 
> A more reasonable behavior would be to list the files that
> are unaccounted for and allow the user to decide if they
> want ot delete (or "| rm" but I sure don't advocate this ;-).
Attached to this email is a new version that just gives a report.  It
does not actually delete anything. 
> 
> Even better would be to ADD the other files to the recorded
> list with the title "Unknown" so they can be viewed and the
> user can decide if they want to watch them or delete them.
There is already a script that was posted to this mailing list (don't
know by who) that does this.  I did not want this because I do not care
about partial or missing shows.  If they are not in the db I want them
gone.

> --  bjm
> 
> 
> Nathan Langley wrote:
> > This is a perl script that will verify that the shows in your store 
> > directory are in your db.  If they are not it will _DELETE_ them.  I had 
> > been getting a few partial shows that did not finish staying on my drive 
> > so I decided to write this to wax them automaticly.  The user you run this 
> > script as must have rw access to the files in your store directory.
> > 
> > To use this _EDIT_ the file verifyshows.pl and follow the Edit next line 
> > Directions.  (You have to put in your store dir and your db username and 
> > pass)
> > 
> > NOTICE: THIS SCRIPT DOES DELETE MYTHTV RECORDING FILES
> >  
> > I will not be held responsible if it deletes actual recordings (even 
> > though it should not)
> > 
> > 
> >  -- 
> > Nathan Langley
> > Victoria Internet Providers
> > 361-572-3230


--=-Tkr1nXCJavmLTlp5WZWw
Content-Disposition: attachment; filename=verifyshows.pl
Content-Transfer-Encoding: quoted-printable
Content-Type: text/x-perl; name=verifyshows.pl; charset=UTF-8

#!/usr/bin/perl
# Mythtv show verify script (Deletes shows on the harddisk that are not in =
the db
# Written by Nathan Langley :: nathan@viptx.net
# Requirements: Perl,Perl DBI Mysql
# This be a comment
# IMPORTANT: This program comes with absolutly NO warranty.  If it deletes =
something you did not want it to I am not liable.  If it kills your system =
you
# are on your own.  I take no resposiblity for _anything_
# INSTRUCTIONS: Change the configurations I marked with Edit the next... be=
low and run ./verifyshows.pl or copy it to a bin dir in=20
# your path and run verifyshows.pl

   use DBI; # if you are having problems install the Perl Mysql DBI module =
check http://search.cpan.org
  =20
   # Edit the next line to match your mythtv store directory
   $path =3D "/mnt/store/"; # Trailing slash is important will not work wit=
hout it ex store/=20
  =20
   # Edit the next 2 lines to match your db username and password
   $user=3D'YourDbUserName';
   $pass=3D'YourDbPassword';
  =20
   $dbh=3DDBI->connect('dbi:mysql:mythconverg',$user,$pass) || die "$DBI::e=
rrstr";
  =20
   @good;
   @bad;

   opendir (DIRLIST, $path) || die print "Could not open $path: You must sp=
ecify it in this file!\n";
   @dirlist =3D readdir (DIRLIST);
   $count =3D 0;
  =20
   foreach (@dirlist) {
       my $exists =3D 0;
       my $consoleinput;
      =20
       if ($_ =3D~ /nuv/ && $_ !~ /ringbuf/) {
	 $count++;
	=20
	 $exists =3D verify($_);
	 if ($exists) { print "\n"; }=20
	 else {=20
	     push (@bad, "$path$_");
	 }
       }
    }
   close (DIRLIST);   =20

  if (@good) {=20
      print "\nVALID SHOWS:\n";
      foreach (@good) {=20
	  print "$_\n";
      }
  }
 =20
  else { print "I did not find any valid shows.  This is probably a problem=
.  Do NOT delete anything.\n"; exit; }
 =20
  print "\n\nSHOWS NOT LISTED IN THE DB:\n";
  foreach (@bad) {=20
      print "$_\n";=20
  }
     =20
sub verify {
    my $show =3D $_[0];
    my $chanid;
   =20
    $showperm =3D $show;
    $show =3D~ s/.nuv//g;
   =20
    @holdinfo =3D split(/_/, $show);
   =20
    $sth =3D $dbh->prepare("SELECT title,subtitle,chanid FROM recorded WHER=
E starttime=3D'$holdinfo[1]' AND endtime=3D'$holdinfo[2]' AND chanid=3D'$ho=
ldinfo[0]' LIMIT 1;");
    $sth->execute || die "ERROR: Unable to execute query: $dbh->errstr\n";
  =20
    $row=3D0;
  =20
    while($row =3D $sth->fetchrow_arrayref)
    {
	 $title=3D$row->[0];	=20
	 $subtitle=3D$row->[1];
	 $chanid=3D$row->[2];

  	 push (@good, "$showperm =3D=3D $title - $subtitle");

    }
    if ($chanid) {
	return 1;
    }
    else {
	return 0;
    }
}
	=20

--=-Tkr1nXCJavmLTlp5WZWw--




More information about the mythtv-dev mailing list