From 600399e82a99de6788ea9b6117bf4aa7219998b0 Mon Sep 17 00:00:00 2001 From: Adi Sai Date: Wed, 11 Oct 2023 23:11:44 -0700 Subject: [PATCH 1/2] tweaks for monetization --- openbb_terminal/common/ultima_newsmonitor_model.py | 6 +++++- openbb_terminal/common/ultima_newsmonitor_view.py | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/openbb_terminal/common/ultima_newsmonitor_model.py b/openbb_terminal/common/ultima_newsmonitor_model.py index 656ba75c53fd..b648a10ae974 100644 --- a/openbb_terminal/common/ultima_newsmonitor_model.py +++ b/openbb_terminal/common/ultima_newsmonitor_model.py @@ -230,6 +230,10 @@ def get_top_headlines(ticker: str) -> dict: ): # If data request failed console.print("[red]Status code not 200. Unable to retrieve data\n[/red]") return {} - return data.json() + json = data.json() + if 'message' in json: + console.print(f"[red]{json['message']}[/red]") + return {} + return json console.print("[red]Ticker not supported. Unable to retrieve data\n[/red]") return {} diff --git a/openbb_terminal/common/ultima_newsmonitor_view.py b/openbb_terminal/common/ultima_newsmonitor_view.py index 539670e5bb6f..df3afa02f4da 100644 --- a/openbb_terminal/common/ultima_newsmonitor_view.py +++ b/openbb_terminal/common/ultima_newsmonitor_view.py @@ -76,7 +76,11 @@ def display_news( console.print(row["URL"] + "\n") console.print("------------------------") - top_headlines = ultima_newsmonitor_model.get_top_headlines(term)["summary"] + top_headlines = ultima_newsmonitor_model.get_top_headlines(term) + if "summary" in top_headlines: + top_headlines = top_headlines["summary"] + else: + return if "Ultima Insights was unable to identify" in top_headlines: console.print( f"[red]Most Relevant Articles for {term} - {dt.datetime.now().strftime('%Y-%m-%d')}\n{top_headlines}[/red]" From 6a57a8fcc7b3528125c530c2e3e2c3f8432e8a3e Mon Sep 17 00:00:00 2001 From: Adi Sai Date: Wed, 11 Oct 2023 23:19:28 -0700 Subject: [PATCH 2/2] fix linting issue --- openbb_terminal/common/ultima_newsmonitor_model.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openbb_terminal/common/ultima_newsmonitor_model.py b/openbb_terminal/common/ultima_newsmonitor_model.py index b648a10ae974..9b74c89aa631 100644 --- a/openbb_terminal/common/ultima_newsmonitor_model.py +++ b/openbb_terminal/common/ultima_newsmonitor_model.py @@ -231,7 +231,7 @@ def get_top_headlines(ticker: str) -> dict: console.print("[red]Status code not 200. Unable to retrieve data\n[/red]") return {} json = data.json() - if 'message' in json: + if "message" in json: console.print(f"[red]{json['message']}[/red]") return {} return json