Commits

Guido Draheim committed 69fd4e2

use timelist_sort to shuffle later-planned adapter into a timely order

  • Participants
  • Parent commits 27bae16

Comments (0)

Files changed (1)

File src/dvbcronrecording/computer.py

         """ weekday, starttime, adapter """
         groups = sorted(self._groups, key = lambda x: (x.weekday, x.newtimeMMM, x.adapter))
         self._groups = groups
+    def timelist_sort(self):
+        """ datetimeX, datetimeY, adapter from timelist_groups() """
+        groups = sorted(self._groups, key = lambda x: (x.datetimeX, x.datetimeY, x.adapter))
+        self._groups = groups
 
 class RecorderFlatPlan:
     def __init__(self):
     """ it is a component but it does not have its own database tables - it 
         just helps to turn the recording list into a proper recording plan. """
         
-    algorithm = Option(PACKAGE, "planning-algorithm", "plan3",
+    algorithm = Option(PACKAGE, "planning-algorithm", "plan4",
                        doc="Choose the planning type plan1,plan2,plan3,plan4")
     rankup_channels = ListOption(PACKAGE, "planning-rankup-channels","3sat,arte",
                        doc="Choose the channels to implicitly rank higher")
                 else:
                     previous = elem
                     group = RecorderGroup()
+                    group.datetimeX = elem.datetimeX
+                    group.datetimeY = elem.datetimeY
                     group.weekday = item.weekday
                     group.newtimeMMM = item.newtimeMMM
                     group.endtimeMMM = item.endtimeMMM
                     group.items += [ item ]
                 else:
                     previous = elem
+                    group.datetimeY = elem.datetimeY
                     group.endtimeMMM = item.endtimeMMM
                     group.extratimeM = item.extratimeM
                     group.items += [ item ]
             group.hasonlydays = []
             key = ""
             for item in group.items:
+                if not key and item.adapter:
+                    key = "(%s)" % item.adapter
                 key += "%02i%04i%04i(%s)" % (item.weekday, item.newtimeMMM, item.endtimeMMM, item.channelname)
                 if item.cloned and item.cloned.onlyday:
                     group.hasonlydays += [ item.cloned.months[0] ]
                 plan.addgroup(group)
         self.logg.info("adapterlist = %s", self.adapterlist())
         if True:
-            # plan.sort()
+            plan.timelist_sort()
             return self.new_reduce_regular_groups(plan)
         else:
-            # plan.sort()
+            plan.timelist_sort()
             return plan
             
     def plan(self, entries):