<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Oct 6, 2014 at 5:28 PM, Nicolas Krzywinski <span dir="ltr"><<a href="mailto:myth@site7even.de" target="_blank">myth@site7even.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
Am 2014-10-06 23:37, schrieb <a href="mailto:mythtv-users-request@mythtv.org" target="_blank">mythtv-users-request@mythtv.<u></u>org</a>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Message: 18<br>
Date: Mon, 6 Oct 2014 15:36:44 -0600<br>
From: John P Poet <<a href="mailto:jppoet@gmail.com" target="_blank">jppoet@gmail.com</a>><span class=""><br>
To: Discussion about MythTV <<a href="mailto:mythtv-users@mythtv.org" target="_blank">mythtv-users@mythtv.org</a>><br>
Subject: Re: [mythtv-users] Conditional custom recording rule<br>
Message-ID:<br></span>
<<a href="mailto:CACSqvJkhM_fJsMXQ4HeZS%2BFthd3vwohQhXdP3EAO6GDBc3aoUQ@mail.gmail.com" target="_blank">CACSqvJkhM_fJsMXQ4HeZS+<u></u>Fthd3vwohQhXdP3EAO6GDBc3aoUQ@<u></u>mail.gmail.com</a>><br>
Content-Type: text/plain; charset="utf-8"<span class=""><br>
<br>
On Mon, Oct 6, 2014 at 2:25 PM, Ian Evans <<a href="mailto:dheianevans@gmail.com" target="_blank">dheianevans@gmail.com</a>> wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
First off, I'd like to thank Hika, Stephen and Nicolas (and anyone else<br>
who'll be jumping in) for looking at this. The fact that we can even toss<br>
this around shows how great MythTV is as compared to the STBs offered by<br>
the cable and sat companies.<br>
<br>
I guess it's really an exercise in laziness. :-) I could just have a rule<br>
for the backup newscast set at a lower priority, but I like to keep my<br>
conflict list free of priority conflicts (I only occasionally get them) so<br>
that when I look I see the real conflict choices between two classic movies<br>
or docs.<br>
<br>
I see here (<a href="http://www.mythtv.org/wiki/Custom_Recording" target="_blank">http://www.mythtv.org/wiki/<u></u>Custom_Recording</a>) that nested<br>
selects work. But do if/then/else phrases?<br>
<br>
This is not valid sql or mythtv obviously but the logic might be:<br>
<br>
IF (select title='CTV News' and time='6pm') = 0 THEN schedule Global News<br>
at 6pm<br>
<br>
</blockquote>
<br>
You can create a Custom Record Rule which uses multiple references to<br>
programs. The 'Additional Tables' just needs filled in to let it know that<br>
you want to base your rule off of another "program". See the attached<br>
screenshot for an example (hopefully you can read it, since I had to save<br>
it at an extremely low quality).<br>
<br></span>
John<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL:<br>
<br>
<<a href="http://www.mythtv.org/pipermail/mythtv-users/attachments/20141006/2b948262/attachment.html" target="_blank">http://www.mythtv.org/<u></u>pipermail/mythtv-users/<u></u>attachments/20141006/2b948262/<u></u>attachment.html</a>><br>
-------------- next part --------------<br>
A non-text attachment was scrubbed...<br>
Name: Fallback-recording.jpg<br>
Type: image/jpeg<br>
Size: 25698 bytes<br>
Desc: not available<br>
URL:<br>
<br>
<<a href="http://www.mythtv.org/pipermail/mythtv-users/attachments/20141006/2b948262/attachment.jpg" target="_blank">http://www.mythtv.org/<u></u>pipermail/mythtv-users/<u></u>attachments/20141006/2b948262/<u></u>attachment.jpg</a>><br>
</blockquote>
Thanks for this post John, as I learned a lot from it.<br>
<br>
First, now I understand the additional tables box within the recording rule mask. SQLly spoken, the "additional tables" box content is appended to the tables expression of the sql query and because of this, there is a comma in front, right?</blockquote><div> </div><div>Yes</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Second, I have to assume - due to my lack of deeper knowledge at this point - that multiple sql table aliases to the same table can be used like different tables. At least this is my understanding of why we can use the program table doubled - one as original program table and the same one aliased as pother.<br></blockquote><div><br></div><div>Yes. </div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Third, after thinking a quite amount of times about your example, I guess now I finally understand it - which leads me to a final question:<br>
pother.starttime has to exactly match program.starttime, so if the alternative news would not exactly start at the same time, this has to be extended, correct?<br></blockquote><div><br></div><div>pother.starttime does not have to equal program.starttime, but it does need to be "reigned in" to allow mysql to know what program it is checking.</div><div><br></div><div>You could think of it as two separate queries. mysql is going to pull all the matches for any program(s) that match the given criteria for 'program':</div><div><br></div><div>program.title = "News" AND program.chanid = 1071</div><div><br></div><div>It is also going to grab any program(s) which match 'pother':</div><div><br></div><div>pother.title <> "Other News" AND DAYNAME(pother.starttime) = 'Saturday'</div><div><br></div><div>As long as the results for both of those are not empty sets, you effectively have a match and it will record 'program'. The "loser" your pother query is though, the harder mysql has to work. Without a starttime you are making it check every program on that day. If you also leave off that chanid, it has to check every show on every channel. If you are not careful, the mysql query will become extremely intensive, and you will kill the performance of the scheduler.</div><div><br></div><div>You could probably get away with limiting the start time to a range:</div><div><br></div><div>(HOUR(program.starttime,...) BETWEEN 12 AND 14) AND (HOUR(pother.starttime,...) BETWEEN 16 AND 22)</div><div> <br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">As mentioned earlier, this really is an awesome example of what MythTV is able to do!<br></blockquote><div><br></div><div>Yup, I make heavy use of power rules. I generally don't push them this far, though ;-)</div><div><br></div><div><br></div><div>John </div></div></div></div>