[mythtv-users] Tuner Schedules

Michael T. Dean mtdean at thirdcontact.com
Sat Mar 19 17:38:06 UTC 2011


On 03/18/2011 08:30 PM, Spencer Herzberg wrote:
>>>>>> Or, you can write your own script that can be run at the command-line or through cron, using the Python bindings.
>>>>>>
>> http://www.mythtv.org/wiki/0.24_Python_bindings/Connection_Handlers#lockTuner
>>>>>> (Description isn't complete, yet, but if you pass a capture card ID, you can tell it  to lock a specific tuner--tell mythbackend that tuner is not available, so it won't be used for scheduling.  You'll need to keep the connection from the python script to the backend open as long as you want the tuner locked--the destructor will unlock anything prior to closing the connection.  So, if done on a cron job, the first script could lock the tuner and keep it open and the second could )
>>>> Heh, forgot to finish the thought...  "the second could just kill the
>>>> first process."
>> Posting a copy of the script(s) to the wiki, along with descriptions and
>> additional instructions, would be wonderful.
>>
>> http://www.mythtv.org/wiki/Category:Scripts
>> http://www.mythtv.org/wiki/Category:Python_Scripts
>>
>> You can use one of the Python Script pages to get the "template" for
>> setting up code boxes and categories, or feel free to ask for help here
>> or in #mythtv-users on IRC.
> I may jump in IRC later tonight or this weekend to ask some more questions.
>
> However, after some simple playing around (with the python bindings)
> lockTuner(), it seemed to work a little strangely. The recording didn't
> record just like you said, but in MythWeb under Listings, the recording
> showed up as "recorded" but "Recorded Programs" didn't show the recording. I
> also assumed that it rescheduled it later but I forgot to look before I
> deleted the schedule.
>
> Also, when I tried to freeTuner(0) or freeTuner(1) I got:
> [stack trace]
> File "/usr/lib/pymodules/python2.6/MythTV/methodheap.py", line 141, in free
>      res = self.getRecorderDetails(id).hostname
> AttributeError: 'MythBE' object has no attribute 'getRecorderDetails'
> [/stack trace]
>
> I didn't dig into the source to see what was up, but I thought someone would
> know of any problems in the source currently. I'm running Ubuntu 10.04 with
> the mythbuntu addon .24 + fixes if that helps. So I just killed the process
> that had the MythBE connection and subsequent recordings were skipped, like
> the tuner was still locked. This happened to my twice and the only fix was
> to restart the server (I suppose restarting mythbackend would have worked
> too). I didn't have a ton of time to debug this so I'll try it again later.
>
> Any help would be great!

Just thought I'd give you a little update.  Raymond (the Python bindings 
guru) and I were talking about this in IRC, yesterday.  He will be 
fixing the issue with the getRecorderDetails method.

There are a few other things to note about the command.  Since the 
command that's used to lock the tuner was designed to allow an external 
program to access the video device, the command can only be run from the 
backend that contains the capture card.  So, if you have 2 capture cards 
defined in MythTV and card 1 is on the master backend and card 2 on a 
remote backend, you'd have to run a script to lock card 1 on the master 
backend host and a script to lock card 2 on the remote backend host.

In the meantime, what I've since decided may be the best approach for 
you to use is still possible:  using Custom/Power Recording Rules.  To 
do this, you'd go to Manage Recordings|Schedule Recordings|Custom Record 
and create rules as described 
http://www.mythtv.org/docs/mythtv-HOWTO-12.html#ss12.5 .  The basic idea 
is to get the proper SQL, then Store that SQL (which puts it away as a 
user-defined "custom" example clause, so you can pull it up, again, by 
just selecting it from the examples), then save the rule.  Then, to 
create your next rule, you'd go back into the editor, select the example 
you saved, then just edit the title.

To record all Nova episodes, except those airing from 8-10pm, regardless 
of tuner:
program.title = 'Nova'
AND (
      TIME(program.starttime) >= '22:00:00'
      OR
      TIME(program.endtime) <= '20:00:00'
     )
Note, though, that this will record shows that air right up to the 
boundaries--it will record an episode airing from 7-8pm or an episode 
recording from 10-11pm.  If you don't want "boundary" episodes, get rid 
of the equal on the time comparisons.  And if you have any time ranges 
that span midnight, you'll need to make the time check more complex.  
Also, you can change the TIME() function to HOUR(), instead, and compare 
to simple integers if you don't plan to involve minutes or seconds in 
the decision making.

To record all Nova episodes, but not use tuner 1 to record episodes 
airing from 8-10pm and not use tuner 2 to record episodes airing from 
9am-3pm (assuming you have 2 video sources, where tuner 1 uses source 1, 
whose channel IDs all fall in the range 1000-1999; and tuner 2 uses 
source 2, whose channel IDs all fall in the range 2000-2999):
program.title = 'Nova'
AND (
       (
        program.chanid BETWEEN 1000 AND 1999
        AND (
             TIME(program.starttime) >= '22:00:00'
             OR
             TIME(program.endtime) <= '20:00:00'
             )
       )
       OR
       (
program.chanid BETWEEN 2000 AND 2999
        AND (
             TIME(program.starttime) >= '15:00:00'
             OR
             TIME(program.endtime) <= '09:00:00'
            )
)
     )

You can specify a Rule Name, then use the "Store" button in the editor 
to store the SQL as an example clause (not a search) and then you can 
select that example when creating the next rule and that exact SQL is 
put in as "template" SQL for you to edit.  If you store the first 
completed rule (using a nice short title, like Nova), you then just have 
to edit the title to create new rules.

Note, though, that the SQL is difficult to edit because we lack a 
multi-line text edit widget in MythUI.  Therefore, I recommend that you 
start the rule with mythfrontend--specify a rule name and select "Match 
an exact title"--then set the rule to record (feel free to mark it 
inactive at this point).  Then, go to MythWeb and edit the SQL (which 
allows you to use copy/paste and line breaks and text isn't cut off).  
Once you finish it, you can go back to mythfrontend and select the rule 
in the editor, change the rule name, then Store the rule as an example.  
>From that point on, you can easily select the example clause, edit the 
title, and save the rule in mythfrontend.

Mike


More information about the mythtv-users mailing list