Kodi Community Forum
mythicalLibrarian - a tool to build Movie and TV Show library from MythTV recordings - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33)
+--- Forum: Supplementary Tools for Kodi (https://forum.kodi.tv/forumdisplay.php?fid=116)
+--- Thread: mythicalLibrarian - a tool to build Movie and TV Show library from MythTV recordings (/showthread.php?tid=65644)



- sdsnyr94 - 2011-11-06

OK, so it looks like deleting all the show folders from .mythicalLibrarian solved my issue.

While looking through this thread earlier to see if there were any hints to the problem I was having, I stumbled upon MythDataDeleter. Right now, mythicalLibrarian moves the file to a network share, and upon a successful move runs Handbrake to transcode the file to an mkv. This works great, but I still have to go back into either Mythtv or the Web Page to delete the recording. I would like to automate the removal of the recording, but not until after it is verified that Handbrake completed.

Any suggestions on how I can tell if the encode completed? I could use mkvinfo and check the "Duration" of the mkv... what could I use for the same effect with the original recording?

There really is nothing that I could easily use from the log file, as far as I can tell, to show if it completed. Even if handbrake crashes halfway through, the log still says that mythicalLibrarian has completed for that recording, and handbrake only says "Rip Done!" when it finishes... I don't know of a way to check which recording is "Done!"... unless you can do something like a grep to find the recording name, and then a nested grep to look for the "Rip Done!" (Is that even possible?).

Any suggestions? Thanks.


- outleradam - 2011-11-06

sdsnyr94 Wrote:OK, so it looks like deleting all the show folders from .mythicalLibrarian solved my issue.

While looking through this thread earlier to see if there were any hints to the problem I was having, I stumbled upon MythDataDeleter. Right now, mythicalLibrarian moves the file to a network share, and upon a successful move runs Handbrake to transcode the file to an mkv. This works great, but I still have to go back into either Mythtv or the Web Page to delete the recording. I would like to automate the removal of the recording, but not until after it is verified that Handbrake completed.

Any suggestions on how I can tell if the encode completed? I could use mkvinfo and check the "Duration" of the mkv... what could I use for the same effect with the original recording?

There really is nothing that I could easily use from the log file, as far as I can tell, to show if it completed. Even if handbrake crashes halfway through, the log still says that mythicalLibrarian has completed for that recording, and handbrake only says "Rip Done!" when it finishes... I don't know of a way to check which recording is "Done!"... unless you can do something like a grep to find the recording name, and then a nested grep to look for the "Rip Done!" (Is that even possible?).

Any suggestions? Thanks.

You can write a UserJob script to check confidence level and execute upon job complete sucessfully. This is an option you can read about in the wiki. Just write it as you would from the command line, mythicalLibrarian will pull userjob scripts into itself when you run mythicalLibrarian --update

I'd write it to check for confidence above 2, then run mythdatadeleter if confidence passes.

btw mythicalLibrarian --doMaintenance removes those folders automatically.


- sdsnyr94 - 2011-11-06

Quote:You can write a UserJob script to check confidence level and execute upon job complete sucessfully. This is an option you can read about in the wiki. Just write it as you would from the command line, mythicalLibrarian will pull userjob scripts into itself when you run mythicalLibrarian --update
Sorry, but I don't see in the Wiki how I can check for confidence.

Also, how would checking for confidence verify if handbrake completed?


- outleradam - 2011-11-08

I don't know about how to check for handbrake.. try

Code:
#If confidence > 1 or show is not episide
if [ $ConfidenceRating -gt 1 ||  $mythicalLibrarianProgramIDCheck =! "EP" ]; then
#run Handbrake
   handbrake --params
#IF handbrake was sucessful
   if [ $? = 0]; then
#run mythdatadeleter or something.
     do stuff;
     do stuff;
   fi
fi
read more here:http://wiki.xbmc.org/index.php?title=MythicalLibrarian_UserJobs
I didn't add all the variables into the wiki, although, please feel free to add your completed job to that page as an example.


- sdsnyr94 - 2011-11-08

Actually, I just found an easier way last night. I can use "2> HBLog.log" at the end of my Handbrake line to export to a separate log. Then I grep for "Rip Done!" and if it exists, It will run MythDataDeleter.

My next issue would be in MythDataDeleter... to make this work from command line, I need to use the original Mythtv recording name. What variable can I use in MythicalLibrarian to represent that file? Would that be the $InputTitle?

Thanks again for your help, and for making my life so much easier with this script.


- outleradam - 2011-11-08

Its on the wiki.. I'm mobile.

Its like filebasename.originalext. or inputpath will also work.


MythicalLibrarian doesn't do anything - varneyb - 2011-11-15

I recently installed MythicalLibrarian, and I'm not having any luck getting it to work.

When I type in "mythicalLibrarian" at the shell prompt, I get no response, and no symlinks are created. I've tried running with any number of flags, and I've made sure the user I'm running as (mythtv) has access to all of the directories involved - still no luck.

I took a look at /usr/local/bin/mythicalLibrarian, and it is a shell script which appears to set some variables and define a function (named "RunJob"), but there doesn't appear to be any code that actually does anything.

Am I missing something?


- shrioux - 2011-11-15

varneyb Wrote:I recently installed MythicalLibrarian, and I'm not having any luck getting it to work.

When I type in "mythicalLibrarian" at the shell prompt, I get no response, and no symlinks are created. I've tried running with any number of flags, and I've made sure the user I'm running as (mythtv) has access to all of the directories involved - still no luck.

I took a look at /usr/local/bin/mythicalLibrarian, and it is a shell script which appears to set some variables and define a function (named "RunJob"), but there doesn't appear to be any code that actually does anything.

Am I missing something?

Have you run mythical setup? and what is the output of a mythicalLibrarian -m (mythical diagnostics)?


- sdsnyr94 - 2011-11-15

varneyb Wrote:I recently installed MythicalLibrarian, and I'm not having any luck getting it to work.

When I type in "mythicalLibrarian" at the shell prompt, I get no response, and no symlinks are created. I've tried running with any number of flags, and I've made sure the user I'm running as (mythtv) has access to all of the directories involved - still no luck.

I took a look at /usr/local/bin/mythicalLibrarian, and it is a shell script which appears to set some variables and define a function (named "RunJob"), but there doesn't appear to be any code that actually does anything.

Am I missing something?

mythicalLibrarian is also designed to primarily be run as a MythTV user job, although it can be run from the command line. If you don't mind, also post an example of what you are entering to run it from command line.


- varneyb - 2011-11-17

shrioux Wrote:Have you run mythical setup? and what is the output of a mythicalLibrarian -m (mythical diagnostics)?

I have run the setup. I tried it under my normal user account, and as the "mythtv" user. Using the -m flag does nothing - I get no response

type mythicalLibrarian indicates it is /usr/local/bin/mythicalLibrarian.

When I look at that, I see a shell script which appears to do nothing other than set some variable values and define a function - no code appears to be executed. Here it is:

Code:
#! /bin/bash
#######################USER SETTINGS##########################
###Stand-alone mode values###
#MoveDir is the folder which mythicalLibrarian will move the file.  No trailing / is accepted eg. ~/videos
MoveDir=./Episodes
#AlternateMoveDir will act as a seccondary MoveDir if the primary MoveDir fails.  No trailing / is accepted eg. ~/videos
AlternateMoveDir=./Episodes
#If TargetPathIsInputPath is Enabled, original dir will override MoveDir.  Useful for multiple recording dirs.
#TargetPathIsInputPath will separate episodes from movies and shows. Enabled|Disabled
TargetPathIsInputPath=Enabled
#Internet access Timeout in seconds: Default Timeout=50 (seconds)
Timeout=50
#Update database time in secconds, Longer duration means faster processing time and less strain on TheTvDb. Default='70000' (almost a day)
UpdateDatabase=70000
#mythicalLibrarian working file dir: Default=~/.mythicalLibrarian (home/username/mythicalLibraian)
mythicalLibrarian=~/.mythicalLibrarian
#FailSafe mode will enable symlinks to be formed in FailSafeDir if the move or symlink operation fails. Enabled|Disabled
FailSafeMode=Enabled
#FailSafeDir is used when the file cannot be moved to the MoveDir. FailSafe will not create folders. eg. /home/username
FailSafeDir='/home/mythtv/FailSafe'
#DirTracking will check for and remove the folders created by mythicalLibrarian
DirTracking=Enabled
#the following line contains the API key from www.TheTvDb.Com. Default project code: 6DF511BB2A64E0E9
APIkey=6DF511BB2A64E0E9
#Language setting
Language=en
#SYMLINK has 3 modes.  MOVE|LINK|Disabled: Default=MOVE
#Create symlink in original dir from file after 'MOVE' | Do not move, just create a sym'LINK' | move the file, symlinking is 'Disabled', delete mythtv files
and DB entries
SYMLINK=MOVE

###Database Settings###
#Database access Enabled|Disabled
Database=Enabled
#Database Type Default=MythTV
DatabaseType=MythTVPythonBindings
#Guide data type
GuideDataType=SchedulesDirect
#MySQL User name: Default=mythtv
MySQLuser=mythtv
#MySQL Password: Default=mythtv
MySQLpass=xxxxxxx
#MythTV Backend server: Default=localhost
DBHostName=192.1.1.50
#The Database Pin for the MythTV Database (used in python bindings only)
DBPin=0
#MySQL Myth Database: Default=mythconverg
MySQLMythDb=mythconverg
#Primary Movie Dir. mythicalLibrarian will attempt to move to this dir first. No trailing / is accepted eg. '~/videos'
PrimaryMovieDir=./Movies
#AlternateMoveDir will act as a Seccondary move dir if the primary moive dir fails
AlternateMovieDir=./Movies
#ShowStopper = Enabled prevents generic shows and unrecognized episodes from being processed
ShowStopper=Disabled
PrimaryShowDir=./Showings
#AlternateShowDir will act as a Seccondary move dir if the primary Show dir fails
AlternateShowDir=./Showings
#CommercialMarkup will generate comskip files for recordings when they are moved. Enabled|Disabled
CommercialMarkup=Enabled
#CommercialMarkupCleanup will execute a maintenance routine which will remove comskip files if they are not needed
CommercialMarkupCleanup=Enabled
###Reporting/Communications###
#If notifications are enabled, NotifyUserName should be the same as the user logged into the GNOME Session. (your username)
Notify=Disabled
#If notifications are enabled, NotifyUserName should be the same as the user logged into the GNOME Session. (your username)
NotifyUserName='mythtv'
#Ip Address and port for XBMC Notifications Eg.XBMCIPs=( '192.168.1.110:8080' '192.168.1.111:8080' 'XBOX:8080' )
XBMCIPs=( '192.1.1.104:8080' )
#Send a notification to XBMC to Update library upon successful move job Enabled|Disabled
XBMCUpdate=Enabled
#Send Notifications to XBMC UI when library is updated Enabled|Disabled
XBMCNotify=Enabled
#Send a notification to XBMC to cleanup the library upon successful move job Enabled|Disabled
XBMCClean=Disabled
#DailyReport provides a local log of shows added to your library per day. Enabled|Disabled
DailyReport=Enabled
#Enables debug mode.  This is a verbose mode of logging which should be used for troubleshooting.  Enabled|Disabled
DEBUGMODE=Enabled
#maxItems controls the number of items in the RSS. RSS Can be activated by creating a folder in /var/www/mythical-rss.
maxItems=8
#########################USER SETTINGS##########################
########################## USER JOBS############################
#The RunJob function is a place where you can put your custom script to be run at the end of execution
#Though it may be at the top, this is actually the end of the program.  
RunJob () {
    case $jobtype in
#Successful Completion of mythicalLibrarian
        LinkModeSuccessful|MoveModeSuccessful)
            echo "SUCCESSFUL COMPLETEION TYPE: $jobtype"
            #Insert Custom User Job here
            
            #
            exit 0
            ;;
#File system error occoured
        PermissionError0Length|NoFileNameSupplied|PermissionErrorWhileMoving|FailSafeModeComplete|LinkModeFailed)
            echo "FILE SYSTEM ERROR:$jobtype"
            #Insert Custom User Job here
            
            #
               exit 1
            ;;

#Information error occoured
        TvDbIsIncomplete|GenericShow)
            echo "INSUFFICIENT INFORMATION WAS SUPPLIED:$jobtype"
              #Insert Custom User Job here
            
            #
              exit 0
            ;;
#Generic error occoured
          GenericUnspecifiedError)
              echo "UNKNOWN ERROR OCCOURED:$jobtype"
              #Insert Custom User Job here  
            
            #
              exit 3
            ;;
#Insufficent data error occoured
             NameCouldNotBeAssigned)
                  echo "NAME COULD NOT BE ASSIGNED BASED UPON DATA SUPPLIED"
                 #Insert Custom User Job here
                 
                #
                exit 3
                ;;
#Job was ignored by title or category
            titleIgnore|categoricIgnore)
            echo "Show Was ignored based on $jobtype"
                #Insert Custom User Job Here
                
                #
                exit 0
                ;;
esac
#Custom exit point may be set anywhere in program by typing RunJob on any new line
#Insert Custom User Job here

#
exit 4

}

Any help is appreciated....

Huh


- varneyb - 2011-11-17

sdsnyr94 Wrote:mythicalLibrarian is also designed to primarily be run as a MythTV user job, although it can be run from the command line. If you don't mind, also post an example of what you are entering to run it from command line.

I've tried running it any number of ways (just alone, with --scan option, with --help option, with -m option) - I get no response on stdout or stderr for anything.


- outleradam - 2011-11-17

Run mythicalSetup. It didn't complete when you ran it. That's about 1/16th of the script. Follow the setup instructions in the wiki.


- GregoryK - 2011-11-18

Small feature request:

When running --doover would it be possible to have the last output be some sort of summary of its success/failure? I run --doover occasionally to try to match up previously-missed shows, but don't really monitor it as it runs.

I'm thinking something along the lines of: "XXX Showings scanned for matches, YYY matches found and moved to Episodes, ZZZ Showings remain unmatched."

Thanks for considering this.

/gkk


- GregoryK - 2011-12-06

^^ Bump of my last request, in case Adam missed it the first time.

/GregoryK


- outleradam - 2012-01-27

I've been thinking about it and I think that might be beyond the scope of what I can handle with this app. It's a linear process, not object oriented. I don't have a group of objects I can enumerate.