improve description and fix IndexError
authorClaromes <claromes@hey.com>
Sat, 20 Jul 2024 19:35:44 +0000 (16:35 -0300)
committerClaromes <claromes@hey.com>
Sat, 20 Jul 2024 19:35:44 +0000 (16:35 -0300)
app/app.py
docs/index.rst

index 6e68929e53942e55656cc9d3cf4a7e215d8d2c07..c045a0a141ab3c7fecba695d0ac293e4fcd85028 100644 (file)
@@ -170,14 +170,14 @@ if st.query_params.username != "":
 
 st.image(TITLE, use_column_width="never")
 st.caption(
-    "[![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/v/release/claromes/waybacktweets?include_prereleases)](https://github.com/claromes/waybacktweets/releases) [![sponsor](https://img.shields.io/badge/Donate-via%20Sponsors-ff69b4.svg?logo=github)](https://github.com/sponsors/claromes)"  # noqa: E501
+    "[![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/v/release/claromes/waybacktweets?include_prereleases)](https://github.com/claromes/waybacktweets/releases) [![read the documentation](https://img.shields.io/badge/read_the-documentation-0a507a?logo=sphinx)](https://claromes.github.io/waybacktweets) [![sponsors](https://img.shields.io/badge/donate-via%20sponsors-ff69b4.svg?logo=github)](https://github.com/sponsors/claromes)"  # noqa: E501
 )
 st.write(
-    "Retrieves archived tweets CDX data in HTML (for easy viewing of the tweets using the iframe tag), CSV, and JSON formats."  # noqa: E501
+    "Retrieves archived tweets CDX data in HTML (for easy viewing of the tweets), CSV, and JSON formats."  # noqa: E501
 )
 
 st.write(
-    "This application uses the Wayback Tweets Python package, which can be used either as a module or as a standalone command-line tool. [Read the documentation](https://claromes.github.io/waybacktweets) for more information."  # noqa: E501
+    "For better performance, use the CLI version, available on [PyPI](https://pypi.org/project/waybacktweets)."  # noqa: E501
 )
 
 st.write(
@@ -246,18 +246,11 @@ if st.query_params.username == "":
 if username != st.session_state.current_username:
     st.session_state.current_username = username
 
-if st.session_state.query or st.session_state.count:
+if (st.session_state.query and username) or st.session_state.count:
     if unique:
         collapse = "urlkey"
         matchtype = "prefix"
 
-    start_timestamp = None
-    end_timestamp = None
-
-    if st.session_state.archived_timestamp_filter:
-        start_timestamp = st.session_state.archived_timestamp_filter[0]
-        end_timestamp = st.session_state.archived_timestamp_filter[1]
-
     try:
         with st.spinner(
             f"Waybacking @{st.session_state.current_username}'s archived tweets"
@@ -265,8 +258,8 @@ if st.session_state.query or st.session_state.count:
             wayback_tweets = wayback_tweets(
                 st.session_state.current_username,
                 collapse,
-                start_timestamp,
-                end_timestamp,
+                st.session_state.archived_timestamp_filter[0],
+                st.session_state.archived_timestamp_filter[1],
                 limit,
                 offset,
                 matchtype,
@@ -370,6 +363,9 @@ if st.session_state.query or st.session_state.count:
         If the problem persists [open an issue](https://github.com/claromes/waybacktweets/issues)."""  # noqa: E501
         )
         st.stop()
+    except IndexError:
+        st.error("Please check if you have entered a date range in the filter.")
+        st.stop()
     except Exception as e:
         st.error(str(e))
         st.stop()
index 300dec95475d5cc427363f8e09d6ec2b20fd03e5..23922ec2899e25a40df9f1bdc59214be378f6ffc 100644 (file)
@@ -11,9 +11,9 @@ Pre-release: |release|
 
 Retrieves archived tweets CDX data from the Wayback Machine, performs necessary parsing (see :ref:`field_options`), and saves the data in HTML, for easy viewing of the tweets using the iframe tags, CSV, and JSON formats.
 
-.. image:: https://img.shields.io/badge/Donate-via%20Sponsors-ff69b4.svg?logo=github
+.. image:: https://img.shields.io/badge/donate-via%20sponsors-ff69b4.svg?logo=github
   :target: https://github.com/sponsors/claromes
-  :alt: GitHub Sponsors
+  :alt: sponsors
 
 .. note::
     Intensive queries can lead to rate limiting, resulting in a temporary ban of a few minutes from web.archive.org.