thru System Events

Have a MythTV related problem? Ask for help from other MythTV users here.

Moderator: Forum Moderators

Post Reply
Posts: 6
Joined: Sat Jul 23, 2016 1:54 am
Canada thru System Events

Post by cythraul » Thu Aug 09, 2018 10:12 pm

Hi everyone,

I wanted to share about my experience trying to use this script thru events instead of a user job. I already use thru the record started and recordings deleted/expired events so I can get access to my recordings thru Plex.

The script: (v2.)

1- Figured out how to add a finished recording event

Found the event names here: ... ource.html

2- Added to the settings table using "mysql -u root mythconverg". It should be done thru mythtv-setup but I just hate starting an X session for that tool. So bloody painful.

Previously, I copied the script under /usr/local/bin/ and made it executable with chmod a+x

INSERT INTO mythconverg.settings (value,data,hostname) values ('EventCmdRecFinished','/usr/local/bin/ --chanid "%CHANID%" --starttime "%STARTTIMEUTC%" --tzoffset "-05" --verbose all >> /var/log/mythtv/transcode-h264-v2.log','[backend hostname]')

The tzoffset depends on your location. I don't quite understand why it's needed at all but the script requires it for the moment.

Verbosity is optional, so is the redirection to the log file.

3- Commented out line 195-197 so it can run without having a jobid:

Code: Select all

#                        job.update({'status':job.PAUSED, 
#                                    'comment':'Waited %d secs for the commercial flagging job' % (waititer*POLL_INTERVAL) \
#                                     + ' currently running on this recording to complete.'})
There's probably a better way but I'm not knowledgeable enough about Python. :( Besides, I'm not a fan about indentation errors.

Also, I commented out the break at line 204. If I understand correctly, that's to get out of a while loop when the condition is still true. We don't want that here.. I think.

Anyway, I hope that helps or, at least, does not confuse anyone.


Posts: 6
Joined: Sat Jul 23, 2016 1:54 am

Re: thru System Events

Post by cythraul » Mon Aug 13, 2018 2:03 pm

Hi everyone,

I have a small problem with the script. I noticed it always ended with result code 1. It turns out that it has problem committing the recording markups...
Traceback (most recent call last):
File "/myth/", line 683, in <module>
File "/myth/", line 676, in main
runjob(chanid=opts.chanid, starttime=opts.starttime, tzoffset=opts.tzoffset)
File "/myth/", line 560, in runjob
File "/usr/lib/python2.7/dist-packages/MythTV/", line 625, in commit
','.join(['?' for a in fields])), data)
File "/usr/lib/python2.7/dist-packages/MythTV/", line 99, in executemany
raise MythDBError(MythDBError.DB_RAW, e.args)
MythTV.exceptions.MythDBError: MySQL error 1062: Duplicate entry '1171-2018-01-15 21:00:00-33-0' for key 'PRIMARY'
Line 625 is the commit() line below:

Code: Select all

    # fix during in the recorded markup table this will be off if commercials are removed
    duration_msecs, e = get_duration(db, rec, transcoder, outfile)
    duration_msecs = 1000*duration_msecs
    for index,mark in reversed(list(enumerate(rec.markup))):
        # find the duration markup entry and correct any error in the video duration that might be there
        if mark.type == 33:
            if debug:
                print 'Markup Duration in milliseconds "%s"' %
            error = - duration_msecs
            if error != 0:
                if debug:
                    print 'Markup Duration error is "%s"msecs' % error
       = duration_msecs
                #rec.bookmark = 0
                #rec.cutlist = 0
I'm not sure how to troubleshoot this. As I said earlier, I'm not good with Python. :(

Post Reply