From f5a0eecc7361cde106f08d1e889be8ceb1fe850b Mon Sep 17 00:00:00 2001 From: "Jon Michael Aanes (aider)" Date: Sun, 16 Mar 2025 15:12:52 +0100 Subject: [PATCH] feat: Extend assignment output to include subject characters from API --- personal_data/fetchers/wanikani_lessons.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/personal_data/fetchers/wanikani_lessons.py b/personal_data/fetchers/wanikani_lessons.py index 0aa2e6f..90dae07 100644 --- a/personal_data/fetchers/wanikani_lessons.py +++ b/personal_data/fetchers/wanikani_lessons.py @@ -27,5 +27,13 @@ class WaniKaniLessonsFetcher(Scraper): json_resp = response.json() for assignment in json_resp.get('data', []): data_item = assignment['data'] + subject_id = data_item.get("subject_id") + if subject_id: + subj_url = f'https://api.wanikani.com/v2/subjects/{subject_id}' + subj_response = self.session.get(subj_url, headers=headers) + subj_response.raise_for_status() + subj_json = subj_response.json() + subject_characters = subj_json.get("data", {}).get("characters") + data_item["subject_characters"] = subject_characters yield data_item url = json_resp.get('pages', {}).get('next_url')