Opened 17 months ago

Last modified 7 weeks ago

#13300 infoneeded_new Patch - Feature

Python Bindings enhancemts according to latest MythTV protocol (91)

Reported by: rcrdnalor Owned by: Raymond Wagner
Priority: minor Milestone: 31.0
Component: Bindings - Python Version: v29-fixes
Severity: medium Keywords:
Cc: Ticket locked: no


Mythtv v29: Python Bindings enhancements according to latest MythTV protocol:

1) Allow db.seacrchRecorded method to search by given recordedid:

Patch: 0001-Add-recordedid-to-db.seacrchRecorded-method.patch

This patch implements a search inside the recorded table by given recordedid by modifing the already implemented searchRecorded method.

2) Add the recordedfile table to python bindings and make use of it:

Patch: 0002-Python-Bindings-Add-recordedfile-table-and-its-usage.patch

This patch adds the recordedfile table to the python bindings and allows the Recorded instance to use (and update) it.

These patches are compatible with current master and fixes/v29. Once accepted, please backport to fixes/v29.

Example usage:

$ python2
Python 2.7.15rc1 (default, Apr 15 2018, 21:51:34) 
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from MythTV import MythDB, MythError, MythDBError, Recorded, RecordedFile
>>> db = MythDB()
>>> reciter = db.searchRecorded(recordedid = 44)
>>> rec =
>>> rec
b'<Recorded 'Servatius Wetter','2018-06-30 11:10:00+02:00' at 0x7efe3fc482a0>'
>>> recfile = rec.getRecordedFile()
>>> recfile
b'<RecordedFile '2105_20180630091000.ts','44' at 0x7efe3fc554f0>'
>>> recfile.keys()
[u'basename', u'filesize', u'width', u'height', u'fps', u'aspect', u'audio_sample_rate', u'audio_channels', u'audio_codec', u'video_codec', u'comment', u'hostname', u'storagegroup', u'id', u'recordedid', u'container', u'total_bitrate', u'video_avg_bitrate', u'video_max_bitrate', u'audio_avg_bitrate', u'audio_max_bitrate']
>>> recfile.values()
[u'2105_20180630091000.ts', 563401220L, 1920, 1088, 25.0, 1.777778, 0, 0, u'AC3', u'H264', u'', u'bionic', u'Default', 51L, 44L, u'MPEG2-TS', 0, 0, 0, 0, 0]

Attachments (2)

0001-Add-recordedid-to-db.seacrchRecorded-method.patch (2.1 KB) - added by rcrdnalor 17 months ago.
Add recordedid to Python Bindings
0002-Python-Bindings-Add-recordedfile-table-and-its-usage.patch (3.6 KB) - added by rcrdnalor 17 months ago.
Add recordedfile to Python Bindings

Download all attachments as: .zip

Change History (8)

Changed 17 months ago by rcrdnalor

Add recordedid to Python Bindings

Changed 17 months ago by rcrdnalor

Add recordedfile to Python Bindings

comment:1 Changed 17 months ago by ijc

FWIW (I'm not a maintainer) these like sane to me.

Was the omission of basename and id from the RecordedId._defaults table deliberate?

comment:2 Changed 16 months ago by rcrdnalor

@ijc Thank you for reviewing my patches.

I am not sure if I understood your question correctly. If you meant theRecordedfile._defaults object, then the answer is yes. If you look into the mysql description of the recordedfile table (mysql describe recrodedfile), the fields id and basename are key-fields: id is autoincrement, it will be handled by mysql itself, and basename has a key as well, that means, the user needs to provide a valid value. Therefore, no default values are foreseen for those fields.

Could you please review #13299 as well? This is a tricky one and hard to decribe.

Thx, dnalor

comment:3 Changed 16 months ago by ijc

Thanks for the explanation, I did mean Recordedfile._defaults and had missed that basename was also a key field.

Will see if I can understand #13299 next...

comment:4 Changed 3 months ago by Bill Meek

Milestone: needs_triage31.0
Status: newinfoneeded_new

Roland, are any changes required for Python 3? E.g. in the 2nd patch here: 'comment':u'', 'hostname':'', 'storagegroup':''

comment:5 Changed 3 months ago by rcrdnalor

I will add testcases to my repo and include the patches in pull request 182 as a single commit.

This means, one can easily revert it, if necessary.

comment:6 Changed 7 weeks ago by rcrdnalor

With the last change on pull request 182, the search with given 'recordedid' in 'searchRecorded' and the access to the 'recordedFile' table works for python3 as well as for python2

$ python
Python 3.6.8 (default, Aug 20 2019, 17:12:48)
>>> from MythTV import MythDB
>>> db = MythDB()
>>> reciter = db.searchRecorded(recordedid = 4762)
>>> rec = next(reciter)
>>> rec
<Recorded 'The Lady from Shanghai','2019-03-05 13:51:00+01:00' at ..>
>>> recfile = rec.getRecordedFile()
>>> recfile
<RecordedFile '3030_20190305125100.mkv','4762' at 0x7fb32d108ca8>
>>> recfile.items()
[('basename', '3030_20190305125100.mkv'), ('filesize', 2793354377),
('width', 992), ('height', 720), ('fps', 25.0), ('aspect', 1.377778),
 ........   )]
>>> exit()

Please give it a try.

Note: See TracTickets for help on using tickets.