Exemple #1
0
            print("Server response not JSON, retrying...")
            time.sleep(1)
            continue

        logging.info(response_data)

        if "broadcast" not in response_data or response_data[
                "broadcast"] is None:
            if "error" in response_data and response_data[
                    "error"] == "Auth not valid":
                raise RuntimeError("Connection settings invalid")
            else:
                print("Show not on.")
                next_time = datetime.strptime(response_data["nextShowTime"],
                                              "%Y-%m-%dT%H:%M:%S.000Z")
                now = time.time()
                offset = datetime.fromtimestamp(
                    now) - datetime.utcfromtimestamp(now)

                print(
                    f"Next show time: {(next_time + offset).strftime('%Y-%m-%d %I:%M %p')}"
                )
                print("Prize: " + response_data["nextShowPrize"])
                time.sleep(20)
        else:
            socket = response_data["broadcast"]["socketUrl"].replace(
                "https", "wss")
            print(f"Show active, connecting to socket at {socket}")
            asyncio.get_event_loop().run_until_complete(
                networking.websocket_handler(socket, headers))
Exemple #2
0
    except:
        print("Server response not JSON, retrying...")
        time.sleep(1)
        continue

    logging.info(response_data)

    if "broadcast" not in response_data or response_data["broadcast"] is None:
        if "error" in response_data and response_data[
                "error"] == "Auth not valid":
            raise RuntimeError("Connection settings invalid")
        else:
            print("Show not on.")
            next_time = datetime.strptime(response_data["nextShowTime"],
                                          "%Y-%m-%dT%H:%M:%S.000Z")
            now = time.time()
            offset = datetime.fromtimestamp(now) - datetime.utcfromtimestamp(
                now)

            print(
                f"Next show time: {(next_time + offset).strftime('%Y-%m-%d %I:%M %p')}"
            )
            print("Prize: " + response_data["nextShowPrize"])
            time.sleep(5)
    else:
        socket = response_data["broadcast"]["socketUrl"].replace(
            "https", "wss")
        print(f"Show active, connecting to socket at {socket}")
        asyncio.get_event_loop().run_until_complete(
            networking.websocket_handler(socket, headers, driver))
Exemple #3
0
# "x-hq-stk": "MQ==",
# "Connection": "Keep-Alive",
# "User-Agent": "okhttp/3.8.0"}

while True:
    print()
    try:
        response_data = asyncio.get_event_loop().run_until_complete(
            networking.get_json_response(main_url, timeout=1.5, headers=headers))
    except:
        print("Server response not JSON, retrying...")
        time.sleep(1)
        continue

    if "broadcast" not in response_data or response_data["broadcast"] is None:
        if "error" in response_data and response_data["error"] == "Auth not valid":
            raise RuntimeError("Connection settings invalid")
        else:
            print("Show not on.")
            next_time = datetime.strptime(response_data["nextShowTime"], "%Y-%m-%dT%H:%M:%S.000Z")
            now = time.time()
            offset = datetime.fromtimestamp(now) - datetime.utcfromtimestamp(now)

            print(f"Next show time: {(next_time + offset).strftime('%Y-%m-%d %I:%M %p')}")
            print("Prize: " + response_data["nextShowPrize"])
            time.sleep(5)
    else:
        socket = response_data["broadcast"]["socketUrl"].replace("https", "wss")
        print(f"Show active, connecting to socket at {socket}")
        asyncio.get_event_loop().run_until_complete(networking.websocket_handler(socket, headers))
        continue

    if "broadcast" not in response_data or response_data["broadcast"] is None:
        if "error" in response_data and response_data[
                "error"] == "Auth not valid":
            raise RuntimeError("Connection settings invalid")
        else:
            print("Show not on.")
            next_time = datetime.strptime(response_data["nextShowTime"],
                                          "%Y-%m-%dT%H:%M:%S.000Z")
            now = time.time()
            offset = datetime.fromtimestamp(now) - datetime.utcfromtimestamp(
                now)
            print(
                f"Next show time: {(next_time + offset).strftime('%Y-%m-%d %I:%M %p')}"
            )
            print("Prize: " + response_data["nextShowPrize"])
            time.sleep(6)
    else:
        socket = response_data["broadcast"]["socketUrl"].replace(
            "https", "wss")
        print(f"Show active, connecting to socket at {socket}")
        data = asyncio.get_event_loop().run_until_complete(
            asyncio.gather(networking.websocket_handler(socket, headers)))
        print(data)
        if data == None:
            continue
        print(data)
        with open('data.json', 'w') as outfile:
            json.dump(data[0], outfile)