diff --git a/src/util/get_tweet.py b/src/util/get_tweet.py index 855a1156..85a5b6be 100644 --- a/src/util/get_tweet.py +++ b/src/util/get_tweet.py @@ -4,11 +4,18 @@ from util.vars import get_json_data # Read curl.txt -with open("curl.txt", "r", encoding="utf-8") as file: - cURL = uncurl.parse_context("".join([line.strip() for line in file])) +try: + with open("curl.txt", "r", encoding="utf-8") as file: + cURL = uncurl.parse_context("".join([line.strip() for line in file])) +except Exception as e: + cURL = None + print("Error: Could not read curl.txt:", e) async def get_tweet(): + if cURL is None: + print("Error: no curl.txt file found. Timelines will not be updated.") + return [] result = await get_json_data( cURL.url, headers=dict(cURL.headers), diff --git a/src/util/parse_tweet.py b/src/util/parse_tweet.py index 58305374..06982f0a 100644 --- a/src/util/parse_tweet.py +++ b/src/util/parse_tweet.py @@ -67,6 +67,8 @@ def save_errored_tweet(tweet, error_msg: str): def parse_tweet(tweet: dict, update_tweet_id: bool = False): reply = None + ## TODO: split the below logic up into functions + # To be able to get the tweet and the reply if "items" in tweet.keys(): reply = tweet["items"][1]["item"]["itemContent"]["tweet_results"] diff --git a/src/util/yf_data.py b/src/util/yf_data.py index ff751f12..800af797 100644 --- a/src/util/yf_data.py +++ b/src/util/yf_data.py @@ -12,9 +12,9 @@ from util.tv_data import tv -async def yf_info(ticker: str, do_format_change: bool = True): +def yf_info(ticker: str, do_format_change: bool = True): # try: - stock_info = await Ticker(ticker, asynchronous=True).price + stock_info = Ticker(ticker, asynchronous=True).price # Test if the ticker is valid if not isinstance(stock_info.get(ticker), dict): @@ -88,7 +88,7 @@ async def get_stock_info( """ if asset_type == "stock": - stock_info = await yf_info(ticker, do_format_change) + stock_info = yf_info(ticker, do_format_change) if stock_info: return stock_info