MythicalLibrarian UserJobs

mythicalLibrarian UserJobs
mythicalLibrarian has incorporated user jobs to allow users to expand mythcialLibrarian to suit their needs without having to worry about loosing their changes when upgrading. User jobs are bash code which run at the end of mythicalLibrarian. Everything which mythicalLibrarian does can be undone or redone using user jobs and a bit of wit.

user jobs are a part of mythicalLibrarian
during mythicalSetup (aka mythicalLibrarian --update), the latest version of mythicalLibrarian is downloaded. mythicalSetup separates the code portion of the script from the user portion of the script. Think of the code portion as unmaintainable and dynamic from a user perspective, that is, it will change frequently. mythicalSetup then asks a series of questions and makes decisions based on your computer's setup. The final step before actually inserting the code into your user portion is to insert the user jobs.

Job Files
Normally, you will only want to script the JobSucessful job. However, the available user jobs are as follows: Only one of these jobs will be run by mythicalLibrarian before it exits.
 * /etc/mythicalLibrarian/JobSucessful -Is run when mythicalLibrarian completes in the most appropriate manner
 * /etc/mythicalLibrarian/JobInformationNotComplete -Is run when mythcalLibrarian determines there was not sufficient information to name the file according to standards. This type of job occurs when mythicalLibrarian attempts to rename by season and episode, but cannot obtain the information from TheTvDb. This is also accompanied by a spot in the --doover job file.
 * /etc/mythicalLibrarian/JobFilesystemError - Is run when mythcialLibrarian detects that it does not have proper permissions on one or more of the required folders.
 * /etc/mythicalLibrarian/JobInsufficientData - Is run in place of JobInformationNotComplete when the user elects not to process shows without required information. AKA. Showstopper.
 * /etc/mythicalLibrarian/JobIgnoreList - Is run when the user elects to ignore a show based on category or Title.
 * /etc/mythicalLibrarian/JobGenericError - Is run when mythicalLibrarian is not given enough information and has no TV Recording database to work with
 * /etc/mythicalLibrarian/JobUnspecified - This job should never be run unless you are debugging. It is called when RunJob is called in mythicalLibrarian and there is no JobType variable set.

Variables for use in user jobs
The following variables can be used in any user job.

$MoveDir/$ShowFileName.$originalext = location of moved file. $ShowName = Processed Title $InputTitle = actual database title $MoveDir = the folder to which the file was moved ie. "/home/mythtv/videos/Episode" $ShowFileName = the name of the show moved, not including extension eg. "simpsons S01E02 (foo)" or "MovieTitle(year)" $originalext = original file extension eg "mpg" $NewShowName = Successfully resolved show name $ChanID = ChannelID $ProgramID= Zap2it listing $ShowStartTime = begin recording time $ShowCategory = category like children or sports $mythicalLibrarianProgramIDCheck = "SH" for SHow or sports - "MV" for MoVie - "EP" for EPisode $plot = plot $stars = stars $FileBaseName = name of the file to be moved without ext $XMLTVGrabber = your guide data type $ProgramIDType= Generic episode with no data, Movie, or Series With Episode Data $Zap2itSeriesID= Zap2it ID with SH, MV or EP stripped $MyUserName = name of user running mythicalLibrarian $SafeShowName = title of show after showtranslations formatted for filesystem use $OriginalAirDate = original air date Generic programming will be the first episode ever, for episodes it will be the first aired date $epn = Subtitle or EPisode Name $exx = Episode Number or "Movie" in case of a movie $sxx = Season number or blank in case of movie $seriesid = TheTVDB series ID $TvDbTime = current tvdb time $LastUpdated = last updated time (for Episodes only others wil be blank) $absolouteEpisodeNumber = tvdb order numbering $MovieAirDate = the original year the movie aired Depending on the recording, different variables will be available. Unused variables will be blank.
 * ALL RECORDINGS - these variables will be set on all recordings
 * EPISODES AND GENERIC SHOWS -These variables will be set only on series type shows
 * EPISODES AND MOVIES - This variable will be set only for shows with season/episode information or movies
 * EPISODES -These variables will be set
 * MOVIES - This variable will only be set for a movie

Transcoding and Tracking
The following is an example which transcodes a file

/etc/mythicalLibrarian/JobSucessful: ffmpeg -i S:"$MoveDir/$ShowFileName.$originalext" -target ntsc-svcds:"$MoveDir/$ShowFileName.mp4" originalext=mp4 performLoggingForMoveMode #or performLoggingForLinkMode rm "$InputPath" ln -s "$MoveDir/$ShowFileName.originalext" "$InputPath" XBMCUpdate=Enabled XBMCClean=Enabled XBMCNotify=Enabled XBMCAutomate
 * 1) Run a transcoding program on the file
 * 1) Write the new file extension over the old extension for logging
 * 1) Run logging for the new file extension so mythicalLibrarian can keep track of files it created.
 * 1) remove the mythicalLibrarian symlink
 * 1) make a new symlink
 * 1) Enable XBMC Communications which were disabled so mythicalLibrarian did not communicate when the command was called before
 * 1) Tell mythicalLibrarian to send a message to XBMC and update the library
 * 1) Don't exit, just let mythicalLibrarian take back over.

Multilingual Recognition
The following is a multilingual example which first searches TheTvDb in English, then tries Spanish. You need two mythicalLibrarian executables, one which has the Language setting to English

/usr/local/bin/mythicalLibrarian: ... Language=en ... and a copy of mythicalLibrarian, called "mythicalLibrarianSP" with the Language setting set to Spanish /usr/local/bin/mythicalLibrarianSP: ... Language=sp ... This allows for two instances of mythicalLibrarian to run in sequence for those who are multi-lingual. So the rest of the setup is cake. Just create a file like this one and mythicalLibrarian will run through TheTvDb in English, then when it is unable to process a match, it runs through TheTvDb in Spanish.
 * 1) Language setting
 * 1) Language setting

/etc/mythicalLibrarian/JobInformationNotComplete: test "$Language" = "sp" && Exit 0 test "$Language" != "sp" && mythicalLibrarianSP