Beispiel #1
0
def updateStatus(no, konamiId, status, error=None):
    db = mysqlConnect()
    cursor = db.cursor()

    if error == None:
        cursor.execute(
            "UPDATE `azuinfo_waiting` SET `status`=%s WHERE `id`=%s",
            (status, no))
    else:
        cursor.execute(
            "UPDATE `azuinfo_waiting` SET `status`=%s, `error`=%s WHERE `id`=%s",
            (status, error, no))

    cursor.close()
    mysqlClose(db, True)

    if status == 1 or status == 2:
        target = "start"

        if status == 2:
            target = "end"

        db = mysqlConnect()
        cursor = db.cursor()
        cursor.execute(
            "UPDATE `azuinfo_waiting` SET `" + target + "`=%s WHERE `id`=%s",
            (int(time.time()), no))
        cursor.close()
        mysqlClose(db, True)

    if status == 2:
        tools.delRefreshdata(konamiId)
Beispiel #2
0
def cookie2session(cookie, returntype):
    output = {}

    with tools.getRequester() as requester:
        req = requester.get(
            "http://p.eagate.573.jp/gate/p/mypage/index.html",
            cookies=requests.utils.cookiejar_from_dict({"M573SSID": cookie}),
            headers={
                "User-Agent":
                "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0"
            })
    data = req.content.decode("SHIFT-JIS")
    konamiId = BeautifulSoup(data, "lxml").find("p", {"class": "id_text"})

    if konamiId == None:
        output = {"resCode": -1, "res": "Invalid Cookie"}
    else:
        konamiId = konamiId.get_text().strip()

        if konamiId == tools.MASTERID:
            tools.setMaster(cookie)
            session = tools.MASTER
        else:
            session = tools.appendSession(cookie, konamiId)

        user = tools.getUserdata(konamiId)

        if user == None:
            db = mysqlConnect()
            cursor = db.cursor()
            cursor.execute(
                "INSERT INTO `azuinfo_user` (`konamiId`) VALUES (%s)",
                (konamiId))
            cursor.close()
            mysqlClose(db, True)

        output = {
            "resCode": 0,
            "res": "success",
            "konamiId": konamiId,
            "session": session
        }

    return Response(dict2jsonp(output, request.args.get("callback"))
                    if returntype == "jsonp" else json.dumps(output),
                    mimetype="application/javascript"
                    if returntype == "jsonp" else "application/json",
                    headers={"Access-Control-Allow-Origin": "*"})
Beispiel #3
0
def setNickname(session, returntype):
    output = {}

    konamiId = tools.session2konamiId(session)

    if konamiId == False:
        output = {"resCode": -2, "res": "Invalid Session"}
    else:
        user = tools.getUserdata(konamiId)

        nickname = request.form.get("nickname")

        if nickname == None:
            output = {"resCode": -3, "res": "Empty Nickname"}
        else:
            if re.match("^[A-Za-z0-9_]+$", nickname):
                db = mysqlConnect()
                cursor = db.cursor()
                cursor.execute(
                    "SELECT * FROM `azuinfo_user` WHERE `nickname`=%s",
                    (nickname))
                chk = cursor.fetchone()
                cursor.close()

                if chk == None:
                    cursor = db.cursor()
                    cursor.execute(
                        "UPDATE `azuinfo_user` SET `nickname`=%s WHERE `id`=%s",
                        (nickname, user[0]))
                    cursor.close()
                    mysqlClose(db, True)

                    output = {"resCode": 0, "res": "success"}
                else:
                    mysqlClose(db)

                    output = {"resCode": -4, "res": "Already used Nickname"}

            else:
                output = {"resCode": -5, "res": "Invalid Nickname Form"}

    return Response(dict2jsonp(output, request.args.get("callback"))
                    if returntype == "jsonp" else json.dumps(output),
                    mimetype="application/javascript"
                    if returntype == "jsonp" else "application/json",
                    headers={"Access-Control-Allow-Origin": "*"})
Beispiel #4
0
def getHistory(session, returntype):
    output = {}

    konamiId = tools.session2konamiId(session)

    if konamiId == False:
        output = {"resCode": -2, "res": "Invalid Session"}
    else:
        user = tools.getUserdata(konamiId)

        if user == None:
            output = {"resCode": -2, "res": "Invalid Session"}
        else:
            db = mysqlConnect()
            cursor = db.cursor()
            cursor.execute(
                "SELECT * FROM `azuinfo_waiting` WHERE `owner`=%s ORDER BY `id` DESC LIMIT 0,10",
                (user[0]))
            chk = cursor.fetchall()
            cursor.close()
            mysqlClose(db)

            output = {"resCode": 0, "res": "success", "data": []}

            for data in chk:
                output["data"].append({
                    "id": data[0],
                    "device": data[2],
                    "status": data[3],
                    "swap": data[4],
                    "error": data[5],
                    "request": data[6],
                    "start": data[7],
                    "end": data[8]
                })

    return Response(dict2jsonp(output, request.args.get("callback"))
                    if returntype == "jsonp" else json.dumps(output),
                    mimetype="application/javascript"
                    if returntype == "jsonp" else "application/json",
                    headers={"Access-Control-Allow-Origin": "*"})
Beispiel #5
0
                while True:
                    db = mysqlConnect()
                    cursor = db.cursor()
                    cursor.execute(
                        "SELECT * FROM `azuinfo_popn_song` WHERE `uniq`=%s",
                        (uniq))
                    chk = cursor.fetchone()
                    cursor.close()

                    if chk == None:
                        cursor = db.cursor()
                        cursor.execute(
                            "INSERT INTO `azuinfo_popn_song` (`uniq`,`title`,`genre`) VALUES (%s,%s,%s)",
                            (uniq, title, genre))
                        cursor.close()
                        mysqlClose(db, True)
                    else:
                        mysqlClose(db)
                        break

                diff = song.contents[3].get_text().strip()
                score = int(song.contents[7].contents[2])
                meda = "l"

                if score != 0:
                    try:
                        meda = song.contents[7].contents[0].get(
                            "src")[:-4][28:]
                    except:
                        pass
Beispiel #6
0
def requestRefresh(session, returntype):
    output = {}

    konamiId = tools.session2konamiId(session)

    if konamiId == False:
        output = {"resCode": -2, "res": "Invalid Session"}
    else:
        card = tools.getCard(konamiId)

        if card == False:
            output = {"resCode": -2, "res": "Invalid Session"}
        elif card == None:
            output = {"resCode": -9, "res": "No Card"}
        else:
            if card != request.form.get("card"):
                output = {"resCode": -10, "res": "Card Not Matched"}
            else:
                password = request.form.get("password")

                if password == None:
                    password = ""

                if re.match("^[0-9]+$", password) and len(password) == 4:
                    device = request.form.get("device")

                    if device == None:
                        device = ""

                    if re.match("^[0-9]+$", device):
                        device = int(device)
                        swap = 0

                        if request.form.get("swap") == "1":
                            swap = 1

                        user = tools.getUserdata(konamiId)

                        db = mysqlConnect()
                        cursor = db.cursor()
                        cursor.execute(
                            "SELECT * FROM `azuinfo_waiting` WHERE `owner`=%s ORDER BY `id` DESC LIMIT 0,1",
                            (user[0]))
                        chk = cursor.fetchone()
                        cursor.close()
                        mysqlClose(db)

                        visit = False

                        if chk == None:
                            visit = True
                        else:
                            if chk[3] == 2:
                                visit = True
                            else:
                                output = {
                                    "resCode": -11,
                                    "res": "Already Requested"
                                }

                        if visit:
                            tools.setRefreshdata(card, password, konamiId)

                            db = mysqlConnect()
                            cursor = db.cursor()
                            cursor.execute(
                                "INSERT INTO `azuinfo_waiting` (`owner`,`device`,`status`,`swap`,`request`) VALUES (%s,%s,0,%s,%s)",
                                (user[0], device, swap, int(time.time())))
                            cursor.close()
                            mysqlClose(db, True)

                            output = {"resCode": 0, "res": "success"}

                    else:
                        output = {"resCode": -12, "res": "Invalid Device Form"}
                else:
                    output = {"resCode": -13, "res": "Invalid Password Form"}

    return Response(dict2jsonp(output, request.args.get("callback"))
                    if returntype == "jsonp" else json.dumps(output),
                    mimetype="application/javascript"
                    if returntype == "jsonp" else "application/json",
                    headers={"Access-Control-Allow-Origin": "*"})
Beispiel #7
0
def getMetadata(device, returntype):
    output = {}

    if device in ["sdvx", "popn"]:
        output["data"] = {}

        if device == "sdvx":
            db = mysqlConnect()
            cursor = db.cursor()
            cursor.execute("SELECT * FROM `azuinfo_sdvx_song`")

            chk = cursor.fetchone()
            while chk != None:
                output["data"][chk[1]] = {
                    "title": chk[2],
                    "artist": chk[3],
                    "effector_nov": chk[4],
                    "effector_adv": chk[5],
                    "effector_exh": chk[6],
                    "illustrator_nov": chk[9],
                    "illustrator_adv": chk[10],
                    "illustrator_exh": chk[11],
                    "grv": chk[14],
                    "nov": chk[15],
                    "adv": chk[16],
                    "exh": chk[17],
                    "albumart_nov": chk[20],
                    "albumart_adv": chk[21],
                    "albumart_exh": chk[22]
                }

                if chk[14] != None:
                    output["data"][chk[1]]["effector_inf"] = chk[8]
                    output["data"][chk[1]]["illustrator_inf"] = chk[13]
                    output["data"][chk[1]]["inf"] = chk[19]
                    output["data"][chk[1]]["albumart_inf"] = chk[24]

                if chk[18] != None:
                    output["data"][chk[1]]["effector_mxm"] = chk[7]
                    output["data"][chk[1]]["illustrator_mxm"] = chk[12]
                    output["data"][chk[1]]["mxm"] = chk[18]
                    output["data"][chk[1]]["albumart_mxm"] = chk[23]

                chk = cursor.fetchone()

            cursor.close()
            mysqlClose(db)
        elif device == "popn":
            db = mysqlConnect()
            cursor = db.cursor()
            cursor.execute("SELECT * FROM `azuinfo_popn_song`")

            chk = cursor.fetchone()
            while chk != None:
                output["data"][chk[1]] = {
                    "title": chk[2],
                    "genre": chk[3],
                    "artist": chk[4],
                    "easy": chk[5],
                    "normal": chk[6],
                    "hyper": chk[7],
                    "ex": chk[8]
                }

                chk = cursor.fetchone()

            cursor.close()
            mysqlClose(db)
    else:
        output = {"resCode": -8, "res": "Invalid Device"}

    return Response(dict2jsonp(output, request.args.get("callback"))
                    if returntype == "jsonp" else json.dumps(output),
                    mimetype="application/javascript"
                    if returntype == "jsonp" else "application/json",
                    headers={"Access-Control-Allow-Origin": "*"})
Beispiel #8
0
    while True:
        hour = time.localtime().tm_hour

        if hour >= 4 and hour < 8:
            time.sleep(300)
            continue

        db = mysqlConnect()
        cursor = db.cursor()
        cursor.execute(
            "SELECT * FROM `azuinfo_waiting` WHERE `status`=0 AND `swap`=1 ORDER BY `id` ASC LIMIT 0,1"
        )
        chk = cursor.fetchone()
        cursor.close()
        mysqlClose(db)

        if chk == None:
            if lastReq + 300 <= int(time.time()):
                if tools.validateSession(tools.MASTERID) == False:
                    uploadNotify()
                    sys.exit()
                else:
                    lastReq = int(time.time())

            time.sleep(1)
            continue

        if tools.validateSession(tools.MASTERID) == False:
            uploadNotify()
            sys.exit()