Archive:MythicalLibrarian UserJobs: Difference between revisions

From Official Kodi Wiki
Jump to navigation Jump to search
>Outleradam
No edit summary
 
(10 intermediate revisions by 5 users not shown)
Line 1: Line 1:
== 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.
[[Archive: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 ==
== 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.
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 ==
== Job Files ==
You will normally only want to script the JobSucessful job. However, the user jobs are as follows
Normally, you will only want to script the JobSucessful job. However, the available user jobs are as follows:
 
* /etc/mythicalLibrarian/JobSucessful -Is run when mythicalLibrarian completes in the most appropriate manner
* /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/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.
Line 20: Line 19:
The following variables can be used in any user job.
The following variables can be used in any user job.


*ALL RECORDINGS - these variables will be set on all recordings
* ALL RECORDINGS - these variables will be set on all recordings
  $MoveDir/$ShowFileName.$originalext = location of moved file.
  $MoveDir/$ShowFileName.$originalext = location of moved file.
  $ShowName = Processed Title
  $ShowName = Processed Title
Line 41: Line 40:
  $MyUserName = name of user running mythicalLibrarian
  $MyUserName = name of user running mythicalLibrarian
  $SafeShowName = title of show after showtranslations formatted for filesystem use
  $SafeShowName = title of show after showtranslations formatted for filesystem use
*EPISODES AND GENERIC SHOWS -These variables will be set only on series type shows
* EPISODES AND GENERIC SHOWS -These variables will be set only on series type shows
  $OriginalAirDate = original air date  Generic programming will be the first episode ever, for episodes it will be the first aired date
  $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
  $epn = Subtitle or EPisode Name
*EPISODES AND MOVIES - This variable will be set only for shows with season/episode information or movies
* EPISODES AND MOVIES - This variable will be set only for shows with season/episode information or movies
  $exx = Episode Number or "Movie" in case of a movie
  $exx = Episode Number or "Movie" in case of a movie
*EPISODES -These variables will be set  
* EPISODES -These variables will be set  
  $sxx = Season number or blank in case of movie
  $sxx = Season number or blank in case of movie
  $seriesid = TheTVDB series ID
  $seriesid = TheTVDB series ID
Line 52: Line 51:
  $LastUpdated = last updated time (for Episodes only others wil be blank)  
  $LastUpdated = last updated time (for Episodes only others wil be blank)  
  $absolouteEpisodeNumber = tvdb order numbering
  $absolouteEpisodeNumber = tvdb order numbering
*MOVIES - This variable will only be set for a movie
* MOVIES - This variable will only be set for a movie
  $MovieAirDate = the original year the movie aired
  $MovieAirDate = the original year the movie aired
Depending on the recording, different variables will be available. Unused variables will be blank.
Depending on the recording, different variables will be available. Unused variables will be blank.
Line 77: Line 76:
  ln -s  "$MoveDir/$ShowFileName.originalext" "$InputPath"
  ln -s  "$MoveDir/$ShowFileName.originalext" "$InputPath"
   
   
  #Enable XBMC Communications which were disabled so mythicalLibrarian did not communicate when the command was called before
  #Enable Kodi Communications which were disabled so mythicalLibrarian did not communicate when the command was called before
  XBMCUpdate=Enabled
  XBMCUpdate=Enabled
  XBMCClean=Enabled
  XBMCClean=Enabled
  XBMCNotify=Enabled
  XBMCNotify=Enabled
   
   
  #Tell mythicalLibrarian to send a message to XBMC and update the library
  #Tell mythicalLibrarian to send a message to Kodi and update the library
  XBMCAutomate
  XBMCAutomate
   
   
Line 89: Line 88:


==== Multilingual Recognition ====
==== 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 line
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:
/usr/local/bin/mythicalLibrarian:
Line 96: Line 95:
  Language=en
  Language=en
  ...
  ...
and a copy of mythicalLibrarian, called "mythicalLibrarianSP" with the line changed to
and a copy of mythicalLibrarian, called "mythicalLibrarianSP" with the Language setting set to Spanish
 
/usr/local/bin/mythicalLibrarianSP:
/usr/local/bin/mythicalLibrarianSP:
  ...
  ...
Line 103: Line 101:
  Language=sp
  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.
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.


/etc/mythicalLibrarian/JobInformationNotComplete:
/etc/mythicalLibrarian/JobInformationNotComplete:
Line 109: Line 107:
  test "$Language" != "sp" && mythicalLibrarianSP
  test "$Language" != "sp" && mythicalLibrarianSP


== See Also ==
== Notes ==
Don't try to override a setting with a user job. If you wish to set a variable as a "global setting" Place that variable in the global settings file
 
/etc/mythicalLibrarian/globalSettings"
SYMLINK=Disabled                               
AlternateMoveDir=/media/usbDrive
NotifyUserName=adam                             
XBMCIPs=( "user:[email protected]:8080" )               
MySQLpass="Gq3117m8"

Latest revision as of 01:06, 8 July 2020

mythicalLibrarian UserJobs

Archive: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:

  • /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.

Only one of these jobs will be run by mythicalLibrarian before it exits.

Variables for use in user jobs

The following variables can be used in any user job.

  • ALL RECORDINGS - these variables will be set on all recordings
$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
  • EPISODES AND GENERIC SHOWS -These variables will be set only on series type shows
$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
  • EPISODES AND MOVIES - This variable will be set only for shows with season/episode information or movies
$exx = Episode Number or "Movie" in case of a movie
  • EPISODES -These variables will be set
$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
  • MOVIES - This variable will only be set for a movie
$MovieAirDate = the original year the movie aired

Depending on the recording, different variables will be available. Unused variables will be blank.

Examples

Transcoding and Tracking

The following is an example which transcodes a file

/etc/mythicalLibrarian/JobSucessful:

#Run a transcoding program on the file
ffmpeg -i S:"$MoveDir/$ShowFileName.$originalext" -target ntsc-svcds:"$MoveDir/$ShowFileName.mp4"

#Write the new file extension over the old extension for logging
originalext=mp4 

#Run logging for the new file extension so mythicalLibrarian can keep track of files it created.
performLoggingForMoveMode #or performLoggingForLinkMode
 
#remove the mythicalLibrarian symlink
rm "$InputPath"

#make a new symlink
ln -s  "$MoveDir/$ShowFileName.originalext" "$InputPath"

#Enable Kodi Communications which were disabled so mythicalLibrarian did not communicate when the command was called before
XBMCUpdate=Enabled
XBMCClean=Enabled
XBMCNotify=Enabled

#Tell mythicalLibrarian to send a message to Kodi and update the library
XBMCAutomate

#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 setting
Language=en
...

and a copy of mythicalLibrarian, called "mythicalLibrarianSP" with the Language setting set to Spanish /usr/local/bin/mythicalLibrarianSP:

...
#Language setting
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.

/etc/mythicalLibrarian/JobInformationNotComplete:

test "$Language" = "sp" && Exit 0
test "$Language" != "sp" && mythicalLibrarianSP

Notes

Don't try to override a setting with a user job. If you wish to set a variable as a "global setting" Place that variable in the global settings file

/etc/mythicalLibrarian/globalSettings"

SYMLINK=Disabled                                 
AlternateMoveDir=/media/usbDrive 
NotifyUserName=adam                              
XBMCIPs=( "user:[email protected]:8080" )                
MySQLpass="Gq3117m8"