Skip to content

Commit

Permalink
hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
StephanAkkerman committed Mar 21, 2024
1 parent b8fd03a commit 66c9015
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
11 changes: 9 additions & 2 deletions src/util/get_tweet.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 2 additions & 0 deletions src/util/parse_tweet.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
6 changes: 3 additions & 3 deletions src/util/yf_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 66c9015

Please sign in to comment.