No subject


Thu May 18 18:34:19 UTC 2006


what they are.  This is a slightly modified version of a script written by
Daniel Hyams, sourced from his excellent Ubuntu HOWTO, at 

http://s91928265.onlinehome.us/hfamily/mythtv/myth_ubuntu.html

I made a couple of modifications for readability -- you'll need to edit the
script to put in your recording path and DB information.

Adam

-- 
<adam at baz.org>           We're never as good as our myths, but surely it says
<adam hirsch>            something that our myths are good.     -James Lileks

--x+6KMIRAuhnl3hBn
Content-Type: application/x-sh
Content-Disposition: attachment; filename="mythshows.sh"
Content-Transfer-Encoding: quoted-printable

#!/usr/bin/perl=0A# m0j0.j0j0 =0A# Mythtv show verify script (Deletes incor=
rect files)=0A=0A# Hacked a by Daniel to just show the show names mapped to=
 the filenames.  I finally understand=0A# how to dive into the mythconverg =
database and get information from it.=0A=0A# Minor additions by Adam (mytht=
v at quakerporn.com) for readability=0A=0A####### for reference=0A#% mysql -p=
=0A#mysql> use mythconverg;=0A#mysql> select * from jumppoints;=0A#mysql> s=
elect * from recordings;=0A###mysql> update jumppoints set keylist=3D"F5" w=
here destination=3D"MythGallery";=0A###################=0A=0A=0Ause DBI;=0A=
use Time::Local;=0A=0A# Edit the next line to match your mythtv store direc=
tory=0A$path =3D "/stuff/mythtv/"; =0A=0A# What's the db user mythtv uses? =
 (almost certainly "mythtv")=0A$user=3D'mythtv';=0A=0A# Grab the DB passwor=
d from the file where myth stores it.=0A=0A$pass=3D`grep DBPassword $path/.=
mythtv/mysql.txt | cut -f2 -d'=3D'`;=0Achomp($pass);=0A=0A=0A$dbh=3DDBI->co=
nnect('dbi:mysql:mythconverg',$user,$pass) || die "$DBI::errstr";=0A=0A$sth=
 =3D $dbh->prepare("SELECT chanid,starttime,endtime,title,subtitle FROM rec=
orded;");=0A$sth->execute || die "Unable to execute query: $dbh->errstr\n";=
=0A=0A$row=3D0;=0Awhile($row =3D $sth->fetchrow_arrayref)=0A{=0A	$chanid=3D=
$row->[0];=0A	$starttime=3D$row->[1];=0A	$endtime=3D$row->[2];=0A	$title=3D=
$row->[3];=0A	$subtitle=3D$row->[4];=0A=0A        $_ =3D $starttime;=0A    =
    s/://g;=0A        s/-//g;=0A        s/ //g;=0A        $starttime =3D $_=
;=0A=0A        $_ =3D $endtime;=0A        s/://g;=0A        s/ //g;=0A     =
   s/-//g;=0A        $endtime =3D $_;=0A=0A	my $file =3D  $path . $chanid .=
 "_" . $starttime . ".mpg";=0A       =0A	my $bytes =3D (stat $file)[7] / (1=
024 * 1024);=0A=0A	my $FileSize =3D sprintf("%.2f", $bytes);=0A	my ($ModTim=
e) =3D (stat $file)[9];=0A=0A	my $Time =3D timelocal($seconds, $minutes, $h=
ours, (localtime)[3,4,5]);=0A	my $TimeDiff =3D $Time - $ModTime; # Diff > 1=
800 --> 30Min =0A=0A		print "$file : "; =0A		printf ("%20s", "$FileSize meg=
abytes");=0A		print sprintf("%60s", "$title [$subtitle]\n");=0A=0A#		$sth2 =
=3D $dbh->prepare("DELETE FROM recorded WHERE chanid=3D$chanid AND starttim=
e=3D$starttime;");=0A#		$sth2->execute || die "Unable to execute query: $db=
h->errstr\n";=0A#		unlink($file) || die("Couldn't unlink: $file $!");=0A=0A=
}=0A=0A
--x+6KMIRAuhnl3hBn--


More information about the mythtv-users mailing list