Skip to content

Commit

Permalink
[twitter] extend 'replies' option (#1254)
Browse files Browse the repository at this point in the history
Allow setting 'replies to '"self"' to only download from self-replies.
  • Loading branch information
mikf committed Aug 10, 2021
1 parent f909658 commit e5a93e1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
3 changes: 3 additions & 0 deletions docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1899,6 +1899,9 @@ Default
Description
Fetch media from replies to other Tweets.

If this value is ``"self"``, only consider replies where
reply and original Tweet are from the same user.


extractor.twitter.retweets
--------------------------
Expand Down
20 changes: 17 additions & 3 deletions gallery_dl/extractor/twitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,17 @@ def items(self):
if not self.retweets and "retweeted_status_id_str" in tweet:
self.log.debug("Skipping %s (retweet)", tweet["id_str"])
continue
if not self.replies and "in_reply_to_user_id_str" in tweet:
self.log.debug("Skipping %s (reply)", tweet["id_str"])
continue
if not self.quoted and "quoted" in tweet:
self.log.debug("Skipping %s (quoted tweet)", tweet["id_str"])
continue
if "in_reply_to_user_id_str" in tweet and (
not self.replies or (
self.replies == "self" and
tweet["in_reply_to_user_id_str"] != tweet["user_id_str"]
)
):
self.log.debug("Skipping %s (reply)", tweet["id_str"])
continue

files = []
if "extended_entities" in tweet:
Expand Down Expand Up @@ -452,6 +457,15 @@ class TwitterTweetExtractor(TwitterExtractor):
"options": (("replies", False),),
"count": 0,
}),
# 'replies' to self (#1254)
("https://twitter.com/i/web/status/1424882930803908612", {
"options": (("replies", "self"),),
"count": 4,
}),
("https://twitter.com/i/web/status/1424898916156284928", {
"options": (("replies", "self"),),
"count": 0,
}),
# "quoted" option (#854)
("https://twitter.com/StobiesGalaxy/status/1270755918330896395", {
"options": (("quoted", True),),
Expand Down

0 comments on commit e5a93e1

Please sign in to comment.