[mythtv] Re: [mythtv-commits] Re: Ticket #643: Program matching multiple recording schedules behaves unexpectantly

Bruce Markey bjm at lvcm.com
Fri Dec 9 16:36:00 EST 2005

Hal Burch wrote:
> FWIW, my argument for priorities would be: If I have one rules that
> says "This is X important to record" and another rule that says "This
> is Y important to record", then something that matches both rules
> should be at least max(X,Y) important.  Even if a user would not
> certain what the behavior would be in this case, using the settings of
> the schedule with a higher priority makes sense (it's as if duplicates
> of the show are created and priority is used to resolve the conflict).

Understood and this may be the right thing to do. When I say
'not comfortable' I mean that it is not clear to me that this
may not create more problems, questions and mysterious behavior
than it resolves.

Some background. There are two things that are sort of related
yet different issues. First, there is the precedence of which rule
should have control of a showing if more than one rule is a match,
then which show should have priority for 'first dibs' when being
placed in the schedule.

A first thought would be that a higher priority is a more favored
rule so in the case of two rules matching the same showing, the
higher priority should take precedence. Now lets say that there is
a situation where you want to lower the priority of a single showing
for the sake of other things at the same time (I can provide examples
if you need them ;-). I set an override, lower the priority, Save,
then look at the conflicts list but the override has no effect because
the priority was lower and lost to the normal rule. Same for setting
a Timeslot rule for an exceptional time along with a Channel rule
for the same title, or a Weekslot exception to an All rule. The
approach then was to always give precedence to the subset as an
exception to the superset.

I don't believe we had search rules yet at the time the new
scheduler went in in 0.15.x . With title match rules only, you
couldn't have (okay, shouldn't have had) two rules of the same
type for the same title. Only one would control all showing and
none would be controlled the other. This would come down to the
final tie breaker. If all else is equal and they aren't the same
rule, the recordid must be different. To be deterministic, we could
always choose the lower number or the higher number. The thinking
was that if it can down to this, myth should continue to be trusted
to record that same show that you've always relied on rather than
obeying the mistake you just made ;-). However, this could have
been the other way around and strive to honor the latest and
greatest new idea.

Now, with search rules, I could have an All rule for Late Show With
David Letterman and I could have an All rule for "Lance Armstrong
(Keyword Search)". When Lance is on Letterman, they both match and
they are both All. These are intersecting sets rather than subset
and superset. This can only happen if one of the rules is normal
and the other is a search, or both are searches. This suggests
that record.search could be used to decide which rule should have
precedence. However, it may be a broad search that matches for a
title shown once a week, or it may be a very rare term that matches
an episode of a title where there are five episodes rerun each day.

So it's hard to say which All rule is a more specific match. The
tie could be broken by recpriority but then there may be effects
where changing a priority here may screw up your plans over there.
As it stands, the older rule takes precedence and doesn't change
as you tweak things.

> The specific, plausable case I gave was trying to recording first runs

  "Consider two recording schedules: Schedule NEWEPISODES that "record
  new episodes only" with priority +1 Schedule REPEATS that records all
  repeat episodes of show A with priority -1 (REPEATS is programmed as a
  "Custom Record", FIRSTRUNS was added first, lower recordid)"

It appears to be similar to an example I've used a few times for
recording new episodes of "The Simpsons" with different attributes
than recording reruns. However, this example is a little bit of the
long way around. The NEWEPISODES (aka FIRSTRUNS) should be the
"Custom Record".

Rule Name: New Simpsons

program.title = 'The Simpsons'
AND program.previouslyshown = 0

Let's say there are 14 reruns per week and one new episode on FOX
each Sunday. If I set a normal title rule for "The Simpsons" with
"Record new episodes only", it will match all 15 showings then
during placement, it would mark 14 of them as "r". With the rule
above, the previouslyshown check takes place during match(!) so
it will only match the one showing on FOX. Next, I can go to any
of the rerun showings and add a new rule as they are not covered
by any other rule yet. I add a rule with low res and limited number
of episodes and so on. The only overlap is Sunday on FOX and only
when there is an actual new episode. 

The attributes for the new episodes will always apply even if on
some random Tuesday I have a conflict for a Simpsons rerun and I
raise the priority of the rule (rather than adding an override).

> and reruns at different priorities (I want reruns of show A, but
> that's not as important as getting the first-runs).  The current
> proposal would, if I added the rules in the wrong order, result in
> everything being recorded at the priority (and recording quality, etc)
> of the reruns.

Understood. Remove and add the rerun rule again. This assures
the first-run rule will always win regardless of tinkering.

Here's an actual situation where I could screw up.

Rule Name: PGA Final
program.title = 'PGA Golf'
AND channel.callsign != 'GOLF'
AND DAYNAME(program.starttime) = 'Sunday'

Rule Name: PGA Golf
program.title = 'PGA Golf'
AND channel.callsign != 'GOLF'

Golf coverage ends on time Thur-Sat but Sun may run long or have
sudden death holes. Therefore, I have a different rule with extra
endoffset. Priority has to do with fitting in with the things
around these showings and there is no reason to believe that the
Sunday round must always be higher or lower than the other rounds
(or the early rounds higher or lower than Sunday). Generally they
are about the same. Now if I lowered the priority on a Sunday to
move it to another card and make room for something else, I wouldn't
want the Sunday rule to disappear and be replaced by the every day
rule with it's regular priority. Worse yet, if there was a conflict
on Friday and I raised the every day rule, I'd hate to first find
out that it won precedence on Sunday when a drive on the 18th hole
of the final paring of the final round starts hooking toward the
water then... the deletion popup appears.

> That said, it may be a rare enough situation that it doesn't matter.

It does come up and it does matter. I'm not saying this is black
and white. The upside is that you could change precedence by
changing priority. The down side is that you might change precedence
by changing priority. Unless there is a compelling reason why
we would have to determine precedence by priority, I think we'd
be better off not adding another check that could cause the
precedence to flip-flop.

--  bjm

More information about the mythtv-dev mailing list