Provide User Interface to the MythTV's Services #198
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
See https://www.mythtv.org/wiki/Services_API .
The class 'MythTVService' can be used in two ways:
Either to be called directly with all parameters to perform an
operation:
Each operation consists of a call to - and a reception of - the
selected MythTVService.
A direct call uses at least the following parameters:
optype = 'POST' # or 'GET'
operation.
Or 'MythTVService' is used sequentially by calling:
An instance of the 'MythTVService' class can be reused to perform
multiple operations of the same service type.
Example:
ms = MythTVService('Channel', host)
op = ms.getoperation('GetChannelInfoList')
op['opdata']['SourceID'] = 1
op['opdata']['Details'] = True
op_stripped = ms.strip_operation_defaults('GetChannelInfoList', op)
op_encoded = ms.encode_operation(op_stripped)
if ms.perform_operation(op_encoded):
# 'ms' is now an object of type 'GetChannelInfoList'
print(ms.channelinfos[0].chanid)
Notes about naming convention:
The MythTV Python Bindings use lower-case names for their attributes.
The MythTV-Services API use 'CamelCase' notation for the data needed
by 'POST' and returned by 'GET' operations.
During processing of these data, they are converted to lower-case:
Please note, that Python's PEP-08 dislikes 'CamelCase' notation for
naming attributes of a class.
Since every call to 'MythTVService' returns an instance derived from
the base-class 'DictData', one can access these data by either using
av'dictionary-like notation', or using the 'key as attribute'.
TL;DR: Attributes are lower-case names and the following notations
belong to the same object:
- ms.channelinfo.chanid
- ms.channelinfo['chanid']
- ms['channelinfo']['chanid']
A list of operations of the selcted service can be retrieved by
calling 'ms.list_operations()'.
A list of available attributes of an already performed operation
is returned by calling 'ms.list_attributes()'.
Notes about logging:
This module uses the internal logging mechanism from 'logging.py'.
To enable all debug logging to console, start the python script with
$ python3 your_script.py --loglevel debug --verbose all .
For the interactive python shell, replace the scriptname with a
dash ("-").
See 'MythTV/services_api/send.py' for logging of the services_api.
Thank you for contributing to MythTV.
As many of our developers do not visit GitHub it is important to track
all contributions at our central ticket tracker over at code.mythtv.org
To prevent your contributions being overlooked please create a new ticket
there and refer to this pull request. (Bonus points for linking to the
ticket in the pull request, too. It helps us noticed potentially overlooked
pull requests due to missing tickets.)
https://code.mythtv.org/trac/wiki/TicketHowTo
https://code.mythtv.org/trac/newticket