Skip to content

Commit

Permalink
Merge pull request #11 from crossjam/feature-implement-feed-metadata-…
Browse files Browse the repository at this point in the history
…subcommand-3

Implement feed metadata subcommand
  • Loading branch information
crossjam authored Oct 27, 2023
2 parents 8d86b8a + c6b7975 commit f50f69e
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions feedbin_tools/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,3 +365,30 @@ def entries(
item["x-read-status"] = params["read"]
sys.stdout.write(json.dumps(item) + "\n")
total_emitted += 1


@cli.command(name="feedmeta", short_help="Retrieve feed metadata")
@click.argument("feed_ids", type=click.INT, nargs=-1)
@click.pass_context
def feed(ctx, feed_ids):
"""
Retrieve the feed information for each ID in FEED_IDS
Emit data in JSONL
"""

auth = auth_from_context(ctx)

for feed_id in feed_ids:
url = f"https://api.feedbin.com/v2/feeds/{feed_id}.json"
session = requests_cache.CachedSession()

resp = session.get(url, auth=auth)
resp.raise_for_status()

sys.stdout.write(json.dumps(resp.json()) + "\n")

try:
sys.stdout.close()
except IOError:
pass

0 comments on commit f50f69e

Please sign in to comment.