Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: MythTV: Dev

SQL to determine if a specific encoder is recording

 

 

MythTV dev RSS feed   Index | Next | Previous | View Threaded


list at mcdermotts

May 10, 2012, 2:54 PM

Post #1 of 6 (474 views)
Permalink
SQL to determine if a specific encoder is recording

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.

The endgame here is to once a day determine if my HDPVR is in use, or
will be in use in the near future. If the HDPVR encoder is not in
use, I will reset it to try and avoid annoying HDPVR hangs.

Here is what I use to find the current recording program and the next
scheduled recording.

Current recording (-2) or tuning (-10):

mysql> select starttime from oldrecorded where recstatus in (-2,-10);
+---------------------+
| starttime |
+---------------------+
| 2012-05-10 15:00:00 |
| 2012-05-10 15:00:00 |
+---------------------+
2 rows in set (0.00 sec)


Next scheduled recording:

mysql> select starttime from oldrecorded where recstatus in (-1) and
starttime > NOW() order by starttime asc limit 2;
+---------------------+
| starttime |
+---------------------+
| 2012-05-10 16:00:00 |
| 2012-05-10 17:00:00 |
+---------------------+
2 rows in set (0.00 sec)
_______________________________________________
mythtv-dev mailing list
mythtv-dev [at] mythtv
http://www.mythtv.org/mailman/listinfo/mythtv-dev


david at istwok

May 10, 2012, 3:29 PM

Post #2 of 6 (458 views)
Permalink
Re: SQL to determine if a specific encoder is recording [In reply to]

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.

> The endgame here is to once a day determine if my HDPVR is in use, or
> will be in use in the near future. If the HDPVR encoder is not in
> use, I will reset it to try and avoid annoying HDPVR hangs.
>
> Here is what I use to find the current recording program and the next
> scheduled recording.
>
> Current recording (-2) or tuning (-10):
>
> mysql> select starttime from oldrecorded where recstatus in (-2,-10);
> +---------------------+
> | starttime |
> +---------------------+
> | 2012-05-10 15:00:00 |
> | 2012-05-10 15:00:00 |
> +---------------------+
> 2 rows in set (0.00 sec)
>
>
> Next scheduled recording:
>
> mysql> select starttime from oldrecorded where recstatus in (-1) and
> starttime > NOW() order by starttime asc limit 2;
> +---------------------+
> | starttime |
> +---------------------+
> | 2012-05-10 16:00:00 |
> | 2012-05-10 17:00:00 |
> +---------------------+
> 2 rows in set (0.00 sec)

Again, you shouldn't be accessing the database directly. There's all
sorts of details and subtleties about the schema of which you probably
aren't aware. Like above, the Python bindings can handle this quite
nicely for you.

David
--
David Engel
david [at] istwok
_______________________________________________
mythtv-dev mailing list
mythtv-dev [at] mythtv
http://www.mythtv.org/mailman/listinfo/mythtv-dev


gary.buhrmaster at gmail

May 10, 2012, 3:31 PM

Post #3 of 6 (466 views)
Permalink
Re: SQL to determine if a specific encoder is recording [In reply to]

On Thu, May 10, 2012 at 9:54 PM, A McDermott <list [at] mcdermotts> wrote:
> Looking for SQL (or pointers to appropriate join/tables) which will
> allow me to determine if a particular encoder is busy.

I would consider using the MythTV bindings rather than
direct SQL access.

My (vague) recollection is (at least) the python bindings
allow you to determine if a tuner is currently in use
(isRecording), and you can get the list of scheduled
recordings (getScheduledRecordings).

Last I looked, the bindings were not as well documented
as one might wish(*), but perhaps if you can update the
wiki as you find issues.

Gary

(*) I would be pleased to know I am wrong here.
_______________________________________________
mythtv-dev mailing list
mythtv-dev [at] mythtv
http://www.mythtv.org/mailman/listinfo/mythtv-dev


list at mcdermotts

May 10, 2012, 5:41 PM

Post #4 of 6 (457 views)
Permalink
Re: SQL to determine if a specific encoder is recording [In reply to]

On Thu, May 10, 2012 at 4:29 PM, David Engel <david [at] istwok> 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)
_______________________________________________
mythtv-dev mailing list
mythtv-dev [at] mythtv
http://www.mythtv.org/mailman/listinfo/mythtv-dev


david at istwok

May 10, 2012, 6:57 PM

Post #5 of 6 (455 views)
Permalink
Re: SQL to determine if a specific encoder is recording [In reply to]

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> 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
> http://www.mythtv.org/mailman/listinfo/mythtv-dev
>

--
David Engel
david [at] istwok
_______________________________________________
mythtv-dev mailing list
mythtv-dev [at] mythtv
http://www.mythtv.org/mailman/listinfo/mythtv-dev


keemllib at gmail

May 10, 2012, 8:24 PM

Post #6 of 6 (450 views)
Permalink
Re: SQL to determine if a specific encoder is recording [In reply to]

On 05/10/2012 07:41 PM, A McDermott wrote:
...
> 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...

Hi;

Are the chanids unique for the HDPVR (e.g 1000-1999?)

If so, here's a pared down version of my upcoming script
http://pastebin.ca/2147139 that will print:

HDPVR (cardid 7) started recording The Daily Show With Jon Stewart at 2012-05-10 22:00:00

Blue Bloods starts recording in: 22:50:08.884448

or: HDPVR is idle

--
Bill
_______________________________________________
mythtv-dev mailing list
mythtv-dev [at] mythtv
http://www.mythtv.org/mailman/listinfo/mythtv-dev

MythTV dev RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.