[mythtv] How do you delete the database except for recorded
videos
Brent Borghese
mythtv-dev@snowman.net
Wed Jan 1 22:49:06 EST 2003
--------------=_4D48010AE2A809EDDF40
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
> I have multiple entries of the same show listed in Fix Recording
> conflicts( a show conflicting with itself). Is there a way to delete
> this section of the database? I want to keep the listing of the curre=
nt
> videos recorded in the hard drive of course. Thanks
Here is a shell script that will check the database and your video store=
=20
to make sure they are in sync.
It has only been tested on the current CVS! =20
What the script does so far:
- Makes sure all DB entries have a video file on disk
- Makes sure all video files have DB entries
- If there are missing DB entries or missing files, it will display the =
mysql command that will fix it.
You will need to run it as root or what ever user has access to the myth=
=20
database.
For now it does not check for duplicate DB entries.
Brent=20
--------------=_4D48010AE2A809EDDF40
Content-Description: filename="mythDBck.sh"
Content-Disposition: inline; filename="mythDBck.sh"
Content-Type: text/plain; name ="mythDBck.sh"
Content-Transfer-Encoding: quoted-printable
#!/bin/bash
store=3D$(mysql -D mythconverg --batch -s -e "select * from settings ;"|=
grep RecordFilePrefix|awk '{ print $2 }')
mysql -D mythconverg --batch -s -e "select * from recorded ;"|awk '{ pri=
nt $1 "_" $2 "_" $3 ".nuv" }'|sort>/tmp/flist.txt
cd $store
find . -name "*.nuv"|awk -F/ '{print $2}'|sort|grep -v ringbuf >/tmp/fli=
st2.txt
diff /tmp/flist.txt /tmp/flist2.txt|egrep "[<>]">/tmp/flist3.txt
cat /tmp/flist3.txt|sed -e 's/</No File found for DB entery:/'|sed -e 's=
/>/No DB entery for file:/'>/tmp/flist4.txt
# Get the number of video files in the store
fileCount=3D$(cat /tmp/flist2.txt|wc -l)
# Get the number of video files in the DB
fileDBCount=3D$(cat /tmp/flist.txt|wc -l)
echo Total number of files found : $fileCount
echo Total number of DB entries found: $fileDBCount
echo Checking to make sure things match.
if [ $(cat /tmp/flist4.txt|wc -l) !=3D "0" ] ; then
echo "Here is a list of problems found"
cat /tmp/flist4.txt
fi
# get the number of missing DB entries
touch /tmp/NoDB.txt
for line in $(cat /tmp/flist3.txt|grep ">"|awk '{ print $2 }') ;
do echo $line >/tmp/line.txt ;
cat /tmp/line.txt |awk -v qq=3D"'" -F "[_.]" '{ print "mysql -D my=
thconverg --batch -s -e \"insert into recorded values (" qq $1 qq "," qq=
$2 qq "," qq $3 qq "," qq "???" qq "," qq "???" qq "," qq "???" qq ") ;=
\"" }'>/tmp/NoDB.txt
done=20
NoDBCount=3D$(cat /tmp/NoDB.txt|wc -l)
if [ $NoDBCount !=3D "0" ]; then
echo
echo "Commands to fix: No DB entery"
echo "----------------------------"
cat /tmp/NoDB.txt
echo Or to free up disk space you can do:
for line in $(cat /tmp/flist3.txt|grep ">"|awk '{ print $2 }') ;
do echo $line >/tmp/line.txt ;
cat /tmp/line.txt |awk -v store=3D$store -F "[_.]" '{ print "rm =
-f " store "/" $1 "_" $2 "_" $3 ".nuv" }'
done=20
else=20
echo All Files have DB entries
fi
# Get the number of missing files
touch /tmp/NoFile.txt
for line in $(cat /tmp/flist3.txt|grep "<"|awk '{ print $2 }') ;
do echo $line >/tmp/line.txt ;
cat /tmp/line.txt |awk -F "[_.]" '{ print "mysql -D mythconverg --=
batch -s -e \"delete from recorded where chanid=3D" $1 " and starttime=3D=
" $2 " and endtime=3D" $3 " ;\"" }'>/tmp/NoFile.txt
done=20
NoFileCount=3D$(cat /tmp/NoFile.txt|wc -l)
if [ $NoFileCount !=3D "0" ]; then
echo
echo "Commands to fix: No File found for DB entery"
echo "--------------------------------------------"
cat /tmp/NoFile.txt
else
echo All DB entries have a file in the store.
fi
rm -f /tmp/flist.txt /tmp/flist2.txt /tmp/flist3.txt /tmp/flist4.txt /tm=
p/NoDB.txt /tmp/NoFile.txt
--------------=_4D48010AE2A809EDDF40--
More information about the mythtv-dev
mailing list