[mythtvnz] Finding a gap in the MythTV Scheduler
Steven Ellis
mythtvnz@lists.linuxnut.co.nz
Sat, 19 May 2007 14:01:13 +1200
This is a multi-part message in MIME format.
--------------030404010705040400060306
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Hadley Rich wrote:
> On Sat, 19 May 2007 12:09:57 Steven Ellis wrote:
>
>> Ok still going to borrow your brains if I may :)
>>
>
> You may borrow the 30% of it that's working this morning.
>
>
>> Not coded python before and wondered if there is an easy way to do
>> something like
>>
>
> Python is lurverly :)
>
>
>> if ( upcoming[0].recstartts > NOW + 30mins )
>> print "TRUE";
>> else
>> print "FALSE";
>> fi
>>
>> IE I only want to run epgsnoop if there is a window of 30 mins between now
>> and the next scheduled recording.
>>
>
> I think this should do what you want;
>
> #!/usr/bin/python
>
> from datetime import datetime, timedelta
> from MythTV import MythTV
>
> m = MythTV()
>
> upcoming = m.getUpcomingRecordings()
>
> print upcoming[0].title, upcoming[0].recstartts
>
> if upcoming[0].recstartts > (datetime.now() + timedelta(minutes=30)):
> print True
> else:
> print False
Almost getting there. Code below. The problem is getUpcomingRecordings
returns an empty value if we are currently recording. This is a problem
if we have multiple tuners in a box. I'm only interested if DVB-S tuners
are busy. Now I could just return False if any tuner is busy, but it
just helps reduce the available window to run an epgsnoop further.
Mind due i'm hardly using an analogue tuner now anyway.
My DVB-S tuner is tuner "3" on the test rig.
#!/usr/bin/python
#
# Do we have a safe window to execute an EPG check
from datetime import datetime, timedelta
from MythTV import MythTV
m = MythTV()
recording = m.isRecording("3")
if recording:
print "False"
else:
upcoming = m.getUpcomingRecordings()
if upcoming is None or len(upcoming) == 0:
print True
elif upcoming[0].recstartts > (datetime.now() +
timedelta(minutes=30)):
print upcoming[0].title, upcoming[0].recstartts
print True
else:
print False
--
Steven Ellis - Technical Director
OpenMedia Limited
email - steven@openmedia.co.nz
sales - sales@openmedia.co.nz
support - support@openmedia.co.nz
website - http://www.openmedia.co.nz
--------------030404010705040400060306
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hadley Rich wrote:
<blockquote cite="mid200705191240.25444.hads@nice.net.nz" type="cite">
<pre wrap="">On Sat, 19 May 2007 12:09:57 Steven Ellis wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Ok still going to borrow your brains if I may :)
</pre>
</blockquote>
<pre wrap=""><!---->
You may borrow the 30% of it that's working this morning.
</pre>
<blockquote type="cite">
<pre wrap="">Not coded python before and wondered if there is an easy way to do
something like
</pre>
</blockquote>
<pre wrap=""><!---->
Python is lurverly :)
</pre>
<blockquote type="cite">
<pre wrap="">if ( upcoming[0].recstartts > NOW + 30mins )
print "TRUE";
else
print "FALSE";
fi
IE I only want to run epgsnoop if there is a window of 30 mins between now
and the next scheduled recording.
</pre>
</blockquote>
<pre wrap=""><!---->
I think this should do what you want;
#!/usr/bin/python
from datetime import datetime, timedelta
from MythTV import MythTV
m = MythTV()
upcoming = m.getUpcomingRecordings()
print upcoming[0].title, upcoming[0].recstartts
if upcoming[0].recstartts > (datetime.now() + timedelta(minutes=30)):
print True
else:
print False</pre>
</blockquote>
Almost getting there. Code below. The problem is getUpcomingRecordings
returns an empty value if we are currently recording. This is a problem
if we have multiple tuners in a box. I'm only interested if DVB-S
tuners are busy. Now I could just return False if any tuner is busy,
but it just helps reduce the available window to run an epgsnoop
further.<br>
<br>
Mind due i'm hardly using an analogue tuner now anyway.<br>
<br>
My DVB-S tuner is tuner "3" on the test rig.<br>
<br>
<br>
#!/usr/bin/python<br>
#<br>
# Do we have a safe window to execute an EPG check<br>
<br>
from datetime import datetime, timedelta<br>
from MythTV import MythTV<br>
<br>
m = MythTV()<br>
<br>
recording = m.isRecording("3")<br>
<br>
if recording:<br>
print "False"<br>
else:<br>
upcoming = m.getUpcomingRecordings()<br>
<br>
if upcoming is None or len(upcoming) == 0:<br>
print True<br>
<br>
elif upcoming[0].recstartts > (datetime.now() +
timedelta(minutes=30)):<br>
print upcoming[0].title, upcoming[0].recstartts<br>
print True<br>
else:<br>
print False<br>
<br>
<br>
<br>
<br>
<pre class="moz-signature" cols="72">--
Steven Ellis - Technical Director
OpenMedia Limited
email - <a class="moz-txt-link-abbreviated" href="mailto:steven@openmedia.co.nz">steven@openmedia.co.nz</a>
sales - <a class="moz-txt-link-abbreviated" href="mailto:sales@openmedia.co.nz">sales@openmedia.co.nz</a>
support - <a class="moz-txt-link-abbreviated" href="mailto:support@openmedia.co.nz">support@openmedia.co.nz</a>
website - <a class="moz-txt-link-freetext" href="http://www.openmedia.co.nz">http://www.openmedia.co.nz</a>
</pre>
</body>
</html>
--------------030404010705040400060306--