Ejemplo n.º 1
0
 def getWordsSnamesVnamesByAid(self, ID, type):
     logic_song = Logic_Song()
     if type == 'ALBUM':
         A_S = logic_song.getSongAlbumByAID(ID)
     else:
         A_S = logic_song.getSongListByLID(ID)
     songList = []
     for i in A_S:
         songList.append(i.SID)
     songs = logic_song.getSongsByIdList(songList)
     IRCS = []
     URLS = []
     SNAMES = []
     VANMES = []
     for song in songs:
         path = '../网易云音乐2/static' + song.SWORDSURL
         IRCS.append(getJsonByPath(path))
         URLS.append(url_for('static', filename=song.SAUDIOURL[1:]))
         SNAMES.append(song.SNAME)
         VANMES.append(song.VNAME)
     args = {
         "IRCS": IRCS,
         "URLS": URLS,
         "SNAMES": SNAMES,
         "VNAMES": VANMES,
         "SIDS": songList,
     }
     return args
Ejemplo n.º 2
0
 def getWordsSnamesVnamesBySid(self, List):
     logic_song = Logic_Song()
     song = logic_song.getSongsByIdList(List)[0]
     path = '../网易云音乐2/static' + song.SWORDSURL
     irc = getJsonByPath(path)
     args = {
         "IRCS": [irc],
         "URLS": [url_for('static', filename=song.SAUDIOURL[1:])],
         "SNAMES": [song.SNAME],
         "VNAMES": [song.VNAME],
     }
     return args
Ejemplo n.º 3
0
    def getAlbumAndListMessageByAid(self, ID, type):
        logic_song = Logic_Song()
        args = {}
        if type == 'SONG':
            AOL = logic_song.getSongsByIdList([ID])[0]
            SNAMES = [AOL.SNAME]
            SAURLS = [AOL.SAUDIOURL]
            SVOCALISTS = [AOL.VNAME]
            SIDS = [AOL.ID]
            args = {
                "id": AOL.ID,
                "name": AOL.SNAME,
                "imgurl": AOL.SIMAGEURL[1:],
                "snames": SNAMES,
                "saurls": SAURLS,
                "svocalists": SVOCALISTS,
                "sids": SIDS
            }
            args.update({"type": "SONG"})
            return args
        if type == 'ALBUM':
            AOL = logic_song.getAlbumById(ID)
            args.update({"type": "ALBUM"})
            R_S = logic_song.getSongAlbumByAID(ID)

        elif type == 'LIST':
            AOL = logic_song.getListById(ID)
            args.update({"type": "LIST"})
            R_S = logic_song.getSongListByLID(ID)
        idList = []
        for i in R_S:
            idList.append(i.SID)
        songs = logic_song.getSongsByIdList(idList)

        SNAMES = []
        SAURLS = []
        SVOCALISTS = []
        SIDS = []
        for i, song in enumerate(songs):
            SNAMES.append(song.SNAME)
            SAURLS.append(song.SAUDIOURL)
            SVOCALISTS.append(song.VNAME)
            SIDS.append(song.ID)
        args.update({
            "id": ID,
            "snames": SNAMES,
            "saurls": SAURLS,
            "svocalists": SVOCALISTS,
            "sids": SIDS
        })
        args.update({
            "name": AOL.NAME,
            "imgurl": AOL.URL[1:],
        })
        return args
 def __init__(self, s=1):
     self.s = s
     self.logic_leaderboard = Logic_Leaderboard()
     self.logic_song = Logic_Song()
     self.mysnow = MySnow()
class leaderboardController():
    def __init__(self, s=1):
        self.s = s
        self.logic_leaderboard = Logic_Leaderboard()
        self.logic_song = Logic_Song()
        self.mysnow = MySnow()

    def deleteLeaderboard(self):
        NAMES = ['飙升榜', '新歌榜', '热歌榜']
        for name in NAMES:
            LIST = self.logic_song.getListByNAME(name)
            if LIST == None:
                continue
            for list in LIST:
                id = list.ID
                self.logic_song.delete_ListSongByLID(id)
                self.logic_song.delete_list(id)

    def createList(self, args):
        #创建飙升榜
        solarId = self.mysnow.get_id()
        solarName = '飙升榜'
        solarUrl = '/imgs/n_blist/飙升榜.jpg'
        self.logic_song.addList(solarId, solarName, solarUrl, 0)
        solarSong = args['solarArgs']['ids']
        for sid in solarSong:
            self.logic_song.addList_Song(solarId, sid)

        #创建新歌榜
        newId = self.mysnow.get_id()
        newName = '新歌榜'
        newUrl = '/imgs/n_blist/新歌榜.jpg'
        self.logic_song.addList(newId, newName, newUrl, 0)
        newSong = args['newArgs']['ids']
        for sid in newSong:
            self.logic_song.addList_Song(newId, sid)

        #创建热歌榜
        hotId = self.mysnow.get_id()
        hotName = '热歌榜'
        hotUrl = '/imgs/n_blist/热歌榜.jpg'
        self.logic_song.addList(hotId, hotName, hotUrl, 0)
        hotSong = args['hotArgs']['ids']
        for sid in hotSong:
            self.logic_song.addList_Song(hotId, sid)

        return solarId, newId, hotId

    def Leaderboard(self):
        self.deleteLeaderboard()
        solarsongId = self.logic_leaderboard.soarLeaderboard()
        newsongId = self.logic_leaderboard.newLeaderboard()
        hotsongId = self.logic_leaderboard.hotLeaderboard()

        solarArgs = {}
        solarArgs.update({"ids": solarsongId})
        solarNames = []
        for i in range(len(solarsongId)):
            solarSong = self.logic_song.getSongsByIdList([solarsongId[i]])[0]
            solarNames.append(solarSong.SNAME)
        solarArgs.update({"names": solarNames})

        newArgs = {}
        newArgs.update({"ids": newsongId})
        newNames = []
        for i in range(len(newsongId)):
            newSong = self.logic_song.getSongsByIdList([newsongId[i]])[0]
            newNames.append(newSong.SNAME)
        newArgs.update({"names": newNames})

        hotArgs = {}
        hotArgs.update({"ids": hotsongId})
        hotNames = []
        for i in range(len(hotsongId)):
            hotSong = self.logic_song.getSongsByIdList([hotsongId[i]])[0]
            hotNames.append(hotSong.SNAME)
        hotArgs.update({"names": hotNames})

        args = {}
        args.update({"solarArgs": solarArgs})
        args.update({"newArgs": newArgs})
        args.update({"hotArgs": hotArgs})
        solarId, newId, hotId = self.createList(args)
        args['solarArgs'].update({"Id": solarId})
        args['newArgs'].update({"Id": newId})
        args['hotArgs'].update({"Id": hotId})
        return args

    def setPlayMessage(self, sid):
        songPlayMessage = self.logic_leaderboard.getPlayMessageBySid(sid)
        preTime = songPlayMessage.PRETIME
        currentTime = int(time.time())
        num = songPlayMessage.NUM + 1
        DNUM = num - songPlayMessage.PRENUM
        nextTime = songPlayMessage.PRETIME + 86400
        update_hash = {"NUM": num}
        DTIME = currentTime - preTime
        if DTIME >= 86400:
            change = {"DNUM": DNUM, "PRENUM": num, "PRETIME": currentTime}
            update_hash.update(change)
        self.logic_leaderboard.updatePlayMessage(sid, update_hash)
Ejemplo n.º 6
0
 def __init__(self, s=1):
     self.s = s
     self.logic_song = Logic_Song()
Ejemplo n.º 7
0
class songController():
    def __init__(self, s=1):
        self.s = s
        self.logic_song = Logic_Song()

    def getWordsSnamesVnamesBySid(self, List):
        logic_song = Logic_Song()
        song = logic_song.getSongsByIdList(List)[0]
        path = '../网易云音乐2/static' + song.SWORDSURL
        irc = getJsonByPath(path)
        args = {
            "IRCS": [irc],
            "URLS": [url_for('static', filename=song.SAUDIOURL[1:])],
            "SNAMES": [song.SNAME],
            "VNAMES": [song.VNAME],
        }
        return args

    def getWordsSnamesVnamesByAid(self, ID, type):
        logic_song = Logic_Song()
        if type == 'ALBUM':
            A_S = logic_song.getSongAlbumByAID(ID)
        else:
            A_S = logic_song.getSongListByLID(ID)
        songList = []
        for i in A_S:
            songList.append(i.SID)
        songs = logic_song.getSongsByIdList(songList)
        IRCS = []
        URLS = []
        SNAMES = []
        VANMES = []
        for song in songs:
            path = '../网易云音乐2/static' + song.SWORDSURL
            IRCS.append(getJsonByPath(path))
            URLS.append(url_for('static', filename=song.SAUDIOURL[1:]))
            SNAMES.append(song.SNAME)
            VANMES.append(song.VNAME)
        args = {
            "IRCS": IRCS,
            "URLS": URLS,
            "SNAMES": SNAMES,
            "VNAMES": VANMES,
            "SIDS": songList,
        }
        return args

    def getAlbumAndListMessageByAid(self, ID, type):
        logic_song = Logic_Song()
        args = {}
        if type == 'SONG':
            AOL = logic_song.getSongsByIdList([ID])[0]
            SNAMES = [AOL.SNAME]
            SAURLS = [AOL.SAUDIOURL]
            SVOCALISTS = [AOL.VNAME]
            SIDS = [AOL.ID]
            args = {
                "id": AOL.ID,
                "name": AOL.SNAME,
                "imgurl": AOL.SIMAGEURL[1:],
                "snames": SNAMES,
                "saurls": SAURLS,
                "svocalists": SVOCALISTS,
                "sids": SIDS
            }
            args.update({"type": "SONG"})
            return args
        if type == 'ALBUM':
            AOL = logic_song.getAlbumById(ID)
            args.update({"type": "ALBUM"})
            R_S = logic_song.getSongAlbumByAID(ID)

        elif type == 'LIST':
            AOL = logic_song.getListById(ID)
            args.update({"type": "LIST"})
            R_S = logic_song.getSongListByLID(ID)
        idList = []
        for i in R_S:
            idList.append(i.SID)
        songs = logic_song.getSongsByIdList(idList)

        SNAMES = []
        SAURLS = []
        SVOCALISTS = []
        SIDS = []
        for i, song in enumerate(songs):
            SNAMES.append(song.SNAME)
            SAURLS.append(song.SAUDIOURL)
            SVOCALISTS.append(song.VNAME)
            SIDS.append(song.ID)
        args.update({
            "id": ID,
            "snames": SNAMES,
            "saurls": SAURLS,
            "svocalists": SVOCALISTS,
            "sids": SIDS
        })
        args.update({
            "name": AOL.NAME,
            "imgurl": AOL.URL[1:],
        })
        return args

    # 模糊查询
    def fuzzyQuerySongs(self, s):
        song1 = self.logic_song.fuzzyQuerySongsBySname(s)
        song2 = self.logic_song.fuzzyQuerySongsByVname(s)
        songs = song1 + song2
        SNAMES = []
        SAURLS = []
        SVOCALISTS = []
        SIDS = []
        for i, song in enumerate(songs):
            SNAMES.append(song.SNAME)
            SAURLS.append(song.SAUDIOURL)
            SVOCALISTS.append(song.VNAME)
            SIDS.append(song.ID)
        args = {
            "snames": SNAMES,
            "saurls": SAURLS,
            "svocalists": SVOCALISTS,
            "sids": SIDS
        }
        return args

    #推荐内容信息
    def recommendListAndList(self, style):
        if style == '全部':
            listsIds = self.logic_song.getAllLists()
            albumsIds = self.logic_song.getAllAlbums()
        else:
            listsIds = self.logic_song.getListsByStyle(style)
            albumsIds = self.logic_song.getAlbumsByStyle(style)
        args = {"name": style}
        Lists = []
        for i, listId in enumerate(listsIds):
            arg = {}
            List = self.logic_song.getListById(listId)
            LNAME = List.NAME
            arg.update({'name': LNAME, 'id': listId, 'type': 'LIST'})
            Lists.append(arg)
        for i, albumId in enumerate(albumsIds):
            arg = {}
            Album = self.logic_song.getAlbumById(albumId)
            LNAME = Album.NAME
            arg.update({'name': LNAME, 'id': albumId, 'type': 'ALBUM'})
            Lists.append(arg)
        args.update({"lists": Lists})
        return args
Ejemplo n.º 8
0
 def __init__(self, s=1):
     self.s = s
     self.logic_users = Logic_Users()
     self.logic_song = Logic_Song()
     self.regex = re.compile('^\d{11}$')
     self.mysnow = MySnow()
Ejemplo n.º 9
0
class usersController():
    def __init__(self, s=1):
        self.s = s
        self.logic_users = Logic_Users()
        self.logic_song = Logic_Song()
        self.regex = re.compile('^\d{11}$')
        self.mysnow = MySnow()

    #判断手机号是否存在
    def isExist(self, ID):
        if self.regex.search(ID) == None:
            return False
        user = self.logic_users.getUserByID(ID)
        if len(user) >= 1:
            return True
        return False

    def usernameIsExist(self, usernamne):
        userid = self.logic_users.getUidByUserName(usernamne)
        if userid != None:
            return True
        return False

    #判断用户名密码是否匹配
    def loginSuccess(self, ID, PASSWORD):
        if ID == None:
            return False, '', 0,
        if self.regex.search(ID) == None:
            return False, '', 0, 0
        user = self.logic_users.getUserByID(ID)
        if len(user) == 0:
            return False, '', 0, 0
        user = user[0]
        if user.PASSWORD == PASSWORD:
            return True, user.NICKNAME, user.UTYPE, user.Prohibit
        return False, '', 0, 0

    #添加用户
    def addUser(self, ID, NIKENAME, PASSWORD, PROBLEM, ANSWER):
        self.logic_users.addUser(ID, NIKENAME, PASSWORD, PROBLEM, ANSWER)

    #根据用户名获取用户歌单信息
    def giveUserListMessage(self, uid):
        listsIds = self.logic_users.getListsByUid(uid)
        args = {'name': '我创建的歌单'}
        Lists = []
        for i, listId in enumerate(listsIds):

            arg = {}
            List = self.logic_song.getListById(listId)
            LNAME = List.NAME
            url = List.URL
            arg.update({'name': LNAME, 'id': listId, 'url': url})
            Lists.append(arg)
        args.update({"lists": Lists})
        return args

    #向歌单中添加歌曲
    def addSongToUserList(self, sid, lid):
        x = self.logic_song.getListSong(lid, sid)
        if len(x) != 0:
            return False
        self.logic_song.addList_Song(lid, sid)
        return True

    #获取全部用户信息
    def getAllUserMessage(self, username):
        Users = self.logic_users.getAllUser()
        Usernames = []
        Uids = []
        Utypes = []
        Uprohibits = []
        for user in Users:
            if user.NICKNAME != username:
                Usernames.append(user.NICKNAME)
                Uids.append(user.ID)
                Utypes.append(user.UTYPE)
                Uprohibits.append(user.Prohibit)
        args = {
            'Usernames': Usernames,
            'Uids': Uids,
            'Utypes': Utypes,
            'Uprohibits': Uprohibits
        }
        return args

    #删除歌单歌曲
    def deleteSongList(self, sid, lid):
        self.logic_song.delete_ListSongByLIDAndSID(lid, sid)

    #管理员与普通用户转换
    def ChangeAdminOrUser(self, username, Utype):
        self.logic_users.changeAdminOruser(username, Utype)

    #账号冻结与解冻转换
    def ChangeProhibit(self, username, Prohibit):
        self.logic_users.changeProhibit(username, Prohibit)

    #删除用户
    def deleteUser(self, username):
        ULists = self.logic_users.getUserListsByUsername(username)
        Lids = [U.LID for U in ULists]
        for lid in Lids:
            self.logic_song.delete_list(lid)
            self.logic_users.deleteUserListTable(username, lid)
        self.logic_users.deleteUser(username)

    #删除歌单
    def deleteList(self, username, lid):
        self.logic_users.deleteUserListTable(username, lid)
        self.logic_song.delete_ListSongByLID(lid)
        self.logic_song.delete_list(lid)

    def addList(self, listName, uid):
        newId = self.mysnow.get_id()
        newUrl = '/imgs/SONG/0.jpg'
        self.logic_song.addList(newId, listName, newUrl, 1)
        self.logic_users.addUserListTable(uid, newId)