Release - myth2kodi -- generate Kodi friendly file-names from MythTV recordings.

  Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
mackie Offline
Junior Member
Posts: 3
Joined: Mar 2017
Reputation: 1
Post: #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!
find quote
stuartk Offline
Junior Member
Posts: 36
Joined: Dec 2016
Reputation: 8
Post: #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.
find quote
jctennis Offline
Senior Member
Posts: 141
Joined: Feb 2013
Reputation: 7
Post: #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)

[Image: Forum_Signature.jpg]
(This post was last modified: 2017-03-21 16:37 by jctennis.)
find quote
stuartk Offline
Junior Member
Posts: 36
Joined: Dec 2016
Reputation: 8
Post: #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.
(This post was last modified: 2017-03-21 17:26 by stuartk.)
find quote
jctennis Offline
Senior Member
Posts: 141
Joined: Feb 2013
Reputation: 7
Post: #65
Yeah. That was the problem. I didn't realize there was a new release.

[Image: Forum_Signature.jpg]
find quote
stuartk Offline
Junior Member
Posts: 36
Joined: Dec 2016
Reputation: 8
Post: #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.
find quote
jctennis Offline
Senior Member
Posts: 141
Joined: Feb 2013
Reputation: 7
Post: #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.

[Image: Forum_Signature.jpg]
find quote
mackie Offline
Junior Member
Posts: 3
Joined: Mar 2017
Reputation: 1
Post: #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.
find quote
stuartk Offline
Junior Member
Posts: 36
Joined: Dec 2016
Reputation: 8
Post: #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.
(This post was last modified: 2017-03-23 09:01 by stuartk.)
find quote
Post Reply