[mythtv] Mythtv Show Verification Script !!! DO NOT USE !!!
Bruce Markey
mythtv-dev@snowman.net
Tue Jan 14 08:05:52 EST 2003
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!
You may not mind this risk yourself but you have no business
imposing it on others!
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 ;-).
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.
-- 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
>
>
> ------------------------------------------------------------------------
>
> #!/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... below and run ./verifyshows.pl or copy it to a bin dir in
> # your path and run verifyshows.pl
>
> use DBI; # if you are having problems install the Perl Mysql DBI module check http://search.cpan.org
>
> # Edit the next line to match your mythtv store directory
> $path = "/mnt/store/"; # Trailing slash is important will not work without it ex store/
>
> # Edit the next 2 lines to match your db username and password
> $user='YourDbUserName';
> $pass='YourDbPassword';
>
> $dbh=DBI->connect('dbi:mysql:mythconverg',$user,$pass) || die "$DBI::errstr";
>
> opendir (DIRLIST, $path) || die print "Could not open $path: You must specify it in this file!\n";
> @dirlist = readdir (DIRLIST);
> $count = 0;
>
> foreach (@dirlist) {
> my $exists = 0;
> if ($_ =~ /nuv/ && $_ !~ /ringbuf/) {
> $count++;
> print "Checking File # $count $_\n";
> $exists = verify($_);
> if ($exists) { print "\n"; }
> else {
> print "$_ does _NOT_ exist. Deleting this file.\n\n";
> system "/bin/rm $path$_";
> }
> }
> }
> close (DIRLIST);
>
> sub verify {
> my $show = $_[0];
> my $chanid;
>
> $showperm = $show;
> $show =~ s/.nuv//g;
>
> @holdinfo = split(/_/, $show);
>
> $sth = $dbh->prepare("SELECT title,subtitle,chanid FROM recorded WHERE starttime='$holdinfo[1]' AND endtime='$holdinfo[2]' AND chanid='$holdinfo[0]' LIMIT 1;");
> $sth->execute || die "Unable to execute query: $dbh->errstr\n";
>
> $row=0;
>
> while($row = $sth->fetchrow_arrayref)
> {
> $title=$row->[0];
> $subtitle=$row->[1];
> $chanid=$row->[2];
>
> print "EXISTS: $showperm == $title - $subtitle\n";
>
> }
> if ($chanid) {
> return 1;
> }
> else {
> return 0;
> }
> }
>
More information about the mythtv-dev
mailing list