[mythtv-users] How can I query database for the details of the program currently playing on a channel?

Lists lists at the-pearsons.co.uk
Tue May 2 20:28:28 UTC 2023


-----Original message-----
From: Lists <lists at the-pearsons.co.uk>
Sent: Monday 1st May 2023 21:34
To: Discussion about MythTV <mythtv-users at mythtv.org>
Subject: Re: [mythtv-users] How can I query database for the details of the program currently playing on a channel?





-----Original message-----
From: Bill Meek <keemllib at gmail.com>
Sent: Monday 1st May 2023 21:09
To: Lists <lists at the-pearsons.co.uk>; Discussion about MythTV <mythtv-users at mythtv.org>
Subject: RE: [mythtv-users] How can I query database for the details of the program currently playing on a channel?

On Monday 01 May 2023 03:00:41 PM (-05:00), Lists wrote:





-----Original message-----
From: Bill Meek <keemllib at gmail.com>
Sent: Monday 1st May 2023 19:00
To: Discussion about MythTV <mythtv-users at mythtv.org>; Lists <lists at the-pearsons.co.uk>
Subject: Re: [mythtv-users] How can I query database for the details of the program currently playing on a channel?

On Monday 01 May 2023 12:30:27 PM (-05:00), Lists wrote:

Hi all,



I'm looking for some guidance so that when I use my channel change script to select a channel, I can also query the database to find out what is showing on that channel and what time it started - I need my. script to get the rating from the programratings table, which only has chanid and starttime to search on.



so my query would be something like



select rating from programrating where programrating.system like "%British%" and starttime like (select starttime from "currently showing program query") and chanid like 

(select chanid from channel where channum = "402" and sourceid = 2);



Any helpful suggestions?






The Services API has an endpoint you may like:

  curl --silent --header 'Accept:Application/JSON' localhost:6547/Frontend/GetStatus|

You can pipe the output to json_pp if you want something nice to look at. Otherwise,
the output is on a single line. If you omit the --header, the output will be in XML if
you prefer. 

There are Python tools that can help. See: https://www.mythtv.org/wiki/Python_API_Examples#The_Myth.2FGetTimeZone_endpoint_example
for an example. Then you can filter out just the info you want.

-- 
Bill

curl --silent --header 'Accept:Application/JSON' localhost:6544/Dvr/GetEncoderList | json_pp

Thanks Bill,



that looks as though it could give me enough information to create my query - it may even give me the Movie age rating, if I set up a movie to record (unfortunately my tuners are all busy at the moment, so I'll check that later) - there's a lot more information given than I expected when I saw that DVR option in the list.



Regards,

Dave.

Hi Bill,



Well, it doesn't give me the rating, but it does give me the ProgramId, couple that with the current date and that gives me enough to query the database for the starttime of the program, which, when I add that to the chanid gives me enough info to get the rating from the programrating table.



Thanks for the advice, I couldn't have done this without you - this will reduce the chances of my script doing things when it doesn't need to, which would mess up my recordings.



All I need to do now is actually write the script :-) 





Thanks also to Hika van den Hoven for his suggestion.



Regards,

Dave.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mythtv.org/pipermail/mythtv-users/attachments/20230502/f6684a29/attachment.htm>


More information about the mythtv-users mailing list