Mailing List Archive

How can I query database for the details of the program currently playing on a channel?
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?
Re: How can I query database for the details of the program currently playing on a channel? [ In reply to ]
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
Re: How can I query database for the details of the program currently playing on a channel? [ In reply to ]
-----Original message-----
From: Bill Meek <keemllib@gmail.com>
Sent: Monday 1st May 2023 19:00
To: Discussion about MythTV <mythtv-users@mythtv.org>; Lists <lists@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



Thanks Bill,



The endpoint is a good possibility, but unfortunately I need this for the Backend, since it's for setting up recordings, rather than watching live tv on a frontend.

I've taken a closer look at the API and GetProgramDetails looked like a possibility, but it requires the Program Start time, which is the information I'm actually trying to find to feed into my SQL search above.

What I need is the start time of the current program on channel number xxx.



Regards,

Dave.
Re: How can I query database for the details of the program currently playing on a channel? [ In reply to ]
On Monday 01 May 2023 03:00:41 PM (-05:00), Lists wrote:









-----Original message-----
From: Bill Meek <keemllib@gmail.com>
Sent: Monday 1st May 2023 19:00
To: Discussion about MythTV <mythtv-users@mythtv.org>; Lists
<lists@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
Re: How can I query database for the details of the program currently playing on a channel? [ In reply to ]
-----Original message-----
From: Bill Meek <keemllib@gmail.com>
Sent: Monday 1st May 2023 21:09
To: Lists <lists@the-pearsons.co.uk>; Discussion about MythTV <mythtv-users@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@gmail.com>
Sent: Monday 1st May 2023 19:00
To: Discussion about MythTV <mythtv-users@mythtv.org>; Lists <lists@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.
Re: How can I query database for the details of the program currently playing on a channel? [ In reply to ]
Hoi Lists,

Monday, May 1, 2023, 7:30:27 PM, you 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?
>

See here a Python module: https://drive.google.com/file/d/1PNFXNDc8hIBTbXVEO8TR_CXwTrm13aeY/view?usp=share_link

It is part of my project to manage up-time of my network. It has a
python Class MythData(name, log, **kwargs)

name is just for identification

log should be a function to process logging that accepts a message and
a loglevel

as further qualified argument it expects "address" as a tuple of
ip-address or dns name and port to access the backend. It defaults to
('LocalHost', 6544)

The class contains functions to retrieve the list of upcoming
recordings, in-progress recordings, and idle gaps. Look for yourself.

There is a remarked out function to send the output to screen or file
for analysis. It converts json text dates and times to python datetime
values. If you still have an older python version, I think pre 3.6 you
will still need pytz for proper timezone handling.


Tot mails,
Hika mailto:hikavdh@gmail.com

"Zonder hoop kun je niet leven
Zonder leven is er geen hoop
Het eeuwige dilemma
Zeker als je hoop moet vernietigen om te kunnen overleven!"

De lerende Mens

_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: How can I query database for the details of the program currently playing on a channel? [ In reply to ]
-----Original message-----
From: Lists <lists@the-pearsons.co.uk>
Sent: Monday 1st May 2023 21:34
To: Discussion about MythTV <mythtv-users@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@gmail.com>
Sent: Monday 1st May 2023 21:09
To: Lists <lists@the-pearsons.co.uk>; Discussion about MythTV <mythtv-users@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@gmail.com>
Sent: Monday 1st May 2023 19:00
To: Discussion about MythTV <mythtv-users@mythtv.org>; Lists <lists@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.
Re: How can I query database for the details of the program currently playing on a channel? [ In reply to ]
On Tuesday 02 May 2023 03:28:28 PM (-05:00), Lists wrote:
<snip>

From your original request, I'd assumed you wanted info on a program that
was currently
recording.


Also without the Rating, there's this to access the program guide (for
example)

curl --silent --header 'Accept:Application/JSON'
localhost:6544/Guide/GetProgramGuide?Starttime=2023-05-02T00:00\&Endtime=2023-05-02T00:59

Times are in UTC.


You can also look at it in your browser if you don't have json_pp or
something like it:



http://yourBackend:6544/Guide/GetProgramGuide?Starttime=2023-05-02T00:00&Endtime=2023-05-02T00:59



See: https://www.mythtv.org/wiki/Services_API for a little more API detail.

--
Bill
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org