<div dir="ltr"><div>All the stuff in your example worked for me to. It was only when I got to the delete on the returned record that I ran into trouble.</div><div><br></div><div>While I'd like to understand what's going on, the services API may be an easier route to get things going, though it too seems pretty opaque. Thanks for the example.</div><div>Ross<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Feb 23, 2020 at 4:56 PM 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 2/23/20 6:15 PM, Ross Boylan wrote:<br>
> Running mythtv 30 with fixes + the python3 code from <a href="https://github.com/rcrdnalor/mythtv" rel="noreferrer" target="_blank">https://github.com/rcrdnalor/mythtv</a>, develop/python3. I gather that code has been merged <br>
> into Myth v31.<br>
> I have no idea if my problem is specific to these version, as I've made no serious use of the python interface before.<br>
> <br>
> I did a --user install of the libraries (and added that location to sys.path). It seems there are actually 2 interfaces, one based fairly <br>
> directly on the Services API and one in a more pythonic style. It's the latter I'm trying to use.<br>
> <br>
> db=MythTV.MythDB() # I can startup the frontend from this account, and I assume MythDB() gets info from my config<br>
> bb=db.searchRecorded(title="Blue Bloods")<br>
> a = next(bb)<br>
> # various queries of a<br>
> a.delete()<br>
> ---------------------------------------------------------------------------<br>
> MythDBError Traceback (most recent call last)<br>
> <ipython-input-42-adfa98f44cbd> in <module>()<br>
> ----> 1 a.delete()<br>
> <br>
> /home/ross/.local/lib/python3.7/site-packages/MythTV/dataheap.py in delete(self, force, rerecord)<br>
> 375 """<br>
> 376 try:<br>
> --> 377 return self.getProgram().delete(force, rerecord)<br>
> 378 except AttributeError:<br>
> 379 raise MythError("Program could not be found")<br>
> <br>
> /home/ross/.local/lib/python3.7/site-packages/MythTV/dataheap.py in getProgram(self)<br>
> 387 def getProgram(self):<br>
> 388 """Recorded.getProgram() -> Program object"""<br>
> --> 389 return Program.fromRecorded(self)<br>
> 390<br>
> 391 def getRecordedFile(self):<br>
> <br>
> /home/ross/.local/lib/python3.7/site-packages/MythTV/mythproto.py in fromRecorded(cls, rec)<br>
> 953 @classmethod<br>
> 954 def fromRecorded(cls, rec):<br>
> --> 955 be = FileOps(db=rec._db)<br>
> 956 return be.getRecording(rec.chanid, rec.starttime)<br>
> 957<br>
> <br>
> /home/ross/.local/lib/python3.7/site-packages/MythTV/mythproto.py in __init__(self, backend, blockshutdown, events, db)<br>
> 78 # no backend given, use master<br>
> 79 self.host = self.db.settings.NULL.MasterServerIP<br>
> ---> 80 self.hostname = self.db._gethostfromaddr(self.host)<br>
> 81<br>
> 82 else:<br>
> <br>
> /home/ross/.local/lib/python3.7/site-packages/MythTV/database.py in _gethostfromaddr(self, addr, value)<br>
> 1346 else:<br>
> 1347 raise MythDBError(MythError.DB_SETTING,<br>
> -> 1348 'BackendServerAddr', addr)<br>
> 1349<br>
> 1350 with self as cursor:<br>
> <br>
> MythDBError: Could not find setting 'BackendServerAddr' on host '192.168.1.10'<br>
> <br>
> Comments:<br>
> Maybe it is expecting a name, not an IP address? If so, how do I fix it?<br>
> OTOH, the method name is gethostfromaddr.<br>
> dig -x on the IP returns the fully qualified host name.<br>
> The database and myth backend are both on the same IP.<br>
<br>
Correct, the PR is in v31. There were more v3 commits made in the v31 cycle.<br>
I see ~46 commits total. There is no plan to support Python v3 in earlier<br>
MythTV versions.<br>
<br>
This works in v31:<br>
<br>
#!/usr/bin/python3<br>
import MythTV<br>
db=MythTV.MythDB()<br>
bb=db.searchRecorded(title="Blue Bloods")<br>
for a in bb:<br>
print(a.title, '\t', a.starttime)<br>
<br>
Blue Bloods 2020-01-03 21:00:00-06:00<br>
Blue Bloods 2020-01-31 21:00:00-06:00<br>
Blue Bloods 2019-10-04 21:00:00-05:00<br>
Blue Bloods 2020-02-14 21:00:00-06:00<br>
Blue Bloods 2020-01-10 21:00:00-06:00<br>
<br>
Or, you can use the python services_api module. It works with<br>
v2 or v3. <a href="https://www.mythtv.org/wiki/Python_API_Examples" rel="noreferrer" target="_blank">https://www.mythtv.org/wiki/Python_API_Examples</a><br>
<br>
#!/usr/bin/python2<br>
# -*- coding: utf-8 -*-<br>
<br>
'''<br>
Example: print_recordings.py <'optional recording title'><br>
'''<br>
<br>
from __future__ import print_function<br>
import sys<br>
from MythTV.services_api import send as api<br>
<br>
<br>
def main():<br>
"""Check host, get recorded programs and print"""<br>
<br>
try:<br>
host = sys.argv[1]<br>
except IndexError:<br>
host = 'localhost'<br>
<br>
backend = api.Send(host=host)<br>
<br>
try:<br>
resp_dict = backend.send(endpoint='Dvr/GetRecordedList')<br>
except RuntimeError as error:<br>
sys.exit('\nFatal error: "{}"'.format(error))<br>
<br>
count = int(resp_dict['ProgramList']['Count'])<br>
progs = resp_dict['ProgramList']['Programs']<br>
<br>
if count < 1:<br>
sys.exit('\nNo upcoming recordings found.\n')<br>
<br>
for upcoming in range(count):<br>
print(' {} {:45.45} {:15.15}'.format(<br>
progs[upcoming]['Recording']['StartTs'],<br>
progs[upcoming]['Title'],<br>
progs[upcoming]['SubTitle']))<br>
<br>
<br>
if __name__ == '__main__':<br>
main()<br>
<br>
# vim: set expandtab tabstop=4 shiftwidth=4 smartindent noai colorcolumn=80:<br>
<br>
-- <br>
Bill<br>
_______________________________________________<br>
mythtv-users mailing list<br>
<a href="mailto:mythtv-users@mythtv.org" target="_blank">mythtv-users@mythtv.org</a><br>
<a href="http://lists.mythtv.org/mailman/listinfo/mythtv-users" rel="noreferrer" target="_blank">http://lists.mythtv.org/mailman/listinfo/mythtv-users</a><br>
<a href="http://wiki.mythtv.org/Mailing_List_etiquette" rel="noreferrer" target="_blank">http://wiki.mythtv.org/Mailing_List_etiquette</a><br>
MythTV Forums: <a href="https://forum.mythtv.org" rel="noreferrer" target="_blank">https://forum.mythtv.org</a><br>
</blockquote></div>