From d7e1351987947e65bbb3ee59e32d9e02ff5994ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Wed, 12 Nov 2025 18:38:44 +0100 Subject: [PATCH] [bellazon] improve 'filename' & 'extension' (#8544) https://github.com/mikf/gallery-dl/issues/8544#issuecomment-3522617104 - use 'extension' from file URL (except attachments) - strip everything after the first '.' from non-URL filenames --- gallery_dl/extractor/bellazon.py | 12 ++++++++---- test/results/bellazon.py | 11 +++++++++++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/gallery_dl/extractor/bellazon.py b/gallery_dl/extractor/bellazon.py index 4ac07b7e..470cc654 100644 --- a/gallery_dl/extractor/bellazon.py +++ b/gallery_dl/extractor/bellazon.py @@ -62,11 +62,12 @@ class BellazonExtractor(Extractor): data["num_internal"] += 1 if not (alt := text.extr(info, ' alt="', '"')) or ( alt.startswith("post-") and "_thumb." in alt): - name = url + dc = text.nameext_from_url(url, data.copy()) else: - name = text.unescape(alt) + dc = data.copy() + dc["name"] = name = text.unescape(alt) + dc["filename"] = name.partition(".")[0] - dc = text.nameext_from_url(name, data.copy()) dc["id"] = text.extr(info, 'data-fileid="', '"') if ext := text.extr(info, 'data-fileext="', '"'): dc["extension"] = ext @@ -75,7 +76,10 @@ class BellazonExtractor(Extractor): dc["id"] = \ url.rpartition("?id=")[2].partition("&")[0] if name := text.extr(info, ">", "<").strip(): - text.nameext_from_url(name, dc) + dc["name"] = name = text.unescape(name) + text.nameext_from_name(name, dc) + else: + dc["extension"] = text.ext_from_url(url) if url[0] == "/": url = f"https:{url}" diff --git a/test/results/bellazon.py b/test/results/bellazon.py index f01c515c..67c21530 100644 --- a/test/results/bellazon.py +++ b/test/results/bellazon.py @@ -237,6 +237,17 @@ __tests__ = ( "id" : "14418097", }, +{ + "#url" : "https://www.bellazon.com/main/topic/4322-candids/page/1066/#comment-3956772", + "#comment" : "weird/wrong 'filename' & 'extension' (#8544)", + "#class" : bellazon.BellazonPostExtractor, + "#count" : 16, + + "extension" : "jpg", + "filename" : r"re:^[^.]+$", + "id" : r"re:^\d+$", +}, + { "#url" : "https://www.bellazon.com/main/topic/57872-millie-brady/", "#class" : bellazon.BellazonThreadExtractor,