Esempio n. 1
0
 def start_recording(self, data):
     """
     Aufnahme starten
     """
     result = self.client.recorder_start()
     store = CombaCalendarService()
     self._preparePlaylistStore(store, datetime.datetime.now(), data)
     uri = store.getUri()
     store.start()
     if self._check_result(result):
         self.success('start_recording', result, '00')
     else:
         self.error('start_recording', result, '01')
Esempio n. 2
0
    def precache(self, data):
        """
        Playlisten 7 Tage im Voraus abholen
        """
        periods = self.config.getPlayPeriods() +  self.config.getRecordPeriods()
        timeBegin = datetime.datetime.now()
        for i in range(0, int(self.get('calendar_precache_days'))):
            for period in periods:

                store = CombaCalendarService()
                self._preparePlaylistStore(store, timeBegin, period)
                store.start()
                counter = 40
                while  counter > 0  and store.is_alive():
                    counter = counter - 1
                    time.sleep(0.1)

            timeBegin =  timeBegin + datetime.timedelta(1)


        self.success('precache')
Esempio n. 3
0
    def _load_playlist(self):
        """
        Playlist laden und von dem Track und Zeitpunkt an starten, der aktuell laufen sollte
        """

        self.messenger.send("Try to load playlist", '0501', 'info', 'loadPlaylist' , None, 'appinternal')

        # Die Playlist holen
        store = CombaCalendarService()

        # start_date ist das Datum, an dem die Playlist beginnen soll - abrunden auf den Beginn der denierten Länge für einen Track
        start_date  = datetime.datetime.now() - datetime.timedelta(seconds=int(datetime.datetime.now().strftime('%s')) % int(self.secondspertrack))

        store.setDateFrom(start_date.strftime("%Y-%m-%dT%H:%M"))
        store.setUntilTime(self.stop_time)

        store.start()
        uri = store.getUri()

        # wait until childs thread returns
        store.join()

        result = self.client.playlist_load(uri)
            
        if not self._get_data(result):
            self.messenger.send('Could not get Data from controller', '0504', 'fatal', 'loadPlaylist' , None, 'appinternal')
        else:
            result = self.client.playlist_play()
            if not self._get_data(result):
                self.messenger.send('Could not get Data from controller', '0505', 'fatal', 'loadPlaylist' , None, 'appinternal')

            else:

                time.sleep(0.2)
                unix_time_now = int(datetime.datetime.now().strftime('%s'))
                # berechnen die Sekunden die wir noch weiterspulen müssen
                seek_time = unix_time_now - int(start_date.strftime('%s'))
                # ... und seek
                self.client.playlist_seek(str(seek_time))
Esempio n. 4
0
    def load_playlist(self, data):
        """
        Playlist laden
        """

        store = CombaCalendarService()
        self._preparePlaylistStore(store, datetime.datetime.now(), data)
        uri = store.getUri()
        store.start()

        # wait until childs thread returns
        store.join()

        data = {}
        data['uri'] = uri

        result = self.client.playlist_load(uri)
        if self._check_result(result):
            self.success('load_playlist', data, '00')
        else:
            self.error('load_playlist', data, '02')