[mythtv] How do you delete the database except for recorded
videos
Brent Borghese
mythtv-dev@snowman.net
Thu Jan 2 04:04:30 EST 2003
--=-ok1WlKGFGBkkpne9ljGM
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
A new version of the script with a bug fix.
Brent
On Wed, 2003-01-01 at 21:15, Brent Borghese wrote:
> > Will this allow me to rebuild the recorded video database from the
> > video files stored on the hard disk if I decide to just delete the whole
> > database and start over?
>
> Yes, it will help you do that.
>
> But, you will not have the name of the shows. When you go to play, it
> will have the channel, date, time and the name will be: ???
>
> It is possible to lookup the info, but with no database that would not
> work.
>
> That is why I think there should be a XML file with each video file.
> Then if you delete your database and have a script to put things back in
> after a upgrade.
>
> Brent
>
>
>
> > On Wed, 2003-01-01 at 17:49, Brent Borghese wrote:
> > > > 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 current
> > > > videos recorded in the hard drive of course. Thanks
> > >
> > > Here is a shell script that will check the database and your video store
> > > to make sure they are in sync.
> > >
> > > It has only been tested on the current CVS!
> > >
> > > 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
> > > database.
> > >
> > > For now it does not check for duplicate DB entries.
> > >
> > > Brent
> > >
> > > ----
> > >
>
> > > #!/bin/bash
> > > store=$(mysql -D mythconverg --batch -s -e "select * from settings
> ;"|grep RecordFilePrefix|awk '{ print $2 }')
> > > mysql -D mythconverg --batch -s -e "select * from recorded ;"|awk '{
> print $1 "_" $2 "_" $3 ".nuv" }'|sort>/tmp/flist.txt
> > > cd $store
> > > find . -name "*.nuv"|awk -F/ '{print $2}'|sort|grep -v ringbuf
> >/tmp/flist2.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=$(cat /tmp/flist2.txt|wc -l)
> > >
> > > # Get the number of video files in the DB
> > > fileDBCount=$(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) != "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="'" -F "[_.]" '{ print "mysql -D
> mythconverg --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
> > > NoDBCount=$(cat /tmp/NoDB.txt|wc -l)
> > > if [ $NoDBCount != "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=$store -F "[_.]" '{ print "rm -f
> " store "/" $1 "_" $2 "_" $3 ".nuv" }'
> > > done
> > > else
> > > 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=" $1 " and starttime=" $2 "
> and endtime=" $3 " ;\"" }'>/tmp/NoFile.txt
> > > done
> > > NoFileCount=$(cat /tmp/NoFile.txt|wc -l)
> > > if [ $NoFileCount != "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
> /tmp/NoDB.txt /tmp/NoFile.txt
> > >
> > >
>
>
> > _______________________________________________
> > mythtv-dev mailing list
> > mythtv-dev@snowman.net
> > http://www.snowman.net/mailman/listinfo/mythtv-dev
>
> _______________________________________________
> mythtv-dev mailing list
> mythtv-dev@snowman.net
> http://www.snowman.net/mailman/listinfo/mythtv-dev
--=-ok1WlKGFGBkkpne9ljGM
Content-Disposition: attachment; filename=mythDBck.sh
Content-Transfer-Encoding: quoted-printable
Content-Type: text/x-sh; name=mythDBck.sh; charset=ISO-8859-1
#!/bin/bash
store=3D$(mysql -D mythconverg --batch -s -e "select * from settings ;"|gre=
p RecordFilePrefix|awk '{ print $2 }')
mysql -D mythconverg --batch -s -e "select * from recorded ;"|awk '{ print =
$1 "_" $2 "_" $3 ".nuv" }'|sort>/tmp/flist.txt
cd $store
find . -name "*.nuv"|awk -F/ '{print $2}'|sort|grep -v ringbuf >/tmp/flist2=
.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 mythc=
onverg --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 --bat=
ch -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 /tmp/N=
oDB.txt /tmp/NoFile.txt
--=-ok1WlKGFGBkkpne9ljGM--
More information about the mythtv-dev
mailing list