• 1
  • 3
  • 4
  • 5(current)
  • 6
  • 7
  • 8
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
#62
(2017-03-19, 22:32)mackie Wrote: 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.
Firstly, a big chunk of myth2kodi's functionality is built around having access to the MythTV database. At the moment the processing of your transcoded files is working a little bit out of luck. For example, had you been using the Python-bindings then myth2kodi would have aborted as soon as the database access failed. The MySQL access method is mostly kept around as a legacy or fall-back version, for example older versions of MythTV don't have Python-bindings.
That being said, clearly if you can provide enough info at the command line, as you do with your series and episode titles, the processing can still work. So, I'll look into the control flow and make sure that processing proceeds if there seems to be enough information provided at the command line.

Using myth2kodi --delete with Python-bindings does almost exactly the same thing as deleting a recording via the MythTV-frontend or mythweb, that is, in each case the actual deletion is done via a call to mythbackend.
Using myth2kodi --delete with the MySQL access method is a little different, as myth2kodi handles the deleting directly, but the end result should be the same, if it is not then that is a bug.

NOTE: The duplicate recording protection in MythTV is based on a table in the MythTV database called oldrecorded. The MythTV-DB access from myth2kodi is only to a separate table called recorded, so --delete and --disconnect do not affect MythTV's ability to avoid duplicate recordings.

As to changing your work-flow, I do not think it is necessary, the way you are doing things should be fine. It is just that, as your approach is one I had not considered, you have run into a few rough corners of the code. The part of my previous post warning about --delete was based on the incorrect assumption that MythTV was somehow associating your transcoded recording with the original. As that is not the case, once you have successfully transcoded a recording and moved it to your Kodi library, using myth2kodi --delete should work without a problem as a way to delete the original recording. Once myth2kodi has either processed a recording in MOVE mode with SYMLINKing Disabled, or as myth2kodi --delete or myth2kodi --disconnect, it no longer keeps track of anything.


(2017-03-19, 22:32)mackie Wrote: 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.
The pattern matching that decides whether a file is a MythTV recording file is too lose, I'll see if I can tighten it so that it will no longer incorrectly identify compound names like you use as belonging to MythTV. Though this will have to be part of the control flow review I mentioned above, as I'll need to downgrade the associated error to a warning and not automatically abort when a recording does not belong to MythTV.

(2017-03-19, 22:32)mackie Wrote: 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:
[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 able to run myth2kodi.
[2017-03-19T14:32:56] INFO: Setting working directory as: '/home/mythtv/.myth2kodi'
On install, there isn't much I can do from the script point of view, at least without changing fundamentally how it functions. To install in a root owned directory you need sudo privileges. However, as you are already setting a fixed working directory for myth2kodi then you might as well do a local install. That is, specify something like /home/mythtv/bin as the install directory. That way, as your mythtv user owns that directory, you will not require sudo privileges for the install. You just need to make sure that the install location is part of the mythtv user's path, otherwise you'll need to call it via the full path at the command line.
Reply
#63
Hey Stuart. I am starting to get my recordings transcoded and I am using myth2kodi --disconnect. It is throwing up a realpath: unrecognized option '--no-symlinks' error. I assume this is another system difference brought on by our differing distros. I'm not sure what the script is trying to do here but it doesn't seem to be screwing anything major up that I can see (at least so far.) Here is the log:

Code:
DEBUG: ENTERING: log_rotation() ; CALLED FROM: m2k_init()
DEBUG: LOGFILE=/media/Storage/myth2kodi/myth2kodi.log-
DEBUG: LOGLEVEL=3-
DEBUG: LOGTYPE=filestderr-
DEBUG: ENTERING: validate_settings() ; CALLED FROM: m2k_init()
ERROR: 'PrimaryShowDir' is not a directory: /media/Storage/recordedShows
DEBUG: myth2kodi script initialisation complete.
DEBUG: Running myth2kodi as 'mythtv'
DEBUG: ENTERING: validate_args() ; CALLED FROM: main()
DEBUG: Called with 2 arguments. Called as:
       myth2kodi '--disconnect' "/media/Storage/Videos/Aqua Teen Hunger Force Forever/Season 4/Aqua Teen Hunger Force Forever S04E07 (Party All the Time).ts" "" "" '' ''
DEBUG: Arguments seem valid.
DEBUG: ENTERING: parse_command_flags() ; CALLED FROM: main()
DEBUG: Recognised command line switch '--disconnect'
DEBUG: ENTERING: disconnect_recording() ; CALLED FROM: parse_command_flags()
WARNING: Attempting to disconnect recording: '/media/Storage/Videos/Aqua Teen Hunger Force Forever/Season 4/Aqua Teen Hunger Force Forever S04E07 (Party All the Time).ts'
         This will PERMANENTLY disconnect the recording from MythTV,
         deleting the associated MythTV database entry.
         Are you sure you want to continue?

DEBUG: ENTERING: identify_recording_files() ; CALLED FROM: disconnect_recording()
DEBUG: ENTERING: find_file_link_pairs() ; CALLED FROM: identify_recording_files()
       arg1: /media/Storage/Videos/Aqua Teen Hunger Force Forever/Season 4/Aqua Teen Hunger Force Forever S04E07 (Party All the Time).ts
realpath: unrecognized option '--no-symlinks'
Usage:
realpath [-s|--strip] [-z|--zero] filename ...
realpath -h|--help
realpath -v|--version
DEBUG: RECORDING_LINK: ''
DEBUG: RECORDING_LINK_OWNER: 'MythTV'
DEBUG: RECORDING_FILE: '/media/Storage/Videos/Aqua Teen Hunger Force Forever/Season 4/Aqua Teen Hunger Force Forever S04E07 (Party All the Time).ts'
DEBUG: RECORDING_FILE_OWNER: 'myth2kodi'
DEBUG: ENTERING: set_recording_name() ; CALLED FROM: identify_recording_files()
       arg1: '/media/Storage/Videos/Aqua Teen Hunger Force Forever/Season 4/Aqua Teen Hunger Force Forever S04E07 (Party All the Time).ts'
INFO: /media/Storage/Videos/Aqua Teen Hunger Force Forever/Season 4/Aqua Teen Hunger Force Forever S04E07 (Party All the Time).ts <==> /media/Storage/mythtv/recordings/1878_20170222054500.ts
realpath: unrecognized option '--no-symlinks'
Usage:
realpath [-s|--strip] [-z|--zero] filename ...
realpath -h|--help
realpath -v|--version
DEBUG: Setting RECORDING_PATH=''
DEBUG: Setting RECORDING_NAME='1878_20170222054500.ts'
DEBUG: RECORDING_PATH: ''
DEBUG: RECORDING_NAME: '1878_20170222054500.ts'
DEBUG: ENTERING: delete_recording_from_mythtv() ; CALLED FROM: disconnect_recording()
       RECORDING_NAME='1878_20170222054500.ts'
       DATABASE_ACCESS='PythonBindings'
       RERECORD=''
DEBUG: Deleted recording info will be stored in temporary file: '/tmp/m2k_delrecinfo_2017-03-21T102852-ajul'
mythdb_access: DEBUG:__main__:Establishing database connection
mythdb_access: DEBUG:__main__:Attempting to write data to file: /tmp/m2k_delrecinfo_2017-03-21T102852-ajul
mythdb_access: DEBUG:__main__:Calling write_data()
mythdb_access: DEBUG:__main__:Operation complete.
mythdb_access: DEBUG:__main__:Closing out the file/stdout
mythdb_access: DEBUG:__main__:Deleting recording: 1878_20170222054500.ts
DEBUG: File tracked by myth2kodi.
DEBUG: Removing lines mentioning '/media/Storage/Videos/Aqua Teen Hunger Force Forever/Season 4/Aqua Teen Hunger Force Forever S04E07 (Party All the Time).ts' from '/media/Storage/myth2kodi/created.tracking'
DEBUG: ENTERING: exit_job() ; CALLED FROM: main()
       Called with 1 arguments
       arg 1 = 'SuccessfulCommandLineSwitch'
DEBUG: Either: Notify=Disabled; scan mode; recording is in an ignore list; or NOTIFY_MSG was not set.
/media/Storage/Videos/Aqua Teen Hunger Force Forever/Season 4/Aqua Teen Hunger Force Forever S04E10 (Moonajuana)
Reply
#64
(2017-03-21, 16:34)jctennis Wrote: Hey Stuart. I am starting to get my recordings transcoded and I am using myth2kodi --disconnect. It is throwing up a realpath: unrecognized option '--no-symlinks' error. I assume this is another system difference brought on by our differing distros. I'm not sure what the script is trying to do here but it doesn't seem to be screwing anything major up that I can see (at least so far.)

Yeah, it's another Ubuntu specific thing. Grab the latest release (v1.4.1) or pull from the repo and run install.sh, that should resolve the issue. Let me know if it doesn't.

NOTE: As you're running in MOVE mode with SYMLINKing, the realpath not working means the link will not have been identified and so will not have been removed (which is a key step in the disconnecting) before the call to delete, this may mean that the recording that you tried to disconnect was deleted. My apologies if this is the case.
Reply
#65
Yeah. That was the problem. I didn't realize there was a new release.
Reply
#66
Updated Release Available (v1.4.1):

Bug Fixes
  • Fix calls to realpath for Ubuntu.

The links provided in the original post of this thread always point to the latest version of myth2kodi.

Thanks to mackie for the feedback.
Reply
#67
I'm just throwing this up here in case someone will get some use from it. Since we had our discussion a few pages back about using handbrake with the files moved by myth2kodi I threw a real quick and dirty script together to compress my recordings and then disconnect them from mythtv. It does a great job and Kodi still skips the commercials perfectly. I don't use the cutlist to actually modify the video itself due to the occasional false positive. I want the ability to back up if part of the show gets cut off.

By default the script will place the converted file into the same directory it found the original in. It will not delete the original unless you remove the # from the proper line.

I have it names convert.sh. Make sure to chmod +x so the script has permission to be executed.
Code:
#!/bin/bash

fullfile=$1
fbname=${fullfile%.*}
echo "$fbname"

HandBrakeCLI -v -i "$1" -o "$fbname".mp4 --preset "Very Fast 720p30" ;

echo y|myth2kodi --disconnect  "$1"
#uncomment next line to delete original
#rm "$1"

It can be run on any file from the terminal using the following command (note: the script must be run by your myth librarian, in my case mythtv. There is no error checking built in so remember to run it as the proper user or myth2kodi won't do the disconnect)
Code:
./convert.sh "/path/to/recorded/file.ts"
All my recordings from mythtv are in the .ts container so I call the script with a find command when I want to run it on my whole recordings directory (in my case /media/Storage/Videos)
Code:
find "/media/Storage/Videos"  -name "*.ts" -exec /media/Storage/convert.sh {} \;

I have it set up as a cron job to run weekly on my entire recordings folder, but you could easily adapt the script to work as a mythtv user job or any other type of automation. As long as it fits the format of script "path/file" it should run properly.

Hope this helps someone else. I can't offer much in the way of support because I couldn't code my way out of a paper bag.
Reply
#68
Just wanted to drop a note that I've done a little more playing around and tested install.sh. As you suggested, I moved m2k to /home/mythtv/bin -- that does make much more sense. The only thing I can say the install script didn't do in order to make a functioning install, other than prompting for User Settings, is changing $binpath. I know you're already aware of that, since I see your TODO comments Smile

I didn't make the change to use the Python bindings to test those out since I think my odd use case would break.

It's doing what I need it to do, though! Thanks again.
Reply
#69
(2017-03-23, 03:17)mackie Wrote: Just wanted to drop a note that I've done a little more playing around and tested install.sh. As you suggested, I moved m2k to /home/mythtv/bin -- that does make much more sense. The only thing I can say the install script didn't do in order to make a functioning install, other than prompting for User Settings, is changing $binpath.

Thanks for pointing out that the binpath wasn't being set, that was actually a single character typo on my part, a fix is in the repo now and so will work right away if you are installing from a clone, or otherwise will be part of the next release (which I expect to put out in the next week or two).

I'll probably add the option of walking through the essential User Settings as part of the install script at some point in the future, though that will not be near term.

(2017-03-23, 03:17)mackie Wrote: I didn't make the change to use the Python bindings to test those out since I think my odd use case would break.
You are right that, with the current release, your use case would not work with the Python bindings as the failure to access the MythTV-DB would cause myth2kodi to print an error message and abort. However, in the next release your use case should work for either DATABASE_ACCESS method, and it will do so more cleanly than it does currently.
Reply
#70
Thumbs Up 
Things are still working well! Thanks again Smile So far the only failures I've had has been title/subtitle matching multipart episodes. In thetvdb, etc., they are listed with part number in parentheses [(1), (2)...], and my MythTV data don't include them. Not a problem to keep an eye on the User Job queue, and if any fail, just fire off myth2kodi from the command line with the full subtitle it (and kodi) want. Works fine in my book -- I don't expect any program of this sort of match 100% of the time.

One other thing I can think of at the moment -- and you may already be aware of this since $binpath is already on your radar -- if $binpath isn't in $Librarian's PATH, "$binpath/"is required in front of some command calls in script in order to make them work, for example on line 5183 of current commit. At least that's how I got it to work for me Smile

Cheers!

Quick edit: Thinking more about this, is it considered better to not have the script name (myth2kodi) hard coded also? I don't have a lot of experience, so I don't really know.
Reply
#71
Updated Release Available (v1.4.2):

Bug Fixes
  • Fix failure to set binpath on install.
  • Tighten name based check of whether file is a MythTV recording.
  • Make sure Sxx and Exx are set from season and episode numbers for all guide-data types.
  • Fix counter initialisation for dir.tracking maintenance (only affects logging messages).
  • Fix logic of whether to attempt SxxExx extraction from Plot (only applies to SydFTA guide-data).
  • Fix logging based on PIPESTATUS in download_series_info().

Other Changes
  • Allow processing of non-MythTV files (NOTE: This already sort-of worked if using the MySQL based db-access method, but this was due to missing checks. Proper checks have been added and processing explicitly allowed.).
    • Without the MythTV-DB, enough info must be provided on the command line for processing to proceed.
    • Most additional functionality is not supported, ie --disconnect, --delete, etc.
    • If a link is created then --undo is supported.
  • Do not add doover entries when TRACKING='Disabled'.
  • Improve checks and messages around --disconnect and --delete.
  • Move storagegroup info access to function, add a MySQL based method.
  • Remove stdout based logging options, they interfere with new assignment logging.
  • Add diagnostic check for RSS directory.
  • Add FileIsNotRecording exit type.
  • Shellcheck based clean-up.
  • Commenting and logging message clean-up.

The links provided in the original post of this thread always point to the latest version of myth2kodi.

Thanks to mackie for the feedback.
Reply
#72
(2017-04-02, 08:05)stuartk Wrote: Updated Release Available (v1.4.2):

Bug Fixes
  • Make sure Sxx and Exx are set from season and episode numbers for all guide-data types.

Ah, I was wondering if this was working before, when I was attempting to call Season and Episode using Schedules Direct data. I suspected it wasn't, but didn't have time to test it. Smile

Speaking of processing non-MythTV files and Schedules Direct, it seems like one of the more common discrepancies between SD and thetvdb.com are these words: the, a, an, of, and. Maybe it would be fairly easy to tweak the Subtitle matching algorithm to try matches without those words? Almost all of my failed MythTV user jobs are the results of SD not exactly matching thetvdb.

Thanks again for all your work!
Reply
#73
Hi guys, this is exactly what I was looking for but I'm very new to MythTV and I'm not sure I'm getting things plugged in correctly.

I installed the script as my myth user and it runs OK by hand.

I went into MythTV settings, general, and set "Allow User Job #1 jobs" enabled in the 8th screen, then set in the 10th screen:
Code:
/usr/local/bin/myth2kodi "%DIR%/%FILE%"

When a scheduled recording happens it doesn't even seem to try running. Here's a mythbackend log excerpt: https://paste.ubuntu.com/24514141/

I have a minor, secondary issue as well. The files moved by the myth2kodi script are mode 644. My kodi install (which runs over the network and accesses the share with a different username) is unable to delete files when I'm done watching them.

Thanks!
Reply
#74
(2017-03-22, 19:42)jctennis Wrote: I'm just throwing this up here in case someone will get some use from it. Since we had our discussion a few pages back about using handbrake with the files moved by myth2kodi I threw a real quick and dirty script together to compress my recordings and then disconnect them from mythtv. It does a great job and Kodi still skips the commercials perfectly. I don't use the cutlist to actually modify the video itself due to the occasional false positive. I want the ability to back up if part of the show gets cut off.

By default the script will place the converted file into the same directory it found the original in. It will not delete the original unless you remove the # from the proper line.

I have it names convert.sh. Make sure to chmod +x so the script has permission to be executed.
Code:
#!/bin/bash

fullfile=$1
fbname=${fullfile%.*}
echo "$fbname"

HandBrakeCLI -v -i "$1" -o "$fbname".mp4 --preset "Very Fast 720p30" ;

echo y|myth2kodi --disconnect  "$1"
#uncomment next line to delete original
#rm "$1"

It can be run on any file from the terminal using the following command (note: the script must be run by your myth librarian, in my case mythtv. There is no error checking built in so remember to run it as the proper user or myth2kodi won't do the disconnect)
Code:
./convert.sh "/path/to/recorded/file.ts"
All my recordings from mythtv are in the .ts container so I call the script with a find command when I want to run it on my whole recordings directory (in my case /media/Storage/Videos)
Code:
find "/media/Storage/Videos"  -name "*.ts" -exec /media/Storage/convert.sh {} \;

I have it set up as a cron job to run weekly on my entire recordings folder, but you could easily adapt the script to work as a mythtv user job or any other type of automation. As long as it fits the format of script "path/file" it should run properly.

Hope this helps someone else. I can't offer much in the way of support because I couldn't code my way out of a paper bag.

First I want to say that myth2kodi works pretty good. I have been using mythicalLibrarian for the last 5 years and looked for an alternative when I needed to set up another Mythtv system. Unfortunately mythicalLibrarian code relies on google code which is no longer viable (at least the install script does). I have shows that I leave as is and some shows that I transcode so as not to take up space as I don't watch them regularly. I add code into the "success" of myth2kodi. I currently use CCExtractor in my setup as my wife likes the captions. That is included in the completion as well.

Code:
#Successful Completion of myth2kodi
    LinkModeSuccessful|MoveModeSuccessful|CopyModeSuccessful|FailSafeModeComplete)
      inform "SUCCESSFUL COMPLETION TYPE: $jobtype"

      #create link to closed caption file from CCExtractor
        filenme=$(basename "$InputPath") #get mythical file name
        exten="${filenme##*.}" #pull file name extension
        fname="${filenme%.*}"         #get name without extension
        searchname=$(echo "$fname")        #create searchname
        chmod 777 "/var/lib/mythtv/recordings/"$searchname".srt"  #change permissions to allow moving
        mv "/var/lib/mythtv/recordings/"$searchname".srt" "$MoveDir/$ShowFileName.srt" #move to video directory
        chmod 777 "$MoveDir/$ShowFileName.srt"  #change permissions to allow other machines to access

        #convert video
        TVFILENAME="${filenme%.*}"
        TVCHAN="${TVFILENAME%_*}"
        TVUTCTIME="${TVFILENAME##*_}"
        /usr/bin/HandBrakeCLI -i "$MoveDir/$ShowFileName.ts" -o "$MoveDir/$ShowFileName.m4v" --subtitle "1" --audio 1 --aencoder copy:aac --audio-fallback faac --audio-copy-mask aac --preset="High Profile" 2> "/var/lib/mythtv/recordings/handbrakelog.txt"
        chown mythtv:mythtv "$MoveDir/$ShowFileName.m4v" #change owner so no issues with delete or watch
        chmod 777 "$MoveDir/$ShowFileName.m4v"  #change permissions to allow access on other machines
        chmod 777 "$MoveDir/$ShowFileName.ts"   #change permissions of original recording to allow next step
        ln -sfn "$MoveDir/$ShowFileName.m4v" "/var/lib/mythtv/recordings/"$searchname".ts"  #change symlink to point to new file
        rm -f "$MoveDir/$ShowFileName.ts"   #delete original recording

What it does:
It moves the previous srt file into the directory created by myth2kodi. This file was created from user job using CCExtractor.
It transcodes the file using handbrakeCLI. {when set up as a user job, this can take some time}
It changes the symlink created by myth2kodi to point to new transcoded file.
It deletes original recording moved by myth2kodi.

I don't use the cutlist, but that can be accomplished using mythtranscode before handbrake.
http://tech.surveypoint.com/posts/mythtv...handbrake/
Reply
#75
(2017-02-09, 03:14)stuartk Wrote: @jctennis There is a "show translation" mechanism in place for
handling just this case. The tv-series are identified by myth2kodi
using http://thetvdb.com/, the closest match between your guide
data and TheTVDB is assumed to be correct. When that is not the
case you just need to add a translation entry into a showTranslations
file in myth2kodi's working directory. So, you'll need to add a file called:

Code:
"$m2kdir"/showTranslations

which for you means:

Code:
/media/Storage/myth2kodi/showTranslations

with the entry:

Code:
Timeless = Timeless (2016)

The format is just one entry per line of the form:

Code:
My Guide Show Title = www.TheTVDB.com Show Title

There needs to be one space either side of the equal-sign and the
guide show title needs to match exactly, including case. When the
guide data is really bad, you end up with something like the example
for Sydney's free-to-air guide data that is in the repository.

Whenever a show is incorrectly identified, just go to http://thetvdb.com/ and
search for "Guide Show Title" (in this case it was "Timeless"), then add a
showTranslation entry.

I am using the showTranslations file for Empire = Empire (2015). It is ignoring and still using "Empire". The file is in /home/mythtv/.mythtv/.myth2kodi/ ... is that where it needs to be? Same spot that mythicalLibrarian uses but doesn't seem to be working. The actual script exists in /usr/local/bin/myth2kodi.
Reply
  • 1
  • 3
  • 4
  • 5(current)
  • 6
  • 7
  • 8

Logout Mark Read Team Forum Stats Members Help
myth2kodi -- generate Kodi friendly file-names from MythTV recordings.2