From b25170296e235c39f0c72f436a7cf0924453fc74 Mon Sep 17 00:00:00 2001 From: "Prof. Dr. Matthias Jung DL9MJ" Date: Fri, 16 May 2025 16:18:49 +0200 Subject: [PATCH] feature: download fotos added --- .gitignore | 1 + api/download.py | 13 +++++++++++++ build.py | 1 + 3 files changed, 15 insertions(+) diff --git a/.gitignore b/.gitignore index 5a5a389..060dbcb 100644 --- a/.gitignore +++ b/.gitignore @@ -167,3 +167,4 @@ test/acceptanceTest.html config/config.json data/metadata.json data/book_N.json +data/photo/* diff --git a/api/download.py b/api/download.py index bf4965c..3e26d11 100644 --- a/api/download.py +++ b/api/download.py @@ -79,3 +79,16 @@ class Download: json.dump(result, f, indent=4) f.close() + def download_photos(cls) : + print("Downloading photos") + + photos = cls.api.get( + "items/Fotos", + params=None + ) + + for photo in tqdm(photos): + data = cls.api.get_file("assets/" + photo["photo"]) + file = open("./data/photo/" + str(photo["id"]) + ".jpg", "wb") + file.write(data) + file.close() \ No newline at end of file diff --git a/build.py b/build.py index dd5e620..88b5a89 100644 --- a/build.py +++ b/build.py @@ -9,3 +9,4 @@ dl = download.Download(api) dl.download_edition("N") dl.download_question_metadata() +dl.download_photos()