[mythtv] SQL to determine if a specific encoder is recording

A McDermott list at mcdermotts.ca
Fri May 11 00:41:56 UTC 2012


On Thu, May 10, 2012 at 4:29 PM, David Engel <david at istwok.net> wrote:
> On Thu, May 10, 2012 at 03:54:57PM -0600, A McDermott wrote:
>> Looking for SQL (or pointers to appropriate join/tables) which will
>> allow me to determine if a particular encoder is busy.  I have found a
>> way to get the info of the current or next recordings, but not how to
>> cross-link with which particular encoder is or will be used for the
>> recording.
>
> That information isn't stored in the database, which you shouldn't be
> accessing directly anyway.  What you need to do is access the master
> backend using the Myth protocol.  The easiest way to do that is with
> the Python bindings.  See http://www.mythtv.org/wiki/0.25_Python_Bindings
> for more details.

I  understand the advice.  I have reviewed the python bindings and
don't see where the necessary information would come from to determine
the current and immediate next start time for only HDPVR encoders...
Am I missing something?

Essentially, I need to determine which input is a HDPVR and determine
if there is a current recording on the encoder, and when the next
recording is scheduled.  It would be easy if I only had 1 type of
encoder, but I don't, I also have a HDhomerun as well.

I've done some more digging on the SQL side, and must prefix the
following with a warning that I'm not a database programmer (no
laughing at the following SQL):

This query gives the number of seconds to the next recording on the
HDPVR input (which I only have one)

select unix_timestamp(starttime)-unix_timestamp(now()) from oldrecorded,
channel where sourceid in (select sourceid from cardinput where cardid in
(select cardid from capturecard where cardtype = 'HDPVR')) and
recstatus in (-1)
and oldrecorded.chanid = channel.chanid order by starttime asc limit 1;
+-------------------------------------------------+
| unix_timestamp(starttime)-unix_timestamp(now()) |
+-------------------------------------------------+
|                                            1586 |
+-------------------------------------------------+

And this one tells me if there is a recording currently running on the
backend on the HDPVR
mysql> select count(*) from oldrecorded, channel where sourceid in (select
sourceid from cardinput where cardid in (select cardid from capturecard
where cardtype = 'HDPVR')) and recstatus in (-2,-10) and oldrecorded.chanid =
channel.chanid order by starttime asc limit 1;
+----------+
| count(*) |
+----------+
|        1 |
+----------+
1 row in set (0.01 sec)


More information about the mythtv-dev mailing list