Skip to content

Commit

Permalink
Initial implementation of --since argument in entries
Browse files Browse the repository at this point in the history
  • Loading branch information
crossjam committed Oct 18, 2023
1 parent dfb3cfe commit 67a16c0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
13 changes: 13 additions & 0 deletions feedbin_tools/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@


import click
from dateparser import parse as dtparse

from .logconfig import DEFAULT_LOG_FORMAT, logging_config

Expand Down Expand Up @@ -254,6 +255,7 @@ def feed(ctx, feed_id, extended, limit):
@click.option("--extended/--no-extended", default=False)
@click.option("--limit", type=click.INT, default=-1)
@click.option("-b", "--per-page", type=click.INT, default=75)
@click.option("--since", type=click.STRING, default="")
@click.option("--include-original/--no-include-original", default=False)
@click.option("--include-enclosure/--no-include-enclosure", default=False)
@click.option("--include-content-diff/--no-include-content-diff", default=False)
Expand All @@ -265,6 +267,7 @@ def entries(
extended,
limit,
per_page,
since,
include_original,
include_enclosure,
include_content_diff,
Expand All @@ -285,6 +288,16 @@ def entries(
params["include_enclosure"] = json_bool(include_enclosure)
params["include_content_diff"] = json_bool(include_content_diff)

if since:
dt = dtparse(
since, settings={"TO_TIMEZONE": "UTC", "RETURN_AS_TIMEZONE_AWARE": True}
)
if not dt:
logging.error("Failed to parse since %s as a date time", since)
raise ValueError(f"Unrecognized dateparser input string: '{since}'")
else:
logging.info("Retrieving entries after: %s", dt.isoformat())

logging.info("Request params: %s", params)

total_emitted = 0
Expand Down
5 changes: 5 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,17 @@ zip_safe = True
include_package_data = True
install_requires =
click
dateparser
pyrate-limiter
requests
requests-cache
stamina
tenacity
keyring

[options.extras_require]
test = pytest
requests-mock


[options.entry_points]
Expand Down

0 comments on commit 67a16c0

Please sign in to comment.