From b08da4ffc778cc8ef42ff8f5d34fb6a577e1100d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Tue, 22 Oct 2024 17:03:11 +0200 Subject: [PATCH] [reddit] add 'embeds' option (#6357) --- docs/configuration.rst | 10 ++++++++++ gallery_dl/extractor/reddit.py | 3 ++- test/results/reddit.py | 9 ++++++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/docs/configuration.rst b/docs/configuration.rst index ca6d6485..1835ac8e 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -3702,6 +3702,16 @@ Description Note: This requires 1 additional API call for every 100 extra comments. +extractor.reddit.embeds +----------------------- +Type + ``bool`` +Default + ``true`` +Description + Download embedded comments media. + + extractor.reddit.date-min & .date-max ------------------------------------- Type diff --git a/gallery_dl/extractor/reddit.py b/gallery_dl/extractor/reddit.py index 465cfdf9..8577e74b 100644 --- a/gallery_dl/extractor/reddit.py +++ b/gallery_dl/extractor/reddit.py @@ -31,6 +31,7 @@ class RedditExtractor(Extractor): parentdir = self.config("parent-directory") max_depth = self.config("recursion", 0) previews = self.config("previews", True) + embeds = self.config("embeds", True) videos = self.config("videos", True) if videos: @@ -100,7 +101,7 @@ class RedditExtractor(Extractor): for comment in comments: html = comment["body_html"] or "" href = (' href="' in html) - media = ("media_metadata" in comment) + media = (embeds and "media_metadata" in comment) if media or href: comment["date"] = text.parse_timestamp( diff --git a/test/results/reddit.py b/test/results/reddit.py index 55623337..1221fa5c 100644 --- a/test/results/reddit.py +++ b/test/results/reddit.py @@ -171,7 +171,6 @@ __tests__ = ( { "#url" : "https://www.reddit.com/r/RobloxArt/comments/15ko0qu/", "#comment" : "comment embeds (#5366)", - "#category": ("", "reddit", "submission"), "#class" : reddit.RedditSubmissionExtractor, "#options" : {"comments": 10}, "#urls" : ( @@ -180,6 +179,14 @@ __tests__ = ( ), }, +{ + "#url" : "https://www.reddit.com/r/RobloxArt/comments/15ko0qu/", + "#comment" : "disabled comment embeds (#6357)", + "#class" : reddit.RedditSubmissionExtractor, + "#options" : {"comments": 10, "embeds": False}, + "#urls" : "https://i.redd.it/ppt5yciyipgb1.jpg", +}, + { "#url" : "https://www.reddit.com/user/TheSpiritTree/comments/srilyf/", "#comment" : "user page submission (#2301)",