diff --git a/README.md b/README.md index 480ba47..2001f63 100644 --- a/README.md +++ b/README.md @@ -17,10 +17,11 @@ This is created as a workaround (just in ICS rather than RSS) for personal use a The results should be similar to the one you would see in [this release query on VNDB](https://vndb.org/r?f=0672171_4YsVe132gja2wzh_dHans-2wzh_dHant-N48721gwcomplete-N480281UJ81Xkx), except that I expand the release window 14 days earlier to avoid missing VNs. To customize the query, run the script with optional parameters: -- `python vndb-calendar.py -f {customized_compact_filter} -p {max_page}` -- Example of generic filters for en & ja releases: `python vndb-calendar.py -f "0572171_4YsVe122gen2gjaN48721gwcomplete-"` +- `python vndb-calendar.py -f {customized_compact_filter} -p {max_page} -t {shift_time}` +- Example of generic filters for en & ja upcoming releases: `python vndb-calendar.py -f "0572171_4YsVe122gen2gjaN48721gwcomplete-" -t 0` - `-f` or `--filter`: your custom [compact filters](https://api.vndb.org/kana#filters), by default it would use my personalized one - `-p` or `--max-page`: maximum pages of query results, by default it will be `2` +- `-t` or `--shift-time`: show *new* releases X days ago, it's really upcoming release if set to `0`, by default it will be `14` ## Todo diff --git a/README_zh-Hans.md b/README_zh-Hans.md index 95c461a..b2f2f39 100644 --- a/README_zh-Hans.md +++ b/README_zh-Hans.md @@ -22,6 +22,7 @@ VNDB 目前只对 *Recent Changes* 提供 RSS,*Upcoming Releases* 和 *Just Re - 以中日视觉小说为例:`python vndb-calendar.py -f "0572171_4YsVe132gja2wzh_dHans-2wzh_dHant-N48721gwcomplete-"` - `-f` 或 `--filter`:自定义 [compact filters](https://api.vndb.org/kana#filters),默认为我高度自定义的个人方案 - `-p` 或 `--max-page`:搜索结果的最大页数,默认为 `2` +- `-t` 或 `--shift-time`:显示 X 天前发售到尚未发售的视觉小说,设置为 `0` 才是真正的「即将发售作品」,默认为 `14` ## Todo diff --git a/vndb-calendar.py b/vndb-calendar.py index 7d133c4..6267635 100644 --- a/vndb-calendar.py +++ b/vndb-calendar.py @@ -159,6 +159,14 @@ default=2, help="max pages of query results", ) +parser.add_argument( + "-t", + "--shift-time", + type=int, + required=False, + default=None, + help='show "new" releases X days ago, it\'s really upcoming release if set to 0', +) args = parser.parse_args() @@ -172,7 +180,13 @@ def get_page(max_page, data): for page in range(1, max_page + 1): data["page"] = page - data["filters"] = args.filter + if args.shift_time: + _SHIFT_TIME_NEW = ( + datetime.now() - timedelta(days=args.shift_time) + ).strftime("%Y-%m-%d") + data["filters"] = args.filter.replace(_SHIFT_TIME, _SHIFT_TIME_NEW) + else: + data["filters"] = args.filter response = requests.post(api_url, data=json.dumps(data), headers=headers) if response.status_code == 200: