-
Notifications
You must be signed in to change notification settings - Fork 346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide User Interface to the MythTV's Services #198
Open
rcrdnalor
wants to merge
4
commits into
MythTV:master
Choose a base branch
from
rcrdnalor:devel/mythservices
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
See ticket #13620 for the basic information and for a simple tutorial. |
stuarta
added
component:bindings:python
Python Bindings
component:mythtv:api
Services API issues
labels
Sep 1, 2020
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: - service: the service category one is asking for (e.g.: 'Dvr') optype = 'POST' # or 'GET' - opdata: a dictionary describing the data needed to perform the operation. Or 'MythTVService' is used sequentially by calling: - getoperation - strip_operation_defaults - encode_operation - perform_operation 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.
The xml data retrieved from the host by the Services-API are of different types: - a simple response containing only values or list of values, like the response to 'GetHostName' or 'GetHosts'. Simple responses get evaluated and are returned directly, because their element-tags are not defined in the wsdl. - a complex response containing a xml namespace and a version, like the response to 'ChannelInfo' or 'ChannelInfoList'. Complex responses will be objectified within the class itself. The result of an operation is now stored in 'MythTVService.operation_result', too.
Elements of type 'ArrayOf' occur in two flowers: - Either defined with types of the "xs" namespace like "ArrayOfString" - Or defined with types of the the "tns" namespace like "ArrayOfProgram". This fixes parsing of list-elements of the basic namespace 'xs'.
Timeout can now be set globally for a 'MythTVService' session or can be set for each operation. Especially uUseful when retrieving metadata.
rcrdnalor
force-pushed
the
devel/mythservices
branch
from
March 2, 2022 20:30
ca2db07
to
c7e7847
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
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