Commits

Guido Draheim committed 7aa2c1b

set_adapters_from_channels_list

Comments (0)

Files changed (3)

src/dvbcronrecording/channels.py

                              str(item.apid),
                              str(item.tpid),                             
                              ])
+    def channels_list(self):
+        " currently it returns directly the db orm items"
+        return self._channel_list()
 
 class RecordingChannelsItem: pass
 class RecordingChannelsConfItem: pass

src/dvbcronrecording/computer.py

 months_ahead = 3
     
 class TracSimpleRecorderComputer:
+    def __init__(self):
+        self._adapters = {}
+    
+    def adapters(self, channelname):
+        if channelname in self._adapters:
+            return self._adapters[channelname]
+        return ["0"]
+    def set_adapters_from_channels_list(self, channelslist):
+        for entry in channelslist:
+            channelname = entry.channelname
+            adapter = entry.adapter
+            if channelname not in self._adapters:
+                self._adapters[channelname] = []
+            if adapter not in self._adapters[channelname]:
+                self._adapters[channelname] += [ adapter ]
+    
     def zero(self, spec):
         if not spec: return 0
         return int(spec)

src/dvbcronrecording/core.py

     def loadtextlines(self, req):
         entries = self._recordings_list(req)
         computer = TracSimpleRecorderComputer()
+        computer.set_adapters_from_channels_list(self.channels_list())
         plan = computer.plan(entries)
         for group in plan.groups():
             newtime = MMMtoHHMM(group.newtimeMMM).replace(":","")
         return list(self._recording_plan_from(entries))
     def _recording_plan_from(self, entries):
         computer = TracSimpleRecorderComputer()
+        computer.set_adapters_from_channels_list(self.channels_list())
         plan = computer.plan(entries)
         for item in plan.items():
             yield item
             return [ 0 ]
         channels = DvbCronRecordingChannelsPlugin(self.env)
         return channels.channelsconf_for_adapter(adapter)
+    def channels_list(self):
+        if DvbCronRecordingChannelsPlugin is None:
+            return [ 0 ]
+        channels = DvbCronRecordingChannelsPlugin(self.env)
+        return channels.channels_list()
 
 
     """ 
     def _makefile_entries(self, req):
         entries = self._recordings_list(req)
         computer = TracSimpleRecorderComputer()
+        computer.set_adapters_from_channels_list(self.channels_list())
         plan = computer.plan(entries)
         for group in plan.groups():
             if not group.items: continue