Complete rewrite with Polars. No more single loop to fetch all data; posts, queued posts, drafts, and activity are all fetched separately. Extra caution when querying API to prevent HTTP 429

This commit is contained in:
2026-10-21 22:12:31 -04:00
parent ea116ee0a3
commit a23bd35001
6 changed files with 964 additions and 219 deletions

View File

@@ -1,20 +1,31 @@
# tumblr-stats
## Usage
```
usage: tumblr_stats.py [-h] -b BLOG [-t TAGS [TAGS ...]] [-i INPUT] [--after AFTER] OPERATION [OPERATION ...]
usage: tumblr_stats.py [-h] -b BLOG [-t TAGS [TAGS ...]]
[-s {none,posts,queued,drafts,activity} [{none,posts,queued,drafts,activity} ...]] [--until UNTIL]
[--since SINCE] [--queued-file QUEUED_FILE] [--drafts-file DRAFTS_FILE] [--posts-file POSTS_FILE]
[--activity-file ACTIVITY_FILE]
Use pytumblr to calculate stats after setting these enviroment variables: $TUMBLR_CONSUMER_KEY, $TUMBLR_CONSUMER_SECRET, $TUMBLR_OAUTH_TOKEN, and $TUMBLR_OAUTH_SECRET
positional arguments:
OPERATION operation used to calculate stats
Use pytumblr and Polars to calculate stats after setting these enviroment variables: $TUMBLR_CONSUMER_KEY,
$TUMBLR_CONSUMER_SECRET, $TUMBLR_OAUTH_TOKEN, and $TUMBLR_OAUTH_SECRET
options:
-h, --help show this help message and exit
-b, --blog BLOG blog name for which to calculate stats
-t, --tags TAGS [TAGS ...]
tag(s) to focus on in status (if applicable)
-i, --input INPUT Don't make API calls, just use a JSON input file
--after AFTER only gather posts after YYYY-MM-DD
tag(s) on which to filter (only affects posts)
-s, --suppress {none,posts,queued,drafts,activity} [{none,posts,queued,drafts,activity} ...]
objects to skip when aggregating data; will render some stats empty
--until UNTIL only gather posts and activity until YYYY-MM-DD
--since SINCE only fetch posts and activity since YYYY-MM-DD
--queued-file QUEUED_FILE
read queued posts from this path instead of fetching them from APIs
--drafts-file DRAFTS_FILE
read drafts from this path instead of fetching them from APIs
--posts-file POSTS_FILE
read posts from this path instead of fetching them from APIs
--activity-file ACTIVITY_FILE
read activity from this path instead of fetching it from APIs
— Be gay and do crime
```