Skip to content

Commit

Permalink
[reddit] add 'embeds' option (#6357)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Oct 22, 2024
1 parent 33161da commit b08da4f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
10 changes: 10 additions & 0 deletions docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion gallery_dl/extractor/reddit.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def items(self):
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:
Expand Down Expand Up @@ -100,7 +101,7 @@ def items(self):
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(
Expand Down
9 changes: 8 additions & 1 deletion test/results/reddit.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@
{
"#url" : "https://www.reddit.com/r/RobloxArt/comments/15ko0qu/",
"#comment" : "comment embeds (#5366)",
"#category": ("", "reddit", "submission"),
"#class" : reddit.RedditSubmissionExtractor,
"#options" : {"comments": 10},
"#urls" : (
Expand All @@ -180,6 +179,14 @@
),
},

{
"#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)",
Expand Down

0 comments on commit b08da4f

Please sign in to comment.