def SetMusic(UserId, MusicId, Level, BaseRate): Music = Func.Get_BestScore(UserId, MusicId) DataBase = DB.LoadBaseRate() Dic = { 'MusicId': MusicId, 'Level': Level, 'MusicName': Music['musicName'], 'Image': Music['musicFileName'], 'ArtistName': Music['artistName'], 'BaseRate': BaseRate } DataBase.SetMusic(Dic)
def CheckMusic(userId): MusicIdList = Func.Get_MusicIdList(userId) DataBase = DB.LoadBaseRate() BaseRateList = DataBase.Get_BaseRateList() NoneMusicList = [] ExistMusicList = [] for level in range(2, 4): for MusicId in MusicIdList[level - 2]: if MusicId in BaseRateList[level - 2]: Music = DataBase.Get_BaseRate(MusicId, level) if Music['BaseRate'] is not None: BaseRate = Music['BaseRate'] Dic = { 'MusicId': MusicId, 'MusicName': Music['MusicName'], 'MusicImage': Music['Image'], 'ArtistName': Music['ArtistName'], 'Level': level, 'BaseRate': BaseRate, 'AirPlus': Music['AirPlus'] } ExistMusicList.append(Dic) continue Music = Func.Get_BestScore(userId, MusicId) Dic = { 'MusicId': MusicId, 'MusicName': Music['musicName'], 'MusicImage': Music['musicFileName'], 'ArtistName': Music['artistName'], 'Level': level, 'BaseRate': None, 'AirPlus': False } NoneMusicList.append(Dic) DataBase.SetMusic(Dic, True) return NoneMusicList, ExistMusicList