feat: Use HTTP response timestamp for WaniKani summary instead of local time
This commit is contained in:
parent
cd62c9dc3f
commit
fcb8df6619
|
@ -1,5 +1,6 @@
|
||||||
import dataclasses
|
import dataclasses
|
||||||
import datetime
|
import datetime
|
||||||
|
from email.utils import parsedate_to_datetime
|
||||||
import logging
|
import logging
|
||||||
from collections.abc import Iterator, Mapping
|
from collections.abc import Iterator, Mapping
|
||||||
|
|
||||||
|
@ -88,6 +89,10 @@ class WaniKaniSummaryFetcher(Scraper):
|
||||||
total_lessons = sum(len(lesson.get('subject_ids', [])) for lesson in lessons)
|
total_lessons = sum(len(lesson.get('subject_ids', [])) for lesson in lessons)
|
||||||
|
|
||||||
reviews = data.get('data', {}).get('reviews', [])
|
reviews = data.get('data', {}).get('reviews', [])
|
||||||
|
date_hdr = response.headers.get("Date")
|
||||||
|
try:
|
||||||
|
now = parsedate_to_datetime(date_hdr) if date_hdr else datetime.datetime.now(datetime.timezone.utc)
|
||||||
|
except Exception:
|
||||||
now = datetime.datetime.now(datetime.timezone.utc)
|
now = datetime.datetime.now(datetime.timezone.utc)
|
||||||
total_reviews = 0
|
total_reviews = 0
|
||||||
for review in reviews:
|
for review in reviews:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user