[mythtv] Purging video files
Chris
mythtv-dev@snowman.net
Fri Jan 10 19:39:05 EST 2003
Is there a way to delete the scheduled recordings and start over while
maintaining the list of recorded videos. Certain scheduled programs
conflict with themselves in my database. Thanks
On Fri, 2003-01-10 at 01:11, Brent Borghese wrote:
> I wrote a Purge shell script for Mythtv.
>
> What it will do is read from the database where is video store is and
> delete the oldest video file and remove the database entry for that
> file. It will do this till there is at least 15G(The default) free.
>
> The default of 15G can be changed by passing a argument to the script
> with the new size, in K.
>
> It can be run from cron, I run it every hour on the half hour.
>
> 30 * * * * /usr/local/bin/mythPurge.sh
>
> This will purge at 5G
>
> 30 * * * * /usr/local/bin/mythPurge.sh 5000000
>
> I did see some database changes in the CVS a day or so and do not know
> if this will still work, I think it should.
>
> To install the script copy it to /usr/local/bin
>
> If some one can put a "Save Until I delete field" in the database, I can
> then check for that so programs can be saved.
>
> Brent
>
> ----
>
> #!/bin/bash
> # This script is licensed under the GNU GENERAL PUBLIC LICENSE
> # Writen by: Brent Borghese
> #
> # Change the next line to the purge size in K, so 15G will be 15000000
> PurgeAt=15000000
> if [ $# -gt 0 ]; then
> PurgeAt=$1
> fi
> store=$(mysql -D mythconverg --batch -s -e "select * from settings ;"|grep RecordFilePrefix|awk '{ print $2 }')
> mysql -D mythconverg --batch -s -e "select * from recorded group by starttime asc;"|awk '{ print $2 " " $1 "_" $2 "_" $3 ".nuv" }'|head -n 1 >/tmp/mythpurge.txt
> freespace=$(df -k $store |grep -v "Filesystem"|awk '{ print $4 }')
> OldestFile=$(cat /tmp/mythpurge.txt|awk '{ print $2 }')
> OldestName=$(mysql -D mythconverg --batch -s -vvv -e "select * from recorded group by starttime asc ;"|awk -F "|" '{ print $5 " - " $6 }'|head -n 8|tail -n 1)
>
> channel=$(echo $OldestFile|awk -F _ '{ print $1 }')
> starttime=$(echo $OldestFile|awk -F _ '{ print $2 }')
> echo "PurgeAt: " $PurgeAt
> #echo "freespace:" $freespace
> #echo "channel: " $channel
> #echo "starttime: " $starttime
> if [ $PurgeAt -gt $freespace ]; then
> echo We need to purge a file
> echo Deleting the oldest show from DB: $OldestName
> mysql -D mythconverg --batch -s -e "delete from recorded where chanid=$channel and starttime= $starttime ;"
> echo Deleting the oldest file Video: $OldestFile
> rm -f $store/$OldestFile
> sleep 1
> $0 $PurgeAt
> else
> echo No need to purge
> fi
>
More information about the mythtv-dev
mailing list