2010-02-07, 21:45
outleradam Wrote:Actually, on seccond thought you could do something like this with a one-liner as a user job to be run after mythicalLibrarian.
Code:test -L "%DIR%/%FILE%" && mysql -uUSERNAME -pPASSWORD "use 'mythconverg' ; DELETE * from recorded where basename like %FILE%; "; *DO THE SAME FOR EACH OF THE DATABASES*; test -L "%DIR%/%FILE%" && rm "%DIR%/%FILE%"
I took this idea and modified it a bit to work for me. I wrote a comanion script for mythical librarian that will delete symlinks and the database entry that accompanies them:
Code:
#!/bin/sh
### myth-remove-from-library.sh - Use to remove a sym-linked mythtv recording and it's database entries
#Grab command line arguments
VIDEODIR=$1
FILENAME=$2
#Make sure we got command line arguments
if [ -z "${VIDEODIR}" -o -z "${FILENAME}" ]; then
echo "Usage: $0 <VideoDirectory> <FileName> "
exit 5
fi
#Test that input files exists and is a symbolic link (we don't want to delete actual recordings)
if [ ! -h "${VIDEODIR}/${FILENAME}" ]; then
echo "File does not exist or is not a symbolic link: ${VIDEODIR}/${FILENAME}"
exit 6
fi
#Remove recording entry from 'mythconverg' mysql database
echo "Removing ${FILENAME} from recorded table"
cat << EOF | mysql -u mythtv -pmythtv mythconverg
DELETE FROM
recorded
WHERE
basename = '${FILENAME}';
EOF
#Remove symblink file and thumbnails
echo "Removing ${FILENAME} file and thumbnails"
rm -f ${VIDEODIR}/${FILENAME}
rm -f ${VIDEODIR}/${FILENAME}.*
exit 0
I then just added a command to execute this script. I added this to mythicalLibrarian.sh in the "MOVE" section, after the Success message is written:
Code:
...
#Send notification to daily report log
dailyreport "$ShowFileName"
echo "@@@@@@@@@@@@@OPERATION COMPLETE" `date` "@@@@@@@@@@@@@@@@">>"$mythicalLibrarian"/output.log
#Use script to remove the sym-link and database entry from mythtv
/home/mythtv/myth-remove-from-library.sh "`dirname "$3"`" "`basename "$3"`"
exit 0
...
Works like a charm. Now I know that any videos still hanging out in the mythtv recordings are not being recognized by mythical librarian and need to be moved manually.