diff --git a/jparty/borders.py b/jparty/borders.py index 3bc9e29..8fa05f5 100644 --- a/jparty/borders.py +++ b/jparty/borders.py @@ -48,10 +48,10 @@ def __flash_hints(self, key): while self.__active_thread == current_thread(): for b in self: b.show_hints(key) - time.sleep(0.5) - for b in self: - b.hide_hints(key) - time.sleep(0.5) + #time.sleep(0.5) + #for b in self: + # b.hide_hints(key) + #time.sleep(0.5) def buzz_hint(self): self.__buzz_hint_thread = Thread(target=self.__buzz_hint, name="buzz_hint") diff --git a/jparty/controller.py b/jparty/controller.py index d7b4f6c..d16cf84 100644 --- a/jparty/controller.py +++ b/jparty/controller.py @@ -152,8 +152,16 @@ def __init__(self, game): self.connected_players = [] self.accepting_players = True - def start(self, threaded=True): - self.app.listen(self.port) + def start(self, threaded=True, tries=0): + try: + self.app.listen(self.port) + except OSError as e: + if tries>10: + raise Exception("Cannot find open port") + self.port += 1 + self.start(threaded, tries+1) + return + if threaded: self.thread = Thread(target=tornado.ioloop.IOLoop.current().start) self.thread.setDaemon(True) diff --git a/jparty/main.py b/jparty/main.py index f0f8111..d8768a7 100644 --- a/jparty/main.py +++ b/jparty/main.py @@ -84,6 +84,12 @@ def main(): game.setBuzzerController(socket_controller) + try: + socket_controller.start() + except PermissionError as e: + permission_error() + exit(1) + main_window = DisplayWindow(game) host_window = HostDisplayWindow(game) game.setDisplays(host_window, main_window) @@ -96,11 +102,6 @@ def main(): song_player = game.song_player - try: - socket_controller.start() - except PermissionError as e: - permission_error() - exit(1) r=1 # fail by default diff --git a/jparty/retrieve.py b/jparty/retrieve.py index 8ac54bc..f11ef7e 100644 --- a/jparty/retrieve.py +++ b/jparty/retrieve.py @@ -1,6 +1,8 @@ import requests from bs4 import BeautifulSoup +from html import unescape import re +import json from jparty.game import Question, Board, FinalBoard, GameData import logging import csv @@ -50,14 +52,17 @@ def get_Gsheet_game(file_id): def get_game(game_id): if len(str(game_id)) < 7: - return get_JArchive_Game(game_id) + return get_wayback_jarchive_game(game_id) else: return get_Gsheet_game(str(game_id)) -def get_JArchive_Game(game_id, soup=None, is_wayback=False, wayback_url=None): +def findanswer(clue): + return re.findall(r'correct_response">(.*?)(.*?)(.*) h1")[0].contents[0] diff --git a/requirements.txt b/requirements.txt index 707b017..6565988 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ PyQt6==6.4.0 -requests==2.28.1 +requests==2.31.0 simpleaudio==1.0.4 -tornado==6.2 +tornado==6.3.2 BeautifulSoup4==4.11.1 pyinstaller==5.6.2 qrcode==7.3.1 \ No newline at end of file