From c0035d8d52d836705fba5f17d4637485c2ed3edd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Wed, 1 Oct 2025 08:40:24 +0200 Subject: [PATCH] [simpcity] fix "KeyError: 'url'" when thread author is deleted (#8323) --- gallery_dl/extractor/simpcity.py | 7 ++++--- test/results/simpcity.py | 33 ++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/gallery_dl/extractor/simpcity.py b/gallery_dl/extractor/simpcity.py index 3354289f..d8227faf 100644 --- a/gallery_dl/extractor/simpcity.py +++ b/gallery_dl/extractor/simpcity.py @@ -92,7 +92,7 @@ class SimpcityExtractor(Extractor): author = schema["author"] stats = schema["interactionStatistic"] url_t = schema["url"] - url_a = author["url"] + url_a = author.get("url") or "" thread = { "id" : url_t[url_t.rfind(".")+1:-1], @@ -104,8 +104,9 @@ class SimpcityExtractor(Extractor): "tags" : (schema["keywords"].split(", ") if "keywords" in schema else ()), "section" : schema["articleSection"], - "author" : author["name"], - "author_id" : url_a[url_a.rfind(".")+1:-1], + "author" : author.get("name") or "", + "author_id" : (url_a[url_a.rfind(".")+1:-1] if url_a else + (author.get("name") or "")[15:]), "author_url": url_a, } diff --git a/test/results/simpcity.py b/test/results/simpcity.py index ad9d5dd8..95e83e90 100644 --- a/test/results/simpcity.py +++ b/test/results/simpcity.py @@ -81,6 +81,39 @@ __tests__ = ( "#results" : ("/goto/post?id=13358068", "https://cyberdrop.me/a/Sh9GlG38"), }, +{ + "#url" : "https://simpcity.cr/threads/kayle-oralglory.36572/post-12065490", + "#comment" : "deleted thread author (#8323)", + "#class" : simpcity.SimpcityPostExtractor, + "#auth" : True, + "#results" : ( + "https://jpg5.su/img/aKroBJp", + "https://jpg5.su/img/aKroy2E", + "https://jpg5.su/img/aKrofqa", + "https://jpg5.su/img/aKroDgo", + "https://bunkr.cr/v/6sErIc9pjrnQ3", + ), + + "post" : { + "author" : "Hexorium", + "author_id" : "3715883", + "author_url": "https://simpcity.cr/members/hexorium.3715883/", + "count" : 5, + "date" : "dt:2024-12-15 21:37:05", + "id" : "12065490", + }, + "thread": { + "author" : "Deleted member 166159", + "author_id" : "166159", + "author_url": "", + "date" : "dt:2022-04-05 14:48:14", + "id" : "36572", + "section" : "Premium Asians", + "title" : "Kayle OralGlory", + "url" : "https://simpcity.cr/threads/kayle-oralglory.36572/", + }, +}, + { "#url" : "https://simpcity.cr/threads/alua-tatakai.89490/", "#class" : simpcity.SimpcityThreadExtractor,