From ad25be342061567078bc6d5a5407cad436c5a400 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Fri, 21 Jun 2024 18:56:43 +0200 Subject: [PATCH] [fanbox] fix 8452d04a (#5759) The previous code would raise an exception when there are no or more than 1 plans with a fee higher than 'feeRequired'. --- gallery_dl/extractor/fanbox.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/gallery_dl/extractor/fanbox.py b/gallery_dl/extractor/fanbox.py index 3d51792f..fbadccff 100644 --- a/gallery_dl/extractor/fanbox.py +++ b/gallery_dl/extractor/fanbox.py @@ -117,8 +117,15 @@ class FanboxExtractor(Extractor): try: post["plan"] = plans[fee] except KeyError: - post["plan"] = plans[fee] = min( - p for p in plans.values() if p["fee"] >= fee) + fees = [f for f in plans if f >= fee] + if fees: + plan = plans[min(fees)] + else: + plan = plans[0].copy() + plan["fee"] = fee + post["plan"] = plans[fee] = plan + print(post["plan"]) + exit() return content_body, post