<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, 29 Mar 2020 at 17:05, Bill Meek <<a href="mailto:keemllib@gmail.com">keemllib@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 3/29/20 9:34 AM, Klaas de Waal wrote:<br>
> On Sat, 28 Mar 2020 at 20:41, Bill Meek <<a href="mailto:keemllib@gmail.com" target="_blank">keemllib@gmail.com</a>> wrote:<br>
> <br>
>> On 3/28/20 2:27 PM, Klaas de Waal wrote:<br>
>>> File "./mythtv-record.py", line 1479, in delete_recordingid<br>
>>> resp_dict = backend.send(endpoint=endpoint, rest=rest, opts=opts)<br>
>><br>
>> Need to use postdata rather than rest, for example:<br>
>><br>
>> postdata = {<br>
>> 'RecordedId': recordedid,<br>
>> 'ForceDelete': 'True',<br>
>> 'AllowRerecord': 'True'<br>
>> }<br>
>><br>
>> resp_dict = backend.send(endpoint=endpoint, postdata=postdata,<br>
>> opts=opts)<br>
>><br>
>><br>
>> Yes this does work and it can actually delete a recording in progress.<br>
> Problem is that it requires a recordedid but when I start the recording I<br>
> get a recordid.<br>
> As shown by the following:<br>
> <br>
> [klaas@modu MythTVPython]$ ./mythtv-record.py add --chanid 170858 --manual<br>
> --starttime 2020-03-29T16:15:00 --type Single --title test2 --duration=60<br>
> -1: 170858 NPO 1 Single Record test2 Start:2020-03-29T14:15:00Z<br>
> End:2020-03-29T15:15:00Z Priority:0 Inactive:false Profile:Default<br>
> RecGroup:Default PlayGroup:Default LastRecorded: Expire:true<br>
> <br>
> Added: "test2" (RecordId 3796).<br>
> <br>
> MariaDB [mythconverg]> select chanid,title,recordid,recordedid from<br>
> recorded where recordid=3796;<br>
> +--------+-------+----------+------------+<br>
> | chanid | title | recordid | recordedid |<br>
> +--------+-------+----------+------------+<br>
> | 120081 | test2 | 3796 | 8896 |<br>
> +--------+-------+----------+------------+<br>
> <br>
> [klaas@modu MythTVPython]$ ./mythtv-record.py delete --recordid 8896<br>
> RecordingId "8896" has been deleted.<br>
> <br>
> My understanding is that the entry in table record is created when the<br>
> recording is scheduled with the "mythtv-record.py add" command. This makes<br>
> it possible to return the recordid.<br>
> The entry in table recorded is created when the recording is started, which<br>
> is usually later in time, so the "myth-record.py add" command cannot know<br>
> this.<br>
> So it looks that what I need is the incantation to delete a recording by<br>
> recordid.<br>
> Or a sql query to get the recordedid but that is not really how the<br>
> ServicesAPI should work afaik.<br>
<br>
Hi Klaas,<br>
<br>
One option is to delete by ChanId and StartTime.<br>
<br>
My solution was to get the recordings, find a match for the RecordId<br>
and get the RecordedId from the result. Example:<br>
<br>
def delete_recording(backend, recordid, title, args, opts):<br>
''' Delete a single recording, lots of times '''<br>
<br>
try:<br>
resp_dict = backend.send(endpoint='Dvr/GetRecordedList',<br>
rest='TitleRegEx={}'.format(title),<br>
opts=opts)<br>
except RuntimeError as error:<br>
print('GetRecordedList Runtme Error: {}'.format(error))<br>
<br>
rec_count = int(resp_dict['ProgramList']['Count'])<br>
resp_dict = resp_dict['ProgramList']['Programs']<br>
recordedid = -1<br>
<br>
for index in range(rec_count):<br>
if resp_dict[index]['Recording']['RecordId'] == recordid:<br>
recordedid = resp_dict[index]['Recording']['RecordedId']<br>
break<br>
<br>
delete_one_rule(backend, recordid, opts)<br>
<br>
if recordedid == -1:<br>
print('No match for recordid {} in GetRecordedList'.format(recordid))<br>
return<br>
<br>
postdata = {<br>
'RecordedId': recordedid,<br>
'ForceDelete': 'True',<br>
'AllowRerecord': 'True'<br>
}<br>
<br>
# What follows was my attempt to do multiple deletes in vcr.py. You don't<br>
# need the loop, but it does do the delete by RecordedId. It also added<br>
# two new switches (in my own copy) you could hard code the values:<br>
<br>
for i in range(args.delete_attempts):<br>
<br>
try:<br>
resp_dict = backend.send(endpoint='Dvr/DeleteRecording',<br>
postdata=postdata, opts=opts)<br>
except RuntimeError as error:<br>
print('Delete Recording Runtme Error: {} on attempt {}'<br>
.format(error, i))<br>
else:<br>
if check_bool_response(resp_dict, 'Dvr/DeleteRecording'):<br>
print('Deleted RecordedId: {} returned true on attempt {}'<br>
.format(recordedid, i))<br>
else:<br>
print('Deleted RecordedId: {} returned false on attempt {}'<br>
.format(recordedid, i))<br>
time.sleep(args.delay_between_deletes)<br>
<br>
<br>
New switches, if you like:<br>
<br>
parser.add_argument('--delay_between_deletes', type=int, metavar='<n>',<br>
default=10,<br>
help='seconds between delete attempts (%(default)s)')<br>
<br>
parser.add_argument('--delete_attempts', type=int, default=100,<br>
metavar='<n>',<br>
help='attempts to delete recording (%(default)s)')<br>
<br>
-- <br>
Bill<br></blockquote>Hi Bill,<div><div><br></div><div>I got a hacked version of vcr.py now running in the way I want it.</div><div>What
I do now is to start the recording with second accuracy instead of
minute accuracy by effectively removing the code that forces the seconds
field to be zero.</div><div>This is only in the code that uses UTC time
when the specified time is in the past. So I do specify a time in the
past and that works OK.<br></div><div>I can now create a recording that
starts immediately instead of on the next minute and this then enables
waiting a number of seconds before deleting.<br></div><div>I also hard-coded the delays for the time being.</div><div>A bit strange is that the backend has not yet crashed with all this testing... but that is for another day.<br></div><br><div>Thanks!</div><div>Klaas.<br></div><font color="#888888"><div></div><div><br><br></div></font> </div></div></div>