Exemplo n.º 1
0
    def set_active(self):
        log(u"Jingle source {0} SET ACTIVE".format(self.audiosource.title),
            "sources")
        super(JingleSource, self).set_active()

        self.audiofiles = RandomAudioSourceWrapper(self.audiosource)
        Thread(target=self.insert_jingles).start()
Exemplo n.º 2
0
    def set_active(self):
        log(u"Back source {0} - BEGIN SET ACTIVE".format(self.audiosource.title), "sources")
        super(BackSource, self).set_active()
        audiofiles = RandomAudioSourceWrapper(self.audiosource)
        now = datetime.now()
        time_end = self.planning_element.time_end

        while now.time() < time_end and now.weekday() == self.planning_element.day:
            audiofile = audiofiles.get_next_random_audiofile()
            self.push_in_queue(audiofile)
            now = now + timedelta(seconds=audiofile.length)

        log(u"Back source {0} - END SET ACTIVE".format(self.audiosource.title), "sources")
Exemplo n.º 3
0
class JingleSource(RadioSource):

    CHUNK_SIZE = 10
    CALLBACK_TIME = 60

    def set_active(self):
        log(u"Jingle source {0} SET ACTIVE".format(self.audiosource.title), "sources")
        super(JingleSource, self).set_active()

        self.audiofiles = RandomAudioSourceWrapper(self.audiosource)
        Thread(target=self.insert_jingles).start()

    def insert_jingles(self):
        time_current = datetime.now()

        while time_current.time() < self.planning_element.time_end:
            log("insert jingles callback", "sources")
            time_current = datetime.now()

            if len(self.queue.get_secondary_queue()) <= 1:
                log("jingles queue empty", "sources")
                for i in range(0, self.CHUNK_SIZE):
                    self.push_in_queue(self.audiofiles.get_next_random_audiofile())

            sleep(self.CALLBACK_TIME)

        self.queue.flush()
Exemplo n.º 4
0
class JingleSource(RadioSource):

    CHUNK_SIZE = 10
    CALLBACK_TIME = 60

    def set_active(self):
        log(u"Jingle source {0} SET ACTIVE".format(self.audiosource.title),
            "sources")
        super(JingleSource, self).set_active()

        self.audiofiles = RandomAudioSourceWrapper(self.audiosource)
        Thread(target=self.insert_jingles).start()

    def insert_jingles(self):
        time_current = datetime.now()

        while time_current.time() < self.planning_element.time_end:
            log("insert jingles callback", "sources")
            time_current = datetime.now()

            if len(self.queue.get_secondary_queue()) <= 1:
                log("jingles queue empty", "sources")
                for i in range(0, self.CHUNK_SIZE):
                    self.push_in_queue(
                        self.audiofiles.get_next_random_audiofile())

            sleep(self.CALLBACK_TIME)

        self.queue.flush()
Exemplo n.º 5
0
    def set_active(self):
        log(
            u"Back source {0} - BEGIN SET ACTIVE".format(
                self.audiosource.title), "sources")
        super(BackSource, self).set_active()
        audiofiles = RandomAudioSourceWrapper(self.audiosource)
        now = datetime.now()
        time_end = self.planning_element.time_end

        while now.time() < time_end and now.weekday(
        ) == self.planning_element.day:
            audiofile = audiofiles.get_next_random_audiofile()
            self.push_in_queue(audiofile)
            now = now + timedelta(seconds=audiofile.length)

        log(u"Back source {0} - END SET ACTIVE".format(self.audiosource.title),
            "sources")
Exemplo n.º 6
0
    def set_active(self):
        log(u"Jingle source {0} SET ACTIVE".format(self.audiosource.title), "sources")
        super(JingleSource, self).set_active()

        self.audiofiles = RandomAudioSourceWrapper(self.audiosource)
        Thread(target=self.insert_jingles).start()