[mythtv-users] Help needed for scripted recordings

Klaas de Waal klaas.de.waal at gmail.com
Sat Mar 28 19:27:16 UTC 2020

On Sat, 28 Mar 2020 at 16:43, Klaas de Waal <klaas.de.waal at gmail.com> wrote:

> On Sat, 28 Mar 2020 at 14:26, Bill Meek <keemllib at gmail.com> wrote:
>> On 3/27/20 8:41 PM, David Engel wrote:
>> > On Fri, Mar 27, 2020 at 06:58:16PM -0500, Bill Meek wrote:
>> >> On 3/27/20 12:13 PM, Klaas de Waal wrote:
>> >>> Hi all,
>> >>>
>> >>> I am attempting to fix bug #13571 and to test this I need to start
>> and then
>> >>> delete recordings lots and lots of times. It would be great if I can
>> start
>> >>> a script that starts a recording on a specified channel, wait 10
>> seconds,
>> >>> delete the recording, wait 10 seconds, start a recording etc etc.
>> >>> And I then want to run another instance of the script on another
>> channel,
>> >>> etc.
>> >>> Has anyone a script available that does something like this, or a
>> basic
>> >>> example on how to build something?
>> >>
>> >> If the 10 second length, is a requirement, no need to read further.
>> Otherwise,
>> >> I might be able change the following to delete recordings
>> automatically...
>> >
>> > Klaas can correct me if I'm wrong but I don't think 10 seconds is a
>> > hard and fast requirement.  The problem at hand seems to occur when
>> > deleting an in-progress recording but only occasionally.  I think the
>> > 10 seconds is solely to recreate the in-progress, deletion condition
>> > as frequently as possible in hopes of reproducing the problem more
>> > quickly.
>> >
>> > David
>> ...
>> Klaas,
>> New version, you can run it from a remote host (FE.) It uses the Services
>> API
>> Dvr/DeleteRecording:
>>   vcr.py --chanid=1021 --delete_while_recording --dst --host=<backend
>> hostname or IP> --length=1 --number=5 --starttime=2020-03-28T13:16 --wrmi
>> will create 5 recording rules, 1 minute apart and 1 minute long.
>> --starttime is
>> in local time and gets converted to UTC for the API.
>> 30 seconds (length/2) after --starttime the 1st recording and it's rule
>> are
>> deleted. Then every minute (length), the next recording and rule are
>> deleted.
>> The --dst switch is a kludge and subtracts 3600 seconds from --starttime.
>> Works
>> for North America.
>> Hi all,
> Thanks for the scripts. They do come close but I still miss a bit.
> David, your description is spot on.
> The crucial point is that I need to delete a recording in progress as
> often as possible.
> Reproducing the problem takes usually about 3 to 10 deletes before the
> crash happens and this is still somewhat doable by hand.
> However, to evaluate the effectiveness of various workarounds and maybe
> even fixes I want at least 100 deletes to be successful.
> Hence the need for automation.
> Ideally I would have two commands:
> - (A) start recording now on a channel, identified by chanid
> - (B) delete the recording that is now being recorded on  channel,
> identified by chanid
> I can string this together with a trivial bit of bash and do the wait
> times with sleep commands.
> Something like "while [ 1 ] ; do command_A <chanid>; sleep 10; command_B
> <chanid>; sleep 10; done".
> If command A does return an ID that is to be used by command B then that
> is OK as well of course.
> A combined script would need 3 parameters, chanid, time_recording and
> time_idle.
> It looks like the mythtv-record.py comes close as it can do a "stop", it
> only misses a "delete"command.
> I'll have a look into the scripts myself as well but I do greatly
> appreciate help with this as it is a bug that is difficult to catch.
I did look into the mythtv-record.py script.
It looks like it can do what I want it to do by creating a Single manual
recording (setting wrmi to True in the code was needed).
I then hacked a "delete recording" in it, copy&paste of the "stop

Start of recording is OK:

[klaas at modu MythTVPython]$ ./mythtv-record.py add --chanid 170858 --manual
--starttime 2020-03-28T20:00:00 --type Single --title test
-1: 170858 NPO 1 Single Record test  Start:2020-03-28T19:00:00Z
 End:2020-03-28T20:00:00Z  Priority:0      Inactive:false  Profile:Default
RecGroup:Default PlayGroup:Default LastRecorded:      Expire:true
Added: "test" (RecordId 3776).

But the delete of the recording is not:

[klaas at modu MythTVPython]$ ./mythtv-record.py delete --recordid 3776
--starttime 2020-03-28T20:00:00 --title test
Fatal API Error response: Unexpected status returned: 404: Reason: "N/A"
URL was: http://modu.home.lan:6544/Dvr/DeleteRecording?RecordedId=3776
Traceback (most recent call last):
  File "./mythtv-record.py", line 1479, in delete_recordingid
    resp_dict = backend.send(endpoint=endpoint, rest=rest, opts=opts)
line 261, in send
    reason, url))
RuntimeError: Unexpected status returned: 404: Reason: "N/A" URL was:

Looks to me that the python code does what it should do but that maybe the
Dvr/DeleteRecording is not available?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mythtv.org/pipermail/mythtv-users/attachments/20200328/85094c21/attachment.htm>

More information about the mythtv-users mailing list