Beispiel #1
0
def GetRandomClip(bpm, key, instrumentId):
    songList = QueryRunner.getSongsWithBPMKeyAndInstrumentId(
        bpm, key, instrumentId)
    if songList is []:
        return None

    length = len(songList) - 1
    randomIndex = randint(0, length)

    return songList[randomIndex][0]
Beispiel #2
0
    def _getData(self, key, bpm, instrumentKey):
        self.writer.PrintAndWrite("** getting data")

        # gets all the songs with the correct bpm, key and instrument
        clipList = QueryRunner.getSongsWithBPMKeyAndInstrumentId(
            bpm, key, instrumentKey)
        if len(clipList) is 0:
            return False

        idClipList = []

        for item in clipList:
            idClipList.append(item[0])

        # need to have the preference for all users
        preferences = {}
        allPreferences = QueryRunner.getAllUsersPreferenceFull()
        if allPreferences is None:
            return False

        for pref in allPreferences:
            resultDict = {}
            user = pref[0]
            item1 = pref[1]
            item2 = pref[2]
            rating = pref[3]

            if item1 in idClipList:
                if item1 not in resultDict:
                    resultDict[item1] = rating
                else:
                    resultDict[item1] += rating

            if item2 in idClipList:
                if item2 not in resultDict:
                    resultDict[item2] = rating
                else:
                    resultDict[item2] += rating

            if user not in preferences:
                # if the user is not known, just add the generated dictionary
                preferences[user] = resultDict

            else:
                # if the user is known, update the existing dictionary with new data
                existingDict = preferences[user]
                for (subkey, subitem) in resultDict.items():
                    existingDict[subkey] = subitem
                preferences[user] = existingDict

        self.data = preferences
Beispiel #3
0
 def _getAllTracks(self, bpm, key, instrumentID):
     songList = QueryRunner.getSongsWithBPMKeyAndInstrumentId(
         bpm, key, instrumentID)
     return songList