From e05c7fefabb983224c9a3fde63ca6246332214e9 Mon Sep 17 00:00:00 2001 From: Claromes Date: Tue, 16 Jul 2024 19:08:45 -0300 Subject: [PATCH] update module viz - add get method --- waybacktweets/api/visualize.py | 40 ++++++++++++++++------------------ 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/waybacktweets/api/visualize.py b/waybacktweets/api/visualize.py index 93ad80a..bb4def0 100644 --- a/waybacktweets/api/visualize.py +++ b/waybacktweets/api/visualize.py @@ -114,12 +114,12 @@ class HTMLTweetsVisualizer: tweet = self.json_path[index] html += '
\n' - if not tweet["available_tweet_text"]: + if not tweet.get("available_tweet_text"): iframe_src = { - "Archived Tweet": tweet["archived_tweet_url"], - "Parsed Archived Tweet": tweet["parsed_archived_tweet_url"], - "Original Tweet": tweet["original_tweet_url"], - "Parsed Tweet": tweet["parsed_tweet_url"], + "Archived Tweet": tweet.get("archived_tweet_url"), + "Parsed Archived Tweet": tweet.get("parsed_archived_tweet_url"), + "Original Tweet": tweet.get("original_tweet_url"), + "Parsed Tweet": tweet.get("parsed_tweet_url"), } for key, value in iframe_src.items(): @@ -149,25 +149,23 @@ class HTMLTweetsVisualizer: index=index, url=value, key_cleaned=key_cleaned ) - if tweet["available_tweet_text"]: + if tweet.get("available_tweet_text"): html += "
\n" - html += f'

Available Tweet Content: {tweet["available_tweet_text"]}

\n' - html += f'

Available Tweet Is Retweet: {tweet["available_tweet_is_RT"]}

\n' - html += f'

Available Tweet Username: {tweet["available_tweet_info"]}

\n' + html += f'

Available Tweet Content: {tweet.get("available_tweet_text")}

\n' + html += f'

Available Tweet Is Retweet: {tweet.get("available_tweet_is_RT")}

\n' + html += f'

Available Tweet Username: {tweet.get("available_tweet_info")}

\n' html += "
\n" - html += f'

Archived Tweet: {tweet["archived_tweet_url"]}

\n' - html += f'

Parsed Archived Tweet: {tweet["parsed_archived_tweet_url"]}

\n' - html += f'

Original Tweet: {tweet["original_tweet_url"]}

\n' - html += f'

Parsed Tweet: {tweet["parsed_tweet_url"]}

\n' - html += f'

Archived URL Key: {tweet["archived_urlkey"]}

\n' - html += f'

Archived Timestamp: {timestamp_parser(tweet["archived_timestamp"])} ({tweet["archived_timestamp"]})

\n' - html += f'

Archived mimetype: {tweet["archived_mimetype"]}

\n' - html += f'

Archived Statuscode: {tweet["archived_statuscode"]}

\n' - html += ( - f'

Archived Digest: {tweet["archived_digest"]}\n' - ) - html += f'

Archived Length: {tweet["archived_length"]}

\n' + html += f'

Archived Tweet: {tweet.get("archived_tweet_url")}

\n' + html += f'

Parsed Archived Tweet: {tweet.get("parsed_archived_tweet_url")}

\n' + html += f'

Original Tweet: {tweet.get("original_tweet_url")}

\n' + html += f'

Parsed Tweet: {tweet.get("parsed_tweet_url")}

\n' + html += f'

Archived URL Key: {tweet.get("archived_urlkey")}

\n' + html += f'

Archived Timestamp: {timestamp_parser(tweet.get("archived_timestamp"))} ({tweet.get("archived_timestamp")})

\n' + html += f'

Archived mimetype: {tweet.get("archived_mimetype")}

\n' + html += f'

Archived Statuscode: {tweet.get("archived_statuscode")}

\n' + html += f'

Archived Digest: {tweet.get("archived_digest")}\n' + html += f'

Archived Length: {tweet.get("archived_length")}

\n' html += "
\n" html += "\n\n" # Closes the page div and the container -- 2.34.1