Release myth2kodi -- generate Kodi friendly file-names from MythTV recordings.
#61
Yay, thanks for the quick turnaround! I've applied your commits for version 1.4.0a Smile
(2017-03-19, 08:50)stuartk Wrote: I have never done things in the way you describe, so I'm uncertain about an aspect of MythTV's behaviour here:
Does calling Handbrake as part of a MythTV User Job result in MythTV associating "/path/to/handbrakeoutputfile.mkv" with the recording?
For example, if you run myth2kodi --recording-info "/path/to/handbrakeoutputfile.mkv" does it actually return data on the recording or does it issue some sort of "recording not found" error?
My User Job just makes a transcoded copy of the recording, and MythTV doesn't keep tabs on it. Indeed --recording-info returns an error:
Code:
mackie@myth:/home/mythtv/$ sudo -u mythtv myth2kodi --recording-info /home/mythtv/video/transcoded/Grimm-EP014189710130-Where_the_Wild_Things_Were-1051_20170318000000.mkv
INFO: Attempting to access recording info for: /home/mythtv/video/transcoded/Grimm-EP014189710130-Where_the_Wild_Things_Were-1051_20170318000000.mkv
INFO: Accessing MythTV DataBase Using mysql Commands:
INFO: Attempting to pull database information on 'Grimm-EP014189710130-Where_the_Wild_Things_Were-1051_20170318000000.mkv'
INFO: Processing MythTV database info as SchedulesDirect.
ERROR: %%%% NO DATABASE INFORMATION. CHECK LOGIN/PASS OR FILE %%%%
ERROR: process_mythtvdb() CALLED FROM: parse_command_flags(): Failed to determine InputTitle from MythTV-DB, and none provided.
WARNING: NAME COULD NOT BE ASSIGNED BASED UPON DATA SUPPLIED

(2017-03-19, 08:50)stuartk Wrote: I assume it must be associated, otherwise when myth2kodi attempts to process "/path/to/handbrakeoutputfile.mkv" it would fail with a database access error.

If the "/path/to/handbrakeoutputfile.mkv" file is tracked by MythTV, then you need to be aware that if myth2kodi was not confident about a MOVE when SYMLINK is Disabled, it tries to fall-back to SYMLINK=Enabled, so that the processing can still be undone.
NOTE: --delete completely deletes a recording, including following symbolic links if they are present, so if you had MOVEd with SYMLINKing Enabled then using --delete will remove all trace of the recording. So in this case, you really do not want to run --delete as it will completely delete the recording.

In the case that myth2kodi is confident in its processing, then, with SYMLINK=Disabled the recording is deleted from MythTV, making your call to myth2kodi --delete "/path/to/mythtv/recordings/<chanid>_<starttimeutc>.mpg" redundant. If it is not confident, then myth2kodi attempts to add symbolic-link and your --delete will most likely delete the recording entirely -- which I assume is not what you want.
I mainly use the pvr.mythtv kodi plugin for watching recordings and live tv, and I occasionally use the full MythTV frontend to do the same. After I've watched a recording I either delete it, or if I want to archive it, send it to kodi after a transcode. MythTV -- I think -- is keeping track of which shows I've recorded and not scheduling those showings again, even after I delete them. Now that you have me thinking harder about that, I'm not 100% sure since I have so much of a backlog of stuff to watch Smile I was under the impression that myth2kodi's --delete was doing essentially that same thing, but maybe I should be doing what you're doing in post #55 and disconnecting first, then transcoding and moving, since I'm gathering myth2kodi is wanting to keep track of things more.

I set logging to 3 and ran my workflow again, and looking through the log my feeling that I'm doing things in the "wrong" order is strengthened. I think this line in particular isn't intended behavior acting on my transcoded file as if it is a mythtv-controlled recording:
Code:
[2017-03-19T13:55:44] DEBUG: Looks ok, FILE is named like a MythTV recording: '/home/mythtv/video/transcoded/Grimm-EP014189710130-Where_the_Wild_Things_Were-1051_20170318000000.mkv'
I could probably "fix" this by giving the file names something that look less like a mythtv recording, but I've not tested what myth2kodi would do (yet). Or maybe it's not a potential problem -- I've not read all the myth2kodi code to see what processing as a recording entails. Logs of my myth2kodi move and --delete are on this pastebin link. Switching --no-symlinks to --strip fixed those errors in --delete.

http://pastebin.com/7hnF8mNg

(2017-03-19, 08:50)stuartk Wrote: 1. I'll look into whether there is a clean way to handle your use-case for the install script. Do I understand correctly that you are running:
Code:
sudo -u mythtv ./install.sh
and then attempting to do a system wide install (that is, install to /usr/local/bin)? EDIT: I've had a look at this and I can't reproduce an issue when running the install script using sudo -u from another user... Could you post the install log from when it failed for you? Or better yet, enable debugging (set LOGLEVEL=3 on line 66 of install.sh) and try again and post that log?
That's correct. The problem comes when the script asks my mythtv user to sudo as root. mythtv is not a sudoer. Here are the interactive output and the log file:
Code:
mackie@myth:/home/mythtv/myth2kodi-1.4.0$ sudo -u mythtv ./install.sh
  Writing installation log to: '/tmp/m2k_install_log_2017-03-19-8led'.


          #######################################
          #### Install Script for myth2kodi. ####
          #######################################
          ./install.sh

  This script will walk you through the installation process.
  It allows you to customise some of the installation.
  If you select an install directory that requires elevated
  privileges (such as "/usr/local/bin"), you will be asked for
  your sudo password by the system commands as needed.

  NOTE: You should run the install script as the user who will
        be running myth2kodi.

Do you want to install myth2kodi? y/(n)>y

   There are two modes of installation:
     1. Interactive (Preferred) -- Informs you of progress, provides
                 the option to select non-default install location,
                 as well as some other basic configuration.

     2. Quick -- Do default install, no questions or feedback.

What type of install do you want to do? (1)|2 >1

  NOTE: For non-default install directory, specify explicit absolute path.

Where do you want myth2kodi installed? [DEFAULT:/usr/local/bin]>

The myth2kodi script requires a working directory. This is used
to store myth2kodi's local television series tables, the file
myth2kodi.conf which is used for user configuration settings,
as well as logging information and other bits and pieces.

Do you want to set-up a working directory for 'mythtv'? (y)/n>y

  NOTE: For non-default working directory, specify either $HOME based or absolute path.

Where do you want the working directory? [DEFAULT:$HOME/.myth2kodi]>/home/mythtv/.myth2kodi

[sudo] password for mythtv:
[sudo] password for mythtv:^c


/tmp/m2k_install_log_2017-03-19-8led:
[2017-03-19T14:29:42] INFO: Running myth2kodi's installation script as mythtv
[2017-03-19T14:29:42] INFO: Install script called on 2017-03-19 at 14:29:42.
[2017-03-19T14:29:42] INFO: Running installation script for myth2kodi Version 1.
4.0
[2017-03-19T14:29:42] INFO: Install script successfully initialised.
[2017-03-19T14:29:42] DEBUG: SCRIPT_PATH='/mnt/raid/home/mythtv/myth2kodi-1.4.0'
[2017-03-19T14:29:42] DEBUG: CALLER='mythtv'
[2017-03-19T14:30:10] DEBUG: ENTERING: get_install_type() ; CALLED FROM: main()
[2017-03-19T14:30:14] INFO: Selected interactive install mode.
[2017-03-19T14:30:14] DEBUG: ENTERING: prepare_installation() ; CALLED FROM: mai
n()
       DEVELOPMENT_INSTALL='Disabled'
       SCRIPT_PATH='/mnt/raid/home/mythtv/myth2kodi-1.4.0'
[2017-03-19T14:30:14] DEBUG: ENTERING: create_temporary_copies_scripts() ; CALLE
D FROM: prepare_installation()
       SCRIPT_PATH='/mnt/raid/home/mythtv/myth2kodi-1.4.0'
[2017-03-19T14:30:14] DEBUG: Creating a temporary copy of myth2kodi for install.
[2017-03-19T14:30:14] DEBUG: Creating a temporary copy of mythdb_access for inst
all.
[2017-03-19T14:30:14] DEBUG: Creating a temporary copy of bashlogging for instal
l.
[2017-03-19T14:30:14] DEBUG: Creating a temporary copy of m2k_notify for install
.
[2017-03-19T14:30:14] DEBUG: M2K_INSTALL_MYTH2KODI_FILE='/tmp/m2k_install_myth2k
odi_2017-03-19-Txu6'
[2017-03-19T14:30:14] DEBUG: M2K_INSTALL_MYTHDB_ACCESS_FILE='/tmp/m2k_install_my
thdb_access_2017-03-19-9iJM'
[2017-03-19T14:30:14] DEBUG: M2K_INSTALL_BASHLOGGING_FILE='/tmp/m2k_install_bash
logging_2017-03-19-ZyGX'
[2017-03-19T14:30:14] DEBUG: M2K_INSTALL_M2K_NOTIFY_FILE='/tmp/m2k_install_m2k_n
otify_2017-03-19-kW6K'
[2017-03-19T14:30:14] DEBUG: ENTERING: create_temporary_copy_conf() ; CALLED FRO
M: prepare_installation()
       SCRIPT_PATH='/mnt/raid/home/mythtv/myth2kodi-1.4.0'
       TODAY='2017-03-19'
[2017-03-19T14:30:14] DEBUG: Creating a temporary copy of myth2kodi.conf for ins
tall.
[2017-03-19T14:30:14] DEBUG: ENTERING: get_install_dir() ; CALLED FROM: main()
[2017-03-19T14:30:18] INFO: Install directory set as: '/usr/local/bin'
[2017-03-19T14:30:18] DEBUG: ENTERING: get_working_dir_location() ; CALLED FROM:
main()
[2017-03-19T14:32:56] WARNING: It appears you have set a fixed working directory
but not an install directory owned by 'mythtv'.
         This probably means, despite install location, only 'mythtv' will be ab
le to run myth2kodi.
[2017-03-19T14:32:56] INFO: Setting working directory as: '/home/mythtv/.myth2ko
di'
[2017-03-19T14:32:56] DEBUG: ENTERING: make_customisations() ; CALLED FROM: main
()
       HOME='/home/ray'
       INSTALL_DIRECTORY='/usr/local/bin'
       M2K_CUSTOM_WORKING_DIRECTORY='/home/mythtv/.myth2kodi'
       CREATE_WORKING_DIR='y'
       CALLER='mythtv'
       M2K_INSTALL_CONF_FILE='/tmp/m2k_install_conf_2017-03-19-FLeT'
[2017-03-19T14:32:56] DEBUG: Adding custom working directory to the myth2kodi sc
ript's settings.
[2017-03-19T14:32:56] DEBUG: Setting 'Librarian' in myth2kodi.conf to: 'mythtv'.
[2017-03-19T14:32:56] DEBUG: Setting 'Librarian' in myth2kodi.conf to: 'mythtv'.
[2017-03-19T14:32:56] DEBUG: ENTERING: install_scripts() ; CALLED FROM: main()
       INSTALL_DIRECTORY='/usr/local/bin'
       M2K_INSTALL_MYTH2KODI_FILE='/tmp/m2k_install_myth2kodi_2017-03-19-Txu6'
       M2K_INSTALL_MYTHDB_ACCESS_FILE='/tmp/m2k_install_mythdb_access_2017-03-19
-9iJM'
       M2K_INSTALL_BASHLOGGING_FILE='/tmp/m2k_install_bashlogging_2017-03-19-ZyG
X'
       M2K_INSTALL_M2K_NOTIFY_FILE='/tmp/m2k_install_m2k_notify_2017-03-19-kW6K'
install_scripts(): Sorry, try again.

(2017-03-19, 08:50)stuartk Wrote: 2. The "realpath: unrecognized option '--no-symlinks'" is an Ubuntu specific bug I was not aware of, it looks like it should be easily fixed as "--no-symlinks", at least on my system, is just another name for the same command as "-s" or "--strip". I'll include the change in an bug-fix release. And yes, hopefully the the two rm errors are just a result of realpath having failed, but I'll look into it and revise the code to protect against this in the future.
Seems fixed! (Log is in pastebin link above.) But, I might shouldn't be using --delete.

Thanks again for your hard work!
Reply


Messages In This Thread
RE: myth2kodi -- generate Kodi friendly file-names from MythTV recordings. - by mackie - 2017-03-19, 22:32
Logout Mark Read Team Forum Stats Members Help
myth2kodi -- generate Kodi friendly file-names from MythTV recordings.2