From 9060fcecac22cf0dcc3c364b0e3f909d1c594f1a Mon Sep 17 00:00:00 2001 From: Claromes Date: Sat, 20 Jul 2024 16:35:44 -0300 Subject: [PATCH] improve description and fix IndexError --- app/app.py | 22 +++++++++------------- docs/index.rst | 4 ++-- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/app/app.py b/app/app.py index 6e68929..c045a0a 100644 --- a/app/app.py +++ b/app/app.py @@ -170,14 +170,14 @@ def scroll_page(): 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 @@ def scroll_page(): 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 @@ def scroll_page(): 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 @@ def scroll_page(): 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() diff --git a/docs/index.rst b/docs/index.rst index 300dec9..23922ec 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -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.