MythSExx

MythSExx allows you to export your episode library into XBMC or Boxee while leaving MythTV in control of the files. mythicalLibrarian utilizes the MythTV database and integrates MythTV movies and episodes into XBMC or Boxee

Support can be found here: http://forum.xbmc.org/showthread.php?t=64160

Key features: /home/mythtv/MythSExx/MythSExx.sh "%TITLE%" "%SUBTITLE%" "%DIR%/%FILE%"
 * MythTV recordings renamed to Show name.SxxExx (episode title).ext
 * Symlinks allow MythTV to maintain your library. Symlink from new file in place of old.  Symlink to original.
 * TvDb recognition of Show Name and Episode Name
 * Fuzzy logic episode name matching allows for improperly named episodes
 * User defined show name translations for improper guide data
 * User is notified at the end of each operation
 * Dynamic mount support with alternate move dir
 * Failsafe Symlink mode
 * easy to troubleshoot permission errors and other problems in debug mode
 * Can be run as MythTV job.

MythSExx
The following instructions are meant as a guide to help you install MythSExx.

list of dependencies
The following packages are required
 * curl -downloads web pages as text
 * agrep -fuzzy logic capabilities
 * libnotify-bin -optional user notifications

set up dependencies
apt-get install curl agrep apt-get install libnotify-bin
 * Install the dependencies by opening a terminal and typing the following
 * optional for Ubuntu GNOME Desktop notification.

set up MythSExx
The following are suggestions for the average user, installation can be performed in many ways according to your desired setup. mkdir /home/mythtv/MythSExx mkdir /home/mythtv/Videos mkdir /home/mythtv/Shared
 * Create a working folder for MythSExx to place it's files
 * Create a Videos folder for MythTV to deposit it's recordings
 * Create a shared folder
 * Share your shared folder by right clicking on the folder then click properties, click share and then follow instructions given

Filename: /home/mythtv/MythSExx/MythSExx.sh # #  # # # # MoveDir=/home/mythtv/NAS/Video/shows AlternateMoveDir=/home/mythtv/Shared UseOriginalDir=Disabled UseShowNameAsDir=Enabled SYMLINK=MOVE Timeout=50 MythSExx=~/MythSExx FailSafeMode=Enabled FailSafeDir=~/home/mythtv Notify=Enabled NotifyUserName=adam APIkey=6DF511BB2A64E0E9 DEBUGMODE=Enabled echo "@@@@@@@@@@NEW SEARCH INITIATED AT `date`@@@@@@@@@@@@@">>"$MythSExx"/output.log if [ ! -d "$MythSExx" ]; then mkdir $MythSExx echo "creating home/MythSExx and log file">>"$MythSExx"/output.log fi ShowName=$1 epn=`echo $2|sed 's/;.*//'|tr -d [:punct:]` originalext=`echo "${3#*.}"` originaldirname=`dirname "$3"` if [ -f $MythSExx/showtranslations ]; then showtranslation=`grep "$ShowName = " "$MythSExx/showtranslations"|replace "$ShowName = " ""|replace "$MythSExx/showtranslations" ""` if [ "$showtranslation" != "$null" ];then ShowName=$showtranslation echo "USER TRANSLATION: $1 = $ShowName">>"$MythSExx"/output.log elif [ "$showtranslation" = "$null" ];then $showtranslation = "Inactive" fi fi echo "SEARCHING: www.TheTvDb.com SHOW NAME: $ShowName EPISODE: $epn">>"$MythSExx"/output.log echo "FILE NAME: $3">>"$MythSExx"/output.log tvdbshowname=`echo $ShowName|replace " " "%20"` curl -s -m"$Timeout" www.thetvdb.com/api/GetSeries.php?seriesname=$tvdbshowname>$MythSExx/working.xml cat $MythSExx/working.xml | grep " "|replace " " ""|replace " " "">$MythSExx/sid.txt cat $MythSExx/working.xml | grep ""|replace "" ""|replace "" "">$MythSExx/shn.txt serieslinenumber=`agrep -Byn "${showname:0:29}" $MythSExx/shn.txt|sed 's/:.*//'|grep -m1 ^` seriesid=`sed -n $serieslinenumber'p' $MythSExx/sid.txt|grep -m1 ^` NewShowName=`sed -n $serieslinenumber'p' $MythSExx/shn.txt|grep -m1 ^` if [ ! -d "$MythSExx/$NewShowName" ]; then mkdir $MythSExx/"$NewShowName" echo "creating home MythSExx and log file">>MythSExx/output.log fi 	echo "SEARCH FOUND:""$NewShowName" "ID#:" $seriesid >>"$MythSExx"/output.log if [ "$seriesid" != "" ]; then seriesid=`echo $seriesid|tr -d " "|tr -d " "` curl -s -m"$Timeout" "http://www.thetvdb.com/api/$APIkey/series/$seriesid/all/en.xml">$MythSExx"/$NewShowName/$NewShowName.xml" if [ -f "$MythSExx/$NewShowName/$NewShowName.xml" ]; then cat "$MythSExx/$NewShowName/$NewShowName.xml" | grep ""|replace " " ""|replace "" ""|tr -d [:punct:]>$MythSExx/"$NewShowName"/"$NewShowName".Ename.txt cat $MythSExx/"$NewShowName"/"$NewShowName".xml | grep ""|replace "" ""|replace "" ""|replace " " "">$MythSExx/"$NewShowName"/"$NewShowName".S.txt cat $MythSExx/"$NewShowName"/"$NewShowName".xml | grep ""|replace "" ""|replace "" ""|replace " " "">$MythSExx/"$NewShowName"/"$NewShowName".E.txt elif [ ! -f "$MythSExx/$NewShowName/$NewShowName.xml" ]; then echo "***FAILURE: curl -s -m$Timeout http://www.thetvdb.com/api/$APIkey/series/$seriesid/all/en.xml">>"$MythSExx"/output.log fi if [ -f $MythSExx/"$NewShowName"/"$NewShowName".Ename.txt ]; then echo "LOCAL DATABASE UPDATED:$MythSExx/$NewShowName">>"$MythSExx"/output.log elif [ ! -f "$MythSExx/$NewShowName/$NewShowName.Ename.txt" ]; then echo "*** PERMISSION ERROR $MythSExx/$NewShowName/">>"$MythSExx"/output.log fi absolouteEpisodeNumber=`agrep -Byn "${epn:0:29}" "$MythSExx""/""$NewShowName""/""$NewShowName"".Ename.txt"|grep -m1 ^|sed 's/:.*//'` echo DEFINED ABSOLOUTE EPISODE NUMBER: $absolouteEpisodeNumber>>"$MythSExx"/output.log if [ "$absolouteEpisodeNumber" != ""  ]; then epn=`sed -n $absolouteEpisodeNumber'p' $MythSExx/"$NewShowName"/"$NewShowName".Ename.txt|sed 's/;.*//'` exx=`sed -n $absolouteEpisodeNumber'p' $MythSExx/"$NewShowName"/"$NewShowName".E.txt` sxx=`sed -n $absolouteEpisodeNumber'p' $MythSExx/"$NewShowName"/"$NewShowName".S.txt` if [ "$exx" -lt 10 ]; then exx=`echo E0$exx` elif [ "$exx" -gt 9 ]; then exx=`echo E$exx` fi if [ "$sxx" -lt 10 ]; then sxx=`echo S0$sxx` elif [ "$sxx" -gt 9 ]; then sxx=`echo S$sxx` fi fi echo "EPISODE:$epn ABSOLUTE NUMBER:$absolouteEpisodeNumber" $sxx$exx elif [ "$seriesid" == "" ]; then echo "series was not found the tvdb may be down try renaming $1">>"$MythSExx"/output.log fi if [ ! -f "$3" ]; then echo "****** INPUT FILE NAME NON EXISTANT CHECK FILE NAME">>"$MythSExx"/output.log echo "****** INPUT FILE NAME NON EXISTANT CHECK FILE NAME" exit 1 elif [ -f "$3" ]; then MoveFileSize=`stat -c %s "$3"`; echo "File Size: $MoveFileSize" MoveFileSize=$((MoveFileSize/1024)) MoveDirFreeSpace=`df $MoveDir|sed -n 2p|awk '{print $4}'`; echo "MoveDir Free Space: $MoveDirFreeSpace" AlternateMoveDirFreeSpace=`df $AlternateMoveDir|sed -n 2p|awk '{print $4}'`; echo "Alternate Move Dir Free Space: $AlternateMoveDirFreeSpace" if [ "$MoveFileSize" -lt "$MoveDirFreeSpace" ]; then echo "Testing write permission on $MoveDir">$MoveDir/arbitraryfile.ext if [ -f "$MoveDir/arbitraryfile.ext" -a -s "$MoveDir/arbitraryfile.ext" ]; then rm "$MoveDir/arbitraryfile.ext" test ! -f "$MoveDir/arbitraryfile.ext";MoveDirWritable=1 else MoveDirWritable=0 Echo "CHECK PERMISSIONS ON $MoveDir" fi elif [ "$MoveFileSize" -gt "$MoveDirFreeSpace" ]; then MoveDirWritable=0 fi fi if [ -L "$3" ]; then echo "FILE IS A LINK ACTIVATING SYMLINK LINK MODE">>"$MythSExx"/output.log SYMLINK=LINK fi if [ "$MoveFileSize" -lt "$AlternateMoveDirFreeSpace" ]; then echo "Testing write permission on $AlternateMoveDir">$AlternateMoveDir/arbitraryfile.ext if [ -f "$AlternateMoveDir/arbitraryfile.ext" -a -s "$AlternateMoveDir/arbitraryfile.ext" ]; then rm "$AlternateMoveDir/arbitraryfile.ext" test ! -f "$AlternateMoveDir/arbitraryfile.ext";AlternateMoveDirWritable=1 else AlternateMoveDirWritable=0 Echo "CHECK PERMISSIONS ON $AlternateMoveDir" fi elif [ "$MoveFileSize" -gt "$MoveDirFreeSpace" ]; then AlternateMoveDirWritable=0 fi 	echo "Move dir writable flag:"$MoveDirWritable echo "AlternateMovedir writable flag:"$AlternateMoveDirWritable if [ $DEBUGMODE = "Enabled" ]; then echo "#########################################################">>"$MythSExx"/output.log echo "###################DEBUG MODE ENABLED####################">>"$MythSExx"/output.log echo "#########################################################">>"$MythSExx"/output.log echo "LISTING INTERNAL VARIABLES USED BY MythSExx.">>"$MythSExx"/output.log echo "INTERNET TIMEOUT:$Timeout- TvDb API KEY:$APIkey- MythSExx WORKING DIR:$MythSExx-">>"$MythSExx"/output.log echo "MOVE DIR:$MoveDir- USING SHOWNAME AS FOLDER:$UseShowNameAsDir-">>"$MythSExx"/output.log echo "FAILSAFE MODE:$FailSafeMode- FAILSAFE DIR:$FailSafeDir- ALTERNATE MOVE DIR:$AlternateMoveDir-">>"$MythSExx"/output.log echo "USE ORIGINAL DIR:$UseOriginalDir NOTIFICATIONS:$Notify DEBUG MODE:$DEBUGMODE-">>"$MythSExx"/output.log echo "INPUT SHOW NAME:$1- LOCAL SHOW NAME TRANSLATION:$showtranslation- SENT TVDB SHOW NAME:$tvdbshowname-">>"$MythSExx"/output.log echo "RESOLVED SERIES ID:$seriesid- RESOVED SHOW NAME:$ShowName-">>"$MythSExx"/output.log echo "INPUT EPISODE NAME:$2- ABSOLOUTE EPISODE NUMBER:$absolouteEpisodeNumber- RESOLVED EPISODE NAME:$epn-">>"$MythSExx"/output.log echo "SEASON:$sxx- EPISODE:$exx- Symlink Mode:$SYMLINK-">>"$MythSExx"/output.log echo "FLAGS: MoveDir:$MoveDirWritable- AlternateMoveDir-$AlternateMoveDirWritable- FileSize: $MoveFileSize">>"$MythSExx"/output.log echo "##############LISTING FOLDER PERMISSIONS#################">>"$MythSExx"/output.log echo "ORIGIONAL FILE>ls -l $3">>"$MythSExx"/output.log ls -l "$3">>"$MythSExx"/output.log echo "MythSExx WORKING DIR>lsmod -l $MythSExx/$NewShowName/">>"$MythSExx"/output.log ls -l "$MythSExx/$NewShowName/">>"$MythSExx"/output.log echo "#########################################################">>"$MythSExx"/output.log echo "####################END OF DEBUG LOG#####################">>"$MythSExx"/output.log echo "#########################################################">>"$MythSExx"/output.log fi FailSafeState=0 if [ $MoveDirWritable = "0" ]; then if [ $AlternateMoveDirWritable = "0" ]; then FailSafeState=1 else MoveDir=$AlternateMoveDir fi fi ShowFileName=`echo "$NewShowName.$sxx$exx ($epn)"` if [ $FailSafeState = "1" ]; then echo "FAILSAFE FLAG WAS SET CHECK PERMISSIONS AND FOLDERS">>"$MythSExx"/output.log if [ $FailSafeMode = "Enabled" ]; then echo "PERMISSION ERROR OR DRIVE FULL">>"$MythSExx"/output.log echo "ATTEMPTING SYMLINK TO FAILSAFE DIR: $FailSafeDir">>"$MythSExx"/output.log ln -s "$3" "$FailSafeDir/$ShowFileName.$originalext" test -f "$FailSafeDir/$ShowFileName.$originalext";"FAILSAFE MODE COMPLETE: SYMLINK CREATED">>"$MythSExx"/output.log test ! -f "$FailSafeDir/$ShowFileName.$originalext";"FAILSAFE MODE FAILURE CHECK PERMISSIONS AND FREE SPACE IN $FailSafeDir">>"$MythSExx"/output.log fi if [ $Notify = Enabled ]; then sudo -u "$NotifyUserName" /usr/local/bin/alt-notify-send "MythSExx FAILSAFE" "FAILSAFE mode active See "$MythSExx"/output.log for more information" error fi exit 1 fi if [ "$exx" = "" ]; then if [ $Notify = Enabled ]; then sudo -u "$NotifyUserName" /usr/local/bin/alt-notify-send "MythSExx Error" "Could not obtain information from server" error fi echo "%%%%%%%%%%COULD NOT OBTAIN SEASON AND EPISODE INFO FOR $1, $2">>"$MythSExx"/output.log exit 1 fi if [ $UseOriginalDir = "Enabled" ]; then MoveDir=`echo "$originaldirname"` fi if [ -d $MoveDir ]; then echo "Verified Move Dir Exists: $MoveDir" if [ "$UseShowNameAsDir" = "Enabled" ]; then MoveDir=`echo "$MoveDir"/"$NewShowName"` if [ -d "$MoveDir" ]; then echo "VERIFIED FOLDER: $MoveDir">>"$MythSExx"/output.log elif [ ! -d "$MoveDir" ]; then echo "CREATING FOLDER: $MoveDir">>"$MythSExx"/output.log mkdir "$MoveDir" if [ ! -d "$MoveDir" ];then echo "******PERMISSION ERROR COULD NOT CREATE $MoveDir/$NewShowName">>"$MythSExx"/output.log fi fi fi fi if [ -f "$MoveDir/$ShowFileName.$originalext" ]; then MythSExxCounter=0 NameCheck=0 while [ $NameCheck = '0' ]; do 		let MythSExxCounter=$MythSExxCounter+1 if [ ! -f "$MoveDir/$ShowFileName-$MythSExxCounter.$originalext" ]; then NameCheck="1" if [ -L "$MoveDir/$ShowFileName-$MythSExxCounter.$originalext" ]; then NameCheck="0" fi ShowFileName=`echo "$ShowFileName-$MythSExxCounter"` echo "FILE NAME EXISTS. FILE WILL BE KNOWN AS: $ShowFileName" fi done fi if [ $SYMLINK != "LINK" ]; then echo "MOVING FILE: $3 to $MoveDir/$ShowFileName.$originalext">>"$MythSExx"/output.log mv "$3" "$MoveDir/$ShowFileName.$originalext" if [ -f "$MoveDir/$ShowFileName.$originalext" ]; then if [ -s "$MoveDir/$ShowFileName.$originalext" ];then if [ $SYMLINK = "MOVE" ]; then echo Creating Link ln -s "$MoveDir/$ShowFileName.$originalext" "$3" fi if [ $Notify = "Enabled" ]; then sudo -u "$NotifyUserName" /usr/local/bin/alt-notify-send "MythSExx Sucess" "$ShowFileName moved to $MoveDir" info fi echo "@@@@@@@@@@@@@OPERATION COMPLETE" `date` "@@@@@@@@@@@@@@@">>"$MythSExx"/output.log exit 0 elif [ ! -s "$MoveDir/$ShowFileName.$originalext" ]; then rm "$MoveDir/$ShowFileName.$originalext" if [ $Notify = "Enabled" ]; then sudo -u "$NotifyUserName" /usr/local/bin/alt-notify-send "MythSExx Failure" "$ShowFileName could not be moved to $MoveDir" error fi echo #################OPERATION FAILED################### fi elif [ ! -f "$MoveDir/$ShowFileName.$originalext" ]; then echo "FILE WAS NOT MOVED">>"$MythSExx"/output.log fi elif [ $SYMLINK = "LINK" ]; then echo Creating Link ln -s "$3" "$MoveDir/$ShowFileName.$originalext" if [ -f "$MoveDir/$ShowFileName.$originalext" ]; then echo "Symlink created $MoveDir/$ShowFileName.$originalext""$MythSExx"/output.log echo "@@@@@@@@@@@@@OPERATION COMPLETE" `date` "@@@@@@@@@@@@@@@">>"$MythSExx"/output.log if [ $Notify = "Enabled" ]; then sudo -u "$NotifyUserName" /usr/local/bin/alt-notify-send "MythSExx Sucess" "$ShowFileName moved to $MoveDir" info fi fi exit 0 fi if [ "$exx" = "" ]; then echo "NO MATCH FOUND. TROUBLESHOOTING: Check www.TheTvDb TO SEE IF $1 EXISTS. ">>"$MythSExx"/output.log echo "CHECK EPISODE NAME $2. CHECK INTERNET CONNECTION. CHECK API KEY.">>"$MythSExx"/output.log echo "CHECK www.TheTvDb.com RUN MythSExx LINK COMMAND PROMPT. FOR MORE INFORMATION SEE http://wiki.xbmc.org/index.php?title=MythSExx">>"$MythSExx"/output.log echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" fi echo "mv $3 $MoveDir/$ShowFileName.$originalext" if [ $Notify = "Enabled" ]; then sudo -u "$NotifyUserName" /usr/local/bin/alt-notify-send "MythSExx error" "MythSExx Move operation failed See "$MythSExx"/output.log for more information" error fi exit 1 sudo chmod +x /home/mythtv/MythSExx/MythSExx.sh
 * Create the following file and set the user settings in the file.
 * 1) !/bin/bash
 * 1) MythSExx by Adam Outler
 * 2) email: outleradam at hotmail.com
 * 3) Software the way it should be: Free and Open Source
 * 4) Please contact me with any bug reports
 * 1) Intention:
 * 2) This program was designed to be a user job in MythTV.  It can be called by creating a user job.
 * 3) The user job can be called as follows:
 * 4) /home/mythtv/MythSExx/MythSExx.sh  "%TITLE%" "%SUBTITLE%" "%DIR%/%FILE%"
 * 1) Usage:
 * 2)  MythSExx.sh -v "show name" "episode name" "Target Folder"
 * 3)  eg. MythSExx.sh "South Park" "Here Comes the Neighborhood" "/home/mythrecordings/2308320472023429837.mpg"
 * 1) Output:
 * 2) If an error occurs and the file cannot be moved, then no change will occur to the original file. If the Movedir
 * 3) is full or not available, such as when running a NAS and the computer is disconnected from the network, the
 * 4) AlternateMoveDir will be used. If both of these dirs fail, the show will be SymLinked in the FailSafeDir.
 * 5) You may elect to run the user job at a later time when the issue has been resolved.  Output dir will depend
 * 6) on user settings. The file name however, is preset to the most acceptable standard:
 * 7)   Show Title - SxxExx (Episode Title).ext
 * 1) Symlinking:
 * 2) When Symlinking is enabled, MythSExx will follow it's normal mode of operation.  In MOVE mode, MythSExx will
 * 3) Create a symlink from the new file in the same name and location of the old file.  In LINK mode, MythSExx will
 * 4) not move the file, LINK mode creates a new symlink to the original file.
 * 1) Logging:
 * 2) Log file will show information for troubleshooting. You can find the log file in the working folder
 * 3) Log file default location: /home/$username/MythSExx
 * 1) Dependencies: depends on "Curl" and "agrep" and "libnotify-bin"
 * 2) install curl with "apt-get install curl"
 * 3) install agrep with "apt-get install agrep"
 * 4) optional: install libnotify-bin with "apt-get install libnotify-bin"
 * 1) Show Name Translation
 * 2) The user may elect to create a file in the MythSExx/ working folder which will then translate any recorded
 * 3) show name into the desired show name.  This is useful for adding a year to distinguish between a new series
 * 4) and an older series and/or typos in your guide data.  By default it should be called "showtranslations" and
 * 5) by default it will be in your home/username/MythSExx folder.  showtranslations is not needed by most users
 * 6) and the file should only be created if it is needed. Under most circumstances, the integrated fuzzy logic
 * 7) will be sufficient to translate the guide name to the TvDb name, however showtranslations is available to
 * 8) improve accuracy to 100%. The format of showtranslations is as follows:
 * 9) Filename: /$MythSExx/showtranslations
 * 10) My Guide Show Title = www.TheTvDb.com Show Title           #
 * 11) Battlestar Gallactica = Battlestar Gallactica (2003)       #
 * 12) Millionaire = Who Wants To Be A Millionaire                #
 * 13) Aqua teen Hungerforce = Aqua Teen Hunger Force             #
 * 1) Aqua teen Hungerforce = Aqua Teen Hunger Force             #
 * 1) USER SETTINGS##########################
 * 2) MoveDir is the folder which MythSExx will move the file. No trailing / is accepted eg. "~/videos"
 * 1) AlternateMoveDir will act as a seccondary MoveDir if the primary MoveDir fails.
 * 1) Disable moving of files. If UseOriginalDir is Enabled, original dir will override MoveDir.  This can be useful for multiple recording dirs   Enabled|Disabled
 * 1) When Enabled, MythSExx will move the file to a folder of the same name as the show. This is not affected by UseOriginalDir. Enabled|Disabled
 * 1) SYMLINK has 3 modes. MOVE|LINK|Disabled
 * 2) Create symlink in original dir from file after MOVE, Create symlink in MoveDir LINK original(overrides moving), Simlinking Disabled
 * 1) Internet access Timeout in seconds: Default Timeout=50
 * 1) MythSExx working file dir: Default is "~/MythSExx"
 * 1) FailSafe mode will enable symlinks to be formed in FailSafeDir if the move or symlink operation fails.
 * 1) FailSafeDir is used when the file cannot be moved to the MoveDir. FailSafe will not create folders.
 * 1) The following line tells MythSExx to send a notification upon completion. Enabled|Disabled
 * 1) If notifications are enabled, NotifyUserName should be the same as the user logged into the GNOME Session.
 * 1) the following line contains the API key from www.TheTvDb.Com. Default: 6DF511BB2A64E0E9
 * 1) Enables debug mode. This is a verbose mode of logging which should be used for troubleshooting.  Enabled|Disabled
 * 1) USER SETTINGS##########################
 * 1) Do not modify below this line##################
 * 1) Do not modify below this line##################
 * 1) DEFINE ENVIRONMENT AND VARIABLES#####
 * 2) make our working dir if it does not exist
 * 1) Set episode name, dir, extension, and showname from the input parameters.
 * 1) Check for show translations relating to the show in question.
 * 1) SEARCH FOR SHOW NAME#####
 * 1) download series info for show, parse into temporary text db- sid.txt shn.txt
 * 1) Use fuzzy logic to make the best match of the show name
 * 1) Get the seriesid based on the showname
 * 1) Create folder for database if it does not exist
 * 1) If series ID is obtained, then get show information.
 * 1) GET SHOW INFORMATION#####
 * 2) Strip XML tags
 * 1) download series info for series id
 * 1) create a folder/file "database" Strip XML tags. Series, Exx and Sxx are separated into different files
 * 1) check if files were created and generate message
 * 1) PROCESS SHOW INFORMATION#####
 * 2) grep use fuzzy logic to find the closest show name from the locally created database and return absolute episode number
 * 1) if line match is obtained, then gather Sxx and Exx
 * 1) gather series and episode names from files created earlier.
 * 1) Single digit episode and show names are not allowed Ex and Sx replaced with Exx Sxx
 * 1) if series id is not obtained
 * 1) SANITY CHECKS#####
 * 2) If file to be moved does not exist, then report
 * 1) If the file does exist, then perform the desired actions
 * 1) Get file size and free space
 * 1) Check write permissions and Free Space on MoveDir
 * 1) Check write permissions and free space on AlternateMoveDir
 * 1) OUTPUT#####
 * 1) Determine where file will fit
 * 1) output format showname=show name sxx=season number exx=episode number epn=episode name
 * 1) If failsafe state is set then create link in FailSafeMode
 * 1) If Failsafe is not set then use normal mode
 * 1) use original dir if requested
 * 1) check to see if output folder exists
 * 1) If specified, make $movedir = $movedir/show name
 * 1) Make the folder if it does not exist
 * 1) Error message if folder was not created
 * 1) If file exists then make a new name for it
 * 1) If file does not exist, then it becomes our target
 * 1) If symlink is not in LINK mode, Move and rename the file.
 * 1) Move the file and rename
 * 1) Check and report if file was moved
 * 1) Send notification of completion and exit
 * 1) if file was not moved, then fail
 * 1) If symlink is in LINK mode then create symlink
 * 1) if no match is found then send error messages
 * 1) send notification if enabled
 * 1) Log error if problem exists
 * 1) send notification if enabled
 * make MythSExx executable

Creating a Rotating MythSExx Library
The following is instructions for setting a dynamic library for XBMC

MythTV settings
UserJob #1 Description: MythSExx User Job #1 Command: /home/mythtv/MythSExx/MythSExx.sh "%TITLE%" "%SUBTITLE%" "%DIR%/%FILE%"
 * Click System/Administration MythTV Backend setup
 * Select "1. General" then select next until you get to screen 3
 * Check "Follow symbolic links when deleting files".
 * Select next until you get to screen 8
 * Check "Allow user job #1 Jobs"
 * Select next until you get to screen 10
 * Select Finish to exit
 * Select 6. Storage Directories
 * Select Default
 * Add a recording folder to which MythTV has access ie. /home/mythtv/Videos
 * Add additional folders if required.
 * Remove folders to which MythTV cannot run move jobs such as /lib or /var

XBMC settings
XBMC can update itself on start up.


 * Check the option to update your library under Settings-Video you will find a option to scan the library on startup.

Enabling Notifications
Notifications will occour at the end of every operation conducted by MythSExx. Notifications will let you know when it is time to update your XBMC Library.

installing notify-send
Libnotify-bin contains the file which allows the terminal to send commands to the GNOME desktop.

apt-get install libnotify-bin
 * open a terminal

setting permissions
The following procedure is a security risk. Unless a better way is found, this is the only way to enable permissions to be set for mythtv to send a user notification. The user mythtv will have access to the sudo command without password.

gedit /etc/group mythtvall:x:9389:mythtv visudo %mythtvall ALL=(ALL) NOPASSWD:ALL
 * type the following
 * add the following line to the end of /etc/group
 * type the following
 * add the following line to visudo
 * write out and quit

enable notifications to GNOME user
To enable notifications to be sent to the desktop from a different user, you will need to use my specially modified alt-notify-send script. this script allows for the error icon and the info icon to be used. The original alt-notify-send did not have provisions for this.

filename: alt-notify-send user=`whoami` pids=`pgrep -u $user gnome-session` title=$1 text=$2 timeout=$3 if [ -z "$title" ]; then echo You need to give me a title >&2 exit 1 fi if [ -z "$text" ]; then text=$title fi if [ -z "$timeout" ]; then timeout=60000 fi for pid in $pids; do         # find DBUS session bus for this session DBUS_SESSION_BUS_ADDRESS=`grep -z DBUS_SESSION_BUS_ADDRESS \ /proc/$pid/environ | sed -e 's/DBUS_SESSION_BUS_ADDRESS=//'` # use it        DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS \ notify-send -u low -i $4 $timeout "$title" "$text" done
 * place the following script in /usr/local/bin/
 * 1) !/bin/bash

sudo chmod +x /usr/local/bin/alt-notify-send
 * Make it executable