<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html>
<head>
  <meta name="Generator" content="Kopano WebApp v-5.0.0.223+1986.1">
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <title>RE: [mythtv-users] How can I query database for the details of the program currently playing on a channel?</title>
</head>
<body>
<blockquote style="border-left: 2px solid #325fba; padding-left: 5px; margin: 0px 5px 1em;"><span style="font-family: tahoma,arial,helvetica,sans-serif; font-size: 10pt;">-----Original message-----<br /><span><strong>From:</strong> Lists <lists@the-pearsons.co.uk></span><br /><span><strong>Sent:</strong> Monday 1st May 2023 21:34</span><br /><span><strong>To:</strong> Discussion about MythTV <mythtv-users@mythtv.org></span><br /><span><strong>Subject:</strong> Re: [mythtv-users] How can I query database for the details of the program currently playing on a channel?</span><br /><br /></span>
<p style="padding: 0; margin: 0; min-height: 11pt; font-family: arial,helvetica,sans-serif; font-size: 11pt;"><br /></p>
<p style="padding: 0; margin: 0; min-height: 11pt; font-family: arial,helvetica,sans-serif; font-size: 11pt;"><br /></p>
<blockquote style="border-left: 2px solid #325fba; padding-left: 5px; margin: 0px 5px 1em;"><span style="font-family: tahoma,arial,helvetica,sans-serif; font-size: 10pt;">-----Original message-----<br /><span><strong>From:</strong> Bill Meek <keemllib@gmail.com></span><br /><span><strong>Sent:</strong> Monday 1st May 2023 21:09</span><br /><span><strong>To:</strong> Lists <lists@the-pearsons.co.uk>; Discussion about MythTV <mythtv-users@mythtv.org></span><br /><span><strong>Subject:</strong> RE: [mythtv-users] How can I query database for the details of the program currently playing on a channel?</span><br /><br /></span>On Monday 01 May 2023 03:00:41 PM (-05:00), Lists wrote:<br /><br />
<blockquote style="margin: 0 0 0.80ex; border-left: #0000FF 2px solid; padding-left: 1ex;">
<p style="font-size: 11pt; font-family: arial, helvetica, sans-serif; min-height: 11pt; padding: 0px; margin: 0px;"><br /></p>
<p style="font-size: 11pt; font-family: arial, helvetica, sans-serif; min-height: 11pt; padding: 0px; margin: 0px;"><br /></p>
<blockquote style="padding-left: 5px; border-left-color: #325fba; border-left-style: solid; border-left-width: 2px; margin: 0px 5px 1em 5px;"><span style="font-size: 10pt; font-family: tahoma, arial, helvetica, sans-serif;">-----Original message-----<br /><span><strong>From:</strong> Bill Meek <keemllib@gmail.com></span><br /><span><strong>Sent:</strong> Monday 1st May 2023 19:00</span><br /><span><strong>To:</strong> Discussion about MythTV <mythtv-users@mythtv.org>; Lists <lists@the-pearsons.co.uk></span><br /><span><strong>Subject:</strong> Re: [mythtv-users] How can I query database for the details of the program currently playing on a channel?</span><br /><br /></span>On Monday 01 May 2023 12:30:27 PM (-05:00), Lists wrote:<br /><br />
<blockquote style="padding-left: 1ex; border-left-color: #0000ff; border-left-style: solid; border-left-width: 2px; margin: 0px 0px 0.8ex 0px;">
<p style="padding: 0px; margin: 0px;"><span style="font-size: 11pt; font-family: arial, helvetica, sans-serif;">Hi all,<br /></span></p>
<p style="padding: 0px; margin: 0px;"><span style="font-size: 11pt; font-family: arial, helvetica, sans-serif;"><br /></span></p>
<p style="padding: 0px; margin: 0px;"><span style="font-size: 11pt; font-family: arial, helvetica, sans-serif;">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.</span></p>
<p style="padding: 0px; margin: 0px;"><span style="font-size: 11pt; font-family: arial, helvetica, sans-serif;"><br /></span></p>
<p style="padding: 0px; margin: 0px;"><span style="font-size: 11pt; font-family: arial, helvetica, sans-serif;">so my query would be something like</span></p>
<p style="padding: 0px; margin: 0px;"><span style="font-size: 11pt; font-family: arial, helvetica, sans-serif;"><br /></span></p>
<p style="padding: 0px; margin: 0px;"><span style="font-size: 11pt; font-family: arial, helvetica, sans-serif;">select rating from programrating where programrating.system like "%British%" and starttime like (select starttime from "currently showing program query") and chanid like </span></p>
<p class="p1" style="font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-kerning: auto; font-optical-sizing: auto; font-feature-settings: normal; font-variation-settings: normal; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; margin: 0px;"><span class="s1" style="font-variant-ligatures: no-common-ligatures;">(select chanid from channel where channum = "402" and sourceid = 2);</span></p>
<p class="p1" style="font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-kerning: auto; font-optical-sizing: auto; font-feature-settings: normal; font-variation-settings: normal; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; margin: 0px;"><span class="s1" style="font-variant-ligatures: no-common-ligatures;"><br /></span></p>
<p class="p1" style="font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-kerning: auto; font-optical-sizing: auto; font-feature-settings: normal; font-variation-settings: normal; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; margin: 0px;"><span class="s1" style="font-variant-ligatures: no-common-ligatures;">Any helpful suggestions?</span></p>
<p class="p1" style="font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-kerning: auto; font-optical-sizing: auto; font-feature-settings: normal; font-variation-settings: normal; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; margin: 0px;"><span class="s1" style="font-variant-ligatures: no-common-ligatures;"><br /></span></p>
<p class="p1" style="font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-kerning: auto; font-optical-sizing: auto; font-feature-settings: normal; font-variation-settings: normal; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; margin: 0px;"><span class="s1" style="font-variant-ligatures: no-common-ligatures;"><br /></span></p>
</blockquote>
<div><span class="viv-signature-below"><br /></span></div>
<div><span class="viv-signature-below">The Services API has an endpoint you may like:</span></div>
<div><span class="viv-signature-below"><br /></span></div>
<div><span class="viv-signature-below">  curl --silent --header 'Accept:Application/JSON' localhost:6547/Frontend/GetStatus|</span></div>
<div><span class="viv-signature-below"><br /></span></div>
<div><span class="viv-signature-below">You can pipe the output to json_pp if you want something nice to look at. Otherwise,</span></div>
<div><span class="viv-signature-below">the output is on a single line. If you omit the --header, the output will be in XML if</span></div>
<div><span class="viv-signature-below">you prefer. </span></div>
<div><span class="viv-signature-below"><br /></span></div>
<div><span class="viv-signature-below">There are Python tools that can help. See: https://www.mythtv.org/wiki/Python_API_Examples#The_Myth.2FGetTimeZone_endpoint_example</span></div>
<div><span class="viv-signature-below">for an example. Then you can filter out just the info you want.</span></div>
</blockquote>
<span class="viv-signature-below"><br />-- <br />Bill</span></blockquote>
<br />
<div><br /></div>
<div>curl --silent --header 'Accept:Application/JSON' localhost:6544/Dvr/GetEncoderList | json_pp</div>
<div><br /></div>
</blockquote>
<p style="padding: 0; margin: 0;">Thanks Bill,</p>
<p style="padding: 0; margin: 0;"><br /></p>
<p style="padding: 0; margin: 0;">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.</p>
<p style="padding: 0; margin: 0;"><span style="font-size: 11pt; font-family: arial, helvetica, sans-serif;"><br /></span></p>
<p style="padding: 0; margin: 0;"><span style="font-size: 11pt; font-family: arial, helvetica, sans-serif;">Regards,</span></p>
<p style="padding: 0; margin: 0;"><span style="font-size: 11pt; font-family: arial, helvetica, sans-serif;">Dave.</span></p>
</blockquote>
<p style="padding: 0; margin: 0; ">Hi Bill,</p>
<p style="padding: 0; margin: 0; "><span style="font-size: 11pt; font-family: arial, helvetica, sans-serif;"><br /></span></p>
<p style="padding: 0; margin: 0; "><span style="font-size: 11pt; font-family: arial, helvetica, sans-serif;">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.<br /></span></p>
<p style="padding: 0; margin: 0; "><span style="font-size: 11pt; font-family: arial, helvetica, sans-serif;"><br /></span></p>
<p style="padding: 0; margin: 0; "><span style="font-size: 11pt; font-family: arial, helvetica, sans-serif;">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.</span></p>
<p style="padding: 0; margin: 0; "><span style="font-size: 11pt; font-family: arial, helvetica, sans-serif;"><br /></span></p>
<p style="padding: 0; margin: 0; "><span style="font-size: 11pt; font-family: arial, helvetica, sans-serif;">All I need to do now is actually write the script :-) </span></p>
<p style="padding: 0; margin: 0; "><span style="font-size: 11pt; font-family: arial, helvetica, sans-serif;"><br /></span></p>
<p style="padding: 0; margin: 0; "><span style="font-size: 11pt; font-family: arial, helvetica, sans-serif;"><br /></span></p>
<p style="padding: 0; margin: 0; "><span style="font-size: 11pt; font-family: arial, helvetica, sans-serif;">Thanks also to Hika van den Hoven for his suggestion.</span></p>
<p style="padding: 0; margin: 0; "><span style="font-size: 11pt; font-family: arial, helvetica, sans-serif;"><br /></span></p>
<p style="padding: 0; margin: 0; "><span style="font-size: 11pt; font-family: arial, helvetica, sans-serif;">Regards,</span></p>
<p style="padding: 0; margin: 0; "><span style="font-size: 11pt; font-family: arial, helvetica, sans-serif;">Dave.</span></p>
</body>
</html>