Hi,

I've tried to make some changes to manual_record.py in the
src/tv/plugins subdirectory, to present the month/date/time start/stop
dialogs based on the current time. The code seems ok, though probably
could be cleaned up a bit (my python knowledge is minimal).

The off-by-one bug where the start/stop date is one month ahead is also
fixed by this patch.

The month and time configuration is ok, but I can't find anything to give
me days-in-month information (short of creating a list, but it won't be
able to handle leap years), so it lists 31 days regardless of which month
it is.

There's probably some issues with date/time validity checking that I've
triggered with this patch. It's probably there previously but the
interface was troublesome enough that few people tried messing with it.
For example, I tried setting the date to before today (June 18 instead of
June 19), and it gave an error "Save Failed, recording was lost: Sorry the
stop time does not give enough time for scheduler to pickup the change.
Please set it to record for a few minutes longer".

By right, according to the logic of the code the module should've
scheduled it for one year in advance if the date is before today?

Also, selecting an invalid day (31 June) will cause a crash of the module
instead of being handled by an exception handler.

My personal comments after playing with the interface a bit is that it's
really klunky for setting start/stop date-time manually. I'd usually want
to change the stop date-time info rather than the start time info (if I'm
trying to record something *now*), and it takes a lot of scrolling to get
to the stop info. I believe an interface like the following would probably
work better for changing the data:

Start: MMM/DD HH:MM
 Stop: MMM/DD HH:MM

+/- (up/down) selects between Start & Stop time, while you select the
field to to change using left / right arrows, and +/- (up/down) to scroll
the information. Scrolling a field that is of lesser value (e.g., Day)
would cause the Month field to rollover (31->1 causes month to advance,
1->31 causes the month to retreat, e.g.). The rollover would observe
days-in-month info so that the date is always valid. Similar Minutes
would also cause a rollover on the hours field.

(Hmmm, keeping the information as a time value instead of as separate
lists of numbers would probably avoid all the input validity checking
problems).

Unfortunately this is beyond my python and freevo programming skills, and
it'll take more than the half a day of hacking I spent on the current
patch. Is someone interested in taking it on?

T.C.

----
Wan Tat Chee (Lecturer)
School of Computer Science, Univ. of Science Malaysia,
11800 USM, Penang, Malaysia.      Rm.625 Ofc Ph: +604 653-3888 x 3617
NRG Lab Admin: +604 659-4757           Rm.601-E Ofc Ph: +604 653-4396
Internet: [EMAIL PROTECTED]            Web: http://nrg.cs.usm.my/~tcwan
GPG Key : http://nrg.cs.usm.my/~tcwan/tcw_gpg-20030322.asc
F'print : DCF2 B9B2 FA4D 1208 AD59  14CA 9A8F F54D B2C4 63C7
--- freevo-1.5-rc3/src/tv/plugins/manual_record.py.orig 2004-06-19 12:50:24.270416488 
+0800
+++ freevo-1.5-rc3/src/tv/plugins/manual_record.py      2004-06-19 15:27:01.995745080 
+0800
@@ -80,6 +80,14 @@
 
         self.months = [ _('Jan'), _('Feb'), _('Mar'), _('Apr'), _('May'), _('Jun'), 
_('Jul'), _('Aug'), _('Sep'), _('Oct'), _('Nov'), _('Dec') ]
     
+        now = time.time()
+        now += 300
+       self.startnow = now
+        self.starttime = time.localtime(now)
+        now += 1900
+       self.stopnow = now
+        self.stoptime = time.localtime(now)
+
     def make_newprog(self):
         self.prog = TvProgram()
 
@@ -91,23 +99,18 @@
         self.prog.channel_id = config.TV_CHANNELS[0][0]
        self.disp_channel = config.TV_CHANNELS[0][1]
 
-        now = time.time()
-        now += 300
-        starttime = time.localtime(now)
-        self.start_month = starttime[1]
-       self.disp_start_month = self.months[self.start_month]
-        self.start_day   = starttime[2]
-        self.start_time  = time.strftime(config.TV_TIMEFORMAT, starttime)
-        self.prog.start  = now
+        self.start_month = self.starttime[1]
+       self.disp_start_month = self.months[self.start_month - 1]
+        self.start_day   = self.starttime[2]
+        self.start_time  = time.strftime(config.TV_TIMEFORMAT, self.starttime)
+        self.prog.start  = self.startnow
        self.disp_starttime = '%s %s %s' % (self.disp_start_month, self.start_day, 
self.start_time)
 
-        now += 1900
-        stoptime = time.localtime(now)
-        self.stop_month = stoptime[1]
-       self.disp_stop_month = self.months[self.stop_month]
-        self.stop_day   = stoptime[2]
-        self.stop_time  = time.strftime(config.TV_TIMEFORMAT, stoptime)
-        self.prog.stop  = now
+        self.stop_month = self.stoptime[1]
+       self.disp_stop_month = self.months[self.stop_month - 1]
+        self.stop_day   = self.stoptime[2]
+        self.stop_time  = time.strftime(config.TV_TIMEFORMAT, self.stoptime)
+        self.prog.stop  = self.stopnow
        self.disp_stoptime = '%s %s %s' % (self.disp_stop_month, self.stop_day, 
self.stop_time)
 
     def actions(self):
@@ -159,9 +162,9 @@
         items = []
 
         iter=1
-        for m in self.months:
-            items.append(menu.MenuItem(m, action=self.alter_prop,
-                         arg=('startmonth', (m,iter))))
+       while iter < 13:
+            items.append(menu.MenuItem(self.months[(iter + self.starttime[1] - 1) % 
12 - 1], action=self.alter_prop,
+                         arg=('startmonth', (self.months[(iter + self.starttime[1] - 
1) % 12 - 1], (iter + self.starttime[1] - 1) % 12))))
             iter = iter + 1
 
         manualrecord_menu = menu.Menu(_('Modify Day'), items,
@@ -176,8 +179,12 @@
 
         iter=1
         while iter < 32:
-            items.append(menu.MenuItem(str(iter), action=self.alter_prop,
-                         arg=('startday', iter)))
+           newday = (iter + self.starttime[2] - 1)
+           currday = newday % 32
+           if newday >= 32:
+               currday += 1
+            items.append(menu.MenuItem(str(currday), action=self.alter_prop,
+                         arg=('startday', currday)))
             iter = iter + 1
 
         manualrecord_menu = menu.Menu(_('Modify Day'), items,
@@ -190,8 +197,12 @@
     def mod_start_time(self, arg=None, menuw=None):
         items = []
 
+       currminutes = self.starttime[3]*60 + self.starttime[4]
+       minpadding = 5 - (currminutes % 5)
+       if minpadding == 5:
+           minpadding = 0
         for i in range(288):
-            mod = i * 5
+            mod = (i * 5 + currminutes + minpadding) % 1440
             showtime = strftime(config.TV_TIMEFORMAT, gmtime(float(mod * 60)))
             items.append(menu.MenuItem(showtime, 
                                        action=self.alter_prop,
@@ -208,9 +219,9 @@
         items = []
 
         iter=1
-        for m in self.months:
-            items.append(menu.MenuItem(m, action=self.alter_prop,
-                         arg=('stopmonth', (m,iter))))
+       while iter < 13:
+            items.append(menu.MenuItem(self.months[(iter + self.stoptime[1] - 1) % 12 
- 1], action=self.alter_prop,
+                         arg=('stopmonth', (self.months[(iter + self.stoptime[1] - 1) 
% 12 - 1], (iter + self.stoptime[1] - 1) % 12))))
             iter = iter + 1
 
         manualrecord_menu = menu.Menu(_('Modify Day'), items,
@@ -225,8 +236,12 @@
 
         iter=1
         while iter < 32:
-            items.append(menu.MenuItem(str(iter), action=self.alter_prop,
-                         arg=('stopday', iter)))
+           newday = (iter + self.starttime[2] - 1)
+           currday = newday % 32
+           if newday >= 32:
+               currday += 1
+            items.append(menu.MenuItem(str(currday), action=self.alter_prop,
+                         arg=('stopday', currday)))
             iter = iter + 1
 
         manualrecord_menu = menu.Menu(_('Modify Day'), items,
@@ -239,8 +254,12 @@
     def mod_stop_time(self, arg=None, menuw=None):
         items = []
 
+       currminutes = self.starttime[3]*60 + self.starttime[4]
+       minpadding = 5 - (currminutes % 5)
+       if minpadding == 5:
+           minpadding = 0
         for i in range(288):
-            mod = i * 5
+            mod = (i * 5 + currminutes + minpadding) % 1440
             showtime = strftime(config.TV_TIMEFORMAT, gmtime(float(mod * 60)))
             items.append(menu.MenuItem(showtime, 
                                        action=self.alter_prop,

Reply via email to