<div dir="ltr"><div dir="ltr"><div dir="ltr">On Fri, Oct 12, 2018 at 7:56 PM David Engel <<a href="mailto:david@istwok.net">david@istwok.net</a>> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Fri, Oct 12, 2018 at 06:49:44PM -0600, John P Poet wrote:<br>
> I see AddRecordSchedule here<br>
> <a href="https://www.mythtv.org/wiki/API_parameters_29#Dvr_service" rel="noreferrer" target="_blank">https://www.mythtv.org/wiki/API_parameters_29#Dvr_service</a> but when I try to<br>
> use it, I am getting a 500 response.  Is this not working, or am I not<br>
> calling it correctly?<br>
<br>
It worked at some time.  It's possible it got broken somewhere along<br>
the line.<br>
<br>
> I am calling it from python:<br>
> <br>
>     endpoint = 'Dvr/AddRecordSchedule'<br>
>     post = recrule.asDict()<br>
>     opt = {'wrmi':True}<br>
> <br>
>     try:<br>
>         resp_dict = backend.send(endpoint=endpoint, postdata=post, opts=opt)<br>
>     except RuntimeError as error:<br>
>         sys.exit('\nFatal error: "{}"'.format(error))<br>
>     except RuntimeWarning as warning:<br>
>         print('Warning: {}'.format(warning))<br>
> <br>
> recrule is a classed derived from a named tuple with the various arguments<br>
> in it, for example: ChanId, Title, Subtitle, etc.<br>
<br>
How are you creating recrule?  The strongly preferred way to do so is<br>
to call Dvr/GetRecordSchedule first.  That will give you a known, good<br>
rule from which you can modify as needed.<br></blockquote><div><br></div><div>recrule is basically a named tuple, with default values for the arguments:</div><div><br></div><div><span style="font-family:monospace,monospace">from typing import Any, NamedTuple</span></div><div><span style="font-family:monospace,monospace"></span><br></div><div>c<span style="font-family:monospace,monospace">lass RecRule(NamedTuple):<br>    ChanId: int<br>    Title: str<br>    Subtitle: str<br>    AutoCommflag: 'RecRule' = 0<br>    AutoExpire: 'RecRule' = 0<br>    AutoMetaLookup: 'RecRule' = 0<br>    AutoTranscode: 'RecRule' = 0<br>    AutoUserJob1: 'RecRule' = 0<br>    AutoUserJob2: 'RecRule' = 0<br>    AutoUserJob3: 'RecRule' = 0<br>    AutoUserJob4: 'RecRule' = 0<br>    Category: 'RecRule' = ''<br>    Description: 'RecRule' = ''<br>    DupIn: 'RecRule' = 15<br>    DupMethod: 'RecRule' = 6<br>    EndOffset: 'RecRule' = 0<br>    EndTime: 'RecRule' = 0<br>    Episode: 'RecRule' = 0<br>    Filter: 'RecRule' = 0<br>    FindDay: 'RecRule' = 0<br>    FindTime: 'RecRule' = '00:00:00'<br>    Inactive: 'RecRule' = 0<br>    Inetref: 'RecRule' = ''<br>    MaxEpisodes: 'RecRule' = 0<br>    MaxNewest: 'RecRule' = 0<br>    ParentId: 'RecRule' = 0<br>    PlayGroup: 'RecRule' = 'Default'<br>    PreferredInput: 'RecRule' = 0<br>    ProgramId: 'RecRule' = ''<br>    RecGroup: 'RecRule' = 'Default'<br>    RecPriority: 'RecRule' = 0<br>    RecProfile: 'RecRule' = 'Default'<br>    SearchType: 'RecRule' = ''<br>    Season: 'RecRule' = 0<br>    SeriesId: 'RecRule' = ''<br>    StartOffset: 'RecRule' = 0<br>    StartTime: 'RecRule' = 0<br>    Station: 'RecRule' = ''<br>    StorageGroup: 'RecRule' = 'Default'<br>    Transcoder: 'RecRule' = 0<br>    Type: 'RecRule' = 0        <br><br>    def asString(self):<br>        result = ''<br>        for attr in dir(self):<br>            if (not callable(getattr(self,attr)) and not attr.startswith("_")):<br>                if result:<br>                    result += '&'<br>                result += attr + '=' + str(getattr(self, attr))<br>        return result<br><br>    def asDict(self):<br>        result = {}<br>        for attr in dir(self):<br>            if (not callable(getattr(self,attr)) and not attr.startswith("_")):<br>                result[attr] = str(getattr(self, attr))<br>        return result</span><br><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
There are 4 ways to call Dvr/GetRecordSchedule:<br>
<br>
nRecordId > 0 : Return the existing recording rule itself.  Not<br>
necessarily tied to a specific program.<br>
<br>
!sTemplate.isEmpty() : Return the existing, template rule itself.<br>
<br>
nRecordedId > 0 : Return the rule for the given recording.<br>
<br>
nChanId > 0 && dStartTime.isValid() : Return the matching rule for the<br>
given program.  Optionally, return an override rule when bMakeOverride<br>
is set.<br></blockquote><div><br></div><div>Good to know.  I had not thought of retrieving a template first.  That seems like a good approach.</div><div><br></div><div>Has anyone written a set of python tools for controlling Myth with the services API, that has been published somewhere?  The documentation is currently somewhat sparse, and examples might be helpful.</div><div><br></div><div>Thanks,</div><div><br></div><div>John<br></div></div></div></div></div>