ComChecker for Linux

I am releasing ComChecker version .3c for Linux. This version is the same as what is used in the Mac component except that the variables are defined in the script instead of a separate preferences file. I have just started using this on my own server and all is well. The code is after the break and be careful of the line wrapping..

#!/bin/bash

# ComChecker_Linux v 0.3c Copyright 2008, Brandon Jenkins
# This is the same script used on the OS X version with exception to the inclusion of the
# user defined settings. It is a separate file on the Mac.

#Simultaneous comskip executions
SIMUL=5

#Path to wine inside of the wine.bundle
WINEPATH=/usr/bin

#Path to comskip.exe and ini.
CSPATH=/opt/sagetv/comskip

#Path to tv files. Space delimited for multiples.
TVPATH=( /var/media/tv )

#Video file types to scan
VTYPE=( mpg ts )

#Comskip files to look for
CHKEXT=( txt log edl )

#If files exist with these extentions, keep all files related to video
KEEP=( mpg mp4 ts ps )

#Set the interval for checking the directory. Recommend 60 seconds. Live scanning is faster.
DELAY=60

if [ -e “$WINEPATH/Wine.bundle” ]; then APPLE_APP=”Wine.bundle/Contents/bin/”; fi

while [ 1 ] ; do
for (( x = 0 ; x < ${#TVPATH[@]} ; x++ )); do
echo
echo “Processing Videos..”
echo
for (( n = 0 ; n < ${#VTYPE[@]} ; n++ )); do
echo ”    Checking for ${VTYPE[$n]} videos.”
for VIDEO in $(find ${TVPATH[$x]} -type f \( -name *.${VTYPE[$n]} \)); do
echo ”        Found $VIDEO checking processed…”
PROCESSED=0
EPISODE=`basename $VIDEO | cut -d’.’ -f1`
for (( i = 0 ; i < ${#CHKEXT[@]} ; i++ )); do
if [ -f “${TVPATH[$x]}/$EPISODE.${CHKEXT[$i]}” ]; then
PROCESSED=1
fi
done
if [ ! $PROCESSED -eq 1 ]; then
if [ $SIMUL -gt `ps -ef | grep comskip | grep -v grep | wc -l | sed ‘s/ //g’` ]; then
if [ -f “$VIDEO” ]; then
echo ”            Run Comskip on $VIDEO”
echo
nohup “$WINEPATH/${APPLE_APP}wine” “$CSPATH/comskip.exe” –ini=”$CSPATH/comskip.ini” “$VIDEO” 2>/dev/null 1>/dev/null &
fi
else
echo ”            Waiting for other Comskip to finish.”
fi
else
echo ”            Already processed.”
fi
done
echo
done

echo “Looking for old files…”
# Build the extentions list
for (( i = 0 ; i < ${#CHKEXT[@]} ; i++ )); do
if ! [[ $FILES ]]; then
FILES=”-name *.${CHKEXT[$i]}”
else
FILES=”$FILES -o -name *.${CHKEXT[$i]}”
fi
done
for DELME in `find ${TVPATH[$x]} -type f \( $FILES \) | sed ‘s/.*\///’ | cut -d “.” -f1 | uniq`; do
for (( i = 0 ; i < ${#DELME[@]} ; i++ )); do
for KEEPME in $KEEP; do
if ! [[ -f ${TVPATH[$x]}/${DELME[$i]}.$KEEPME ]]; then
echo ”    Removing $DELME.*”
rm     ${TVPATH[$x]}/${DELME[$i]}.*
fi
done
done
done
done
echo
echo “Waiting for $DELAY seconds”
sleep $DELAY
done

Advertisements

No comments yet

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: