[mythtv] Services API for ChannelServices / Video Source

Mike Bibbings mike.bibbings at gmail.com
Fri Nov 1 11:15:57 UTC 2019


On 31/10/2019 21:42, Klaas de Waal wrote:
> On Thu, 31 Oct 2019 at 15:07, Bill Meek <keemllib at gmail.com> wrote:
>> On 10/31/19 6:26 AM, Klaas de Waal wrote:
>>> Hi,
>>>
>>> I've recently added two parameters to the Video Source page of
>>> mythtv-setup, bouquet_id and region_id. These are used to get the
>>> channel numbers for Freesat and BSkyB on the Astra-2 28.2E satellite.
>>>
>>> I am now about to add these parameters to functions in
>>> channelservices.cpp/h such as AddVideoSource which are, as I
>>> understand it, part of what is called the Services API. This does
>>> compile cleanly but I am not aware of which other code or applications
>>> does actually use this.
>>>
>>> Are there applications I can test with or other steps I should take or
>>> shall I just commit this to master and wait what happens?
>>>
>>> Groetjes,
>>> Klaas.
>> Hi Klaas,
>>
>> If you'd like me to run some test, just let me know when you push.
>>
>> Otherwise, if it helps, I just added a parameter to an existing endpoint here:
>>
>>       git log --author Bill --patch -1
>>
>> 5 files changed:
>>
>>       libs/libmythservicecontracts/services/channelServices.h
>>       libs/libmythtv/channelutil.{cpp,h}
>>       programs/mythbackend/services/channel.{cpp,h}
>>
>> For testing, curl works OK. Sounds like the above adds/changes data,
>> which means a POST is required. Here's an old example of the format:
>>
>> curl \
>>       --data ChanID=1021 \
>>       ...
>>       --data XMLTVID=20454 \
>>       backendNameOrIP:6544/Channel/UpdateDBChannel
>>
>> Or, you can use the Python bindings for the Services API similar to this:
>>
>> #!/usr/bin/python
>> """Simple POST example"""
>>
>> from __future__ import print_function
>> import os.path
>> import sys
>> from MythTV.services_api import send as api
>>
>>
>> def main():
>>       """Check arguments and call send() with a POST"""
>>
>>       try:
>>           behost = sys.argv[1]
>>           dbhost = sys.argv[2]
>>           dbuser = sys.argv[3]
>>           dbpswd = sys.argv[4]
>>       except IndexError:
>>           sys.exit('\nUsage: {} backend_host db_host db_user db_password'
>>                    .format(os.path.basename(sys.argv[0])))
>>
>>       postdata = {'HostName': dbhost, 'UserName': dbuser, 'Password': dbpswd}
>>
>>       backend = api.Send(host=behost)
>>       backend.send(endpoint='Myth/TestDBSettings', postdata=postdata,
>>                    opts={'wrmi': True})
>>
>>
>> if __name__ == '__main__':
>>       main()
>>
>> --
>> Bill
>> _______________________________________________
> Hi Bill,
>
> I have committed support for the bouquet ID and the region ID in the
> services API  but not yet tested anything. I followed what was done
> for the dvb_nit_id and I think the C++ code is correct and complete. I
> made some changes to the Javascript code but I am not sure what else
> needs to be done there or what needs to be done in other non-C++ parts
> of the code. I do appreciate it very much if you would have a look at
> it.
>
> For the people who read this and feel tempted to play with this, the
> code does need the fields bouquet_id and region_id and one way to test
> it is to add these fields manually to database table videosource; SQL
> commands given in dbcheck.cpp. Changing the schema version to 1351 in
> mythversion.h does this and also activates the mythtv-setup gui for
> these fields but this should only be done on a discardable database.
>
>
> Groetjes,
> Klaas.
> _______________________________________________

Just for information.

I quickly tested current Kodi (Leia 18.4) with kodi-pvr-mythtv addon 
(5.10.13) with the updated database (1351) and Services API everything 
still works,

Normally with a Services API/schema change I would expect an update to 
MYTH_PROTO_VERSION (currently 91) and MYTH_PROTO_TOKEN (currently BuzzOff).

Updating these means a change to kodi-pvr-mythtv addon (it uses 
MYTH_PROTO_VERSION to decide how to process Services API calls).


Mike






More information about the mythtv-dev mailing list