예제 #1
0
    def __find_queued (self):
        """
        Return next queued song, or a random song, or a jingle.
        """

        # Jingle time?
        if settings.PLAY_JINGLES:
            jingle = self.JingleTime()
            if jingle:
                return jingle

        # Fetch from queue with playtime explicitly set
        queues = Queue.objects.filter (played=False, playtime__lte = datetime.now()).order_by('-priority', 'id')

        # Nothing explicitly set for the moment, lets check normal queue entries
        if not queues:
            # Since OR queries have been problematic on production server earlier, we do this hack..
            queues = Queue.objects.filter (played=False, playtime = None).order_by ('-priority', 'id')

        if queues:
            # Something we should take from the queue
            queue = queues [0]
        else:
            # Nothing in queue, DJRandom turn
            song = self.getRandomSong ()
            queue = common.queue_song (song, self.dj_user, False, True)

        common.play_queued (queue)
        return queue.song
예제 #2
0
    def __find_queued(self):
        """
        Return next queued song, or a random song, or a jingle.
        """

        # Jingle time?
        if settings.PLAY_JINGLES:
            jingle = self.JingleTime()
            if jingle:
                return jingle

        # Fetch from queue with playtime explicitly set
        queues = Queue.objects.filter(played=False,
                                      playtime__lte=datetime.now()).order_by(
                                          '-priority', 'id')

        # Nothing explicitly set for the moment, lets check normal queue entries
        if not queues:
            # Since OR queries have been problematic on production server earlier, we do this hack..
            queues = Queue.objects.filter(played=False,
                                          playtime=None).order_by(
                                              '-priority', 'id')

        if queues:
            # Something we should take from the queue
            queue = queues[0]
        else:
            # Nothing in queue, DJRandom turn
            song = self.getRandomSong()
            queue = common.queue_song(song, self.dj_user, False, True)

        common.play_queued(queue)
        return queue.song
예제 #3
0
 def getRandom(self):
     query = self.max_songlength and Song.active.filter(song_length__lt = self.max_songlength) or Song.active.all()
     song = self.select_random(query)
     C = 0
     self.log.debug("Trying to find a random song")
     # Try to find a good song that is not locked. Will try up to 10 times.
     while not self.isGoodSong(song) and C < 10:
        self.log.debug("Random %s - song : %s [%s]" % (C, song.title, song.id))
        song = self.select_random(query)
        C += 1
     self.log.debug("Using song %s (%s)" % (song.title, song.id))
     Q = common.queue_song(song, self.dj_user, False, True)
     common.play_queued(Q)
     return song
예제 #4
0
 def getRandom(self):
     query = self.max_songlength and Song.active.filter(song_length__lt = self.max_songlength) or Song.active.all()
     song = self.select_random(query)
     C = 0
     self.log.debug("Trying to find a random song")
     # Try to find a good song that is not locked. Will try up to 10 times.
     while not self.isGoodSong(song) and C < 10:
        self.log.debug("Random %s - song : %s [%s]" % (C, song.title, song.id))
        song = self.select_random(query)
        C += 1
     self.log.debug("Using song %s (%s)" % (song.title, song.id))
     Q = common.queue_song(song, self.dj_user, False, True)
     common.play_queued(Q)
     return song
예제 #5
0
def findQueued():
    songs = Queue.objects.filter(played=False, playtime__lte = datetime.datetime.now()).order_by('-priority', 'id')
    if not songs: # Since OR queries have been problematic on production server earlier, we do this hack..
        songs = Queue.objects.filter(played=False, playtime = None).order_by('-priority', 'id')
    if settings.PLAY_JINGLES:
        jingle = JingleTime()
        if jingle:
            return jingle
    if songs:
        song = songs[0]
        common.play_queued(song)
        return song.song
    else:
        return getRandom()
예제 #6
0
def findQueued():
    songs = Queue.objects.filter(
        played=False,
        playtime__lte=datetime.datetime.now()).order_by('-priority', 'id')
    if not songs:  # Since OR queries have been problematic on production server earlier, we do this hack..
        songs = Queue.objects.filter(played=False, playtime=None).order_by(
            '-priority', 'id')
    if settings.PLAY_JINGLES:
        jingle = JingleTime()
        if jingle:
            return jingle
    if songs:
        song = songs[0]
        common.play_queued(song)
        return song.song
    else:
        return getRandom()
예제 #7
0
def getRandom():
    query = max_length and Song.active.filter(song_length__lt = max_length) or Song.active.all()
    songs = query.count()
    rand = random.randint(0,songs-1)
    song = query[rand]
    C = 0
    Log.debug("Trying to find a random song")
    # Try to find a good song that is not locked. Will try up to 10 times.
    while not isGoodSong(song) and C < 10:
       Log.debug("Random %s - song : %s [%s]" % (C, song.title, song.id))
       rand = random.randint(0,songs-1)
       song = query[rand]
       C += 1
    Log.debug("Using song %s (%s)" % (song.title, song.id))
    Q = common.queue_song(song, djUser, False, True)
    common.play_queued(Q)
    return song
예제 #8
0
def getRandom():
    query = max_length and Song.active.filter(
        song_length__lt=max_length) or Song.active.all()
    songs = query.count()
    rand = random.randint(0, songs - 1)
    song = query[rand]
    C = 0
    Log.debug("Trying to find a random song")
    # Try to find a good song that is not locked. Will try up to 10 times.
    while not isGoodSong(song) and C < 10:
        Log.debug("Random %s - song : %s [%s]" % (C, song.title, song.id))
        rand = random.randint(0, songs - 1)
        song = query[rand]
        C += 1
    Log.debug("Using song %s (%s)" % (song.title, song.id))
    Q = common.queue_song(song, djUser, False, True)
    common.play_queued(Q)
    return song