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

David Engel david at istwok.net
Fri May 11 01:57:42 UTC 2012


On Thu, May 10, 2012 at 06:41:56PM -0600, A McDermott wrote:
> 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?

Raymond Wagner can probably help you much better than me.  He wrote
and maintains the Python bindings.  That being said, I can offer a
little more help.

I don't know if the bindings provide a way to find out which recorder
is an HD-PVR.  I know the web service interface does, but that
requires different access.  Anyway, the recorder card and input
numbers don't change unless you modify them in mythtv-setup, so you
could always just hard code tham

After you have the card (aka recorder) number, the rest should be very
easy.  The call to find it what a given recorder is or isn't recording
right now is getCurrentRecording(self recorder).  The call to get the
full list of programs that are recording now or are scheduled to record
in the future is getPendingRecordings(self, pg).

David

> 
> 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)
> _______________________________________________
> mythtv-dev mailing list
> mythtv-dev at mythtv.org
> http://www.mythtv.org/mailman/listinfo/mythtv-dev
> 

-- 
David Engel
david at istwok.net


More information about the mythtv-dev mailing list