Skip to content

Commit

Permalink
Add shift time arg
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinfall committed Jan 18, 2024
1 parent acc700b commit 0e9f689
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions README_zh-Hans.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
16 changes: 15 additions & 1 deletion vndb-calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()


Expand All @@ -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:
Expand Down

0 comments on commit 0e9f689

Please sign in to comment.