[twitter] add option to filter media from quoted tweets (#854)
This commit is contained in:
@@ -1213,12 +1213,21 @@ Description A (comma-separated) list of post types to extract images, etc. from.
|
|||||||
=========== =====
|
=========== =====
|
||||||
|
|
||||||
|
|
||||||
|
extractor.twitter.quoted
|
||||||
|
------------------------
|
||||||
|
=========== =====
|
||||||
|
Type ``bool``
|
||||||
|
Default ``true``
|
||||||
|
Description Fetch media from quoted Tweets.
|
||||||
|
=========== =====
|
||||||
|
|
||||||
|
|
||||||
extractor.twitter.replies
|
extractor.twitter.replies
|
||||||
-------------------------
|
-------------------------
|
||||||
=========== =====
|
=========== =====
|
||||||
Type ``bool``
|
Type ``bool``
|
||||||
Default ``true``
|
Default ``true``
|
||||||
Description Extract media from replies to other Tweets.
|
Description Fetch media from replies to other Tweets.
|
||||||
=========== =====
|
=========== =====
|
||||||
|
|
||||||
|
|
||||||
@@ -1227,7 +1236,7 @@ extractor.twitter.retweets
|
|||||||
=========== =====
|
=========== =====
|
||||||
Type ``bool``
|
Type ``bool``
|
||||||
Default ``true``
|
Default ``true``
|
||||||
Description Extract media from Retweets.
|
Description Fetch media from Retweets.
|
||||||
=========== =====
|
=========== =====
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -155,6 +155,7 @@
|
|||||||
},
|
},
|
||||||
"twitter":
|
"twitter":
|
||||||
{
|
{
|
||||||
|
"quoted": true,
|
||||||
"replies": true,
|
"replies": true,
|
||||||
"retweets": true,
|
"retweets": true,
|
||||||
"twitpic": false,
|
"twitpic": false,
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ class TwitterExtractor(Extractor):
|
|||||||
self.retweets = self.config("retweets", True)
|
self.retweets = self.config("retweets", True)
|
||||||
self.replies = self.config("replies", True)
|
self.replies = self.config("replies", True)
|
||||||
self.twitpic = self.config("twitpic", False)
|
self.twitpic = self.config("twitpic", False)
|
||||||
|
self.quoted = self.config("quoted", True)
|
||||||
self.videos = self.config("videos", True)
|
self.videos = self.config("videos", True)
|
||||||
self._user_cache = {}
|
self._user_cache = {}
|
||||||
|
|
||||||
@@ -41,10 +42,9 @@ class TwitterExtractor(Extractor):
|
|||||||
|
|
||||||
for tweet in self.tweets():
|
for tweet in self.tweets():
|
||||||
|
|
||||||
if not self.retweets and (
|
if (not self.retweets and "retweeted_status_id_str" in tweet or
|
||||||
"retweeted_status_id_str" in tweet or
|
not self.replies and "in_reply_to_user_id_str" in tweet or
|
||||||
"quoted_status_id_str" in tweet) or \
|
not self.quoted and "quoted" in tweet):
|
||||||
not self.replies and "in_reply_to_user_id_str" in tweet:
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if self.twitpic:
|
if self.twitpic:
|
||||||
@@ -340,9 +340,16 @@ class TwitterTweetExtractor(TwitterExtractor):
|
|||||||
"options": (("replies", False),),
|
"options": (("replies", False),),
|
||||||
"count": 0,
|
"count": 0,
|
||||||
}),
|
}),
|
||||||
# quoted tweet (#526)
|
# quoted tweet (#526, #854)
|
||||||
("https://twitter.com/Pistachio/status/1222690391817932803", {
|
("https://twitter.com/StobiesGalaxy/status/1270755918330896395", {
|
||||||
"pattern": r"https://pbs\.twimg\.com/media/EPfMfDUU8AAnByO\.jpg",
|
"pattern": r"https://pbs\.twimg\.com/media/Ea[KG].+\.jpg",
|
||||||
|
"count": 8,
|
||||||
|
}),
|
||||||
|
# "quoted" option (#854)
|
||||||
|
("https://twitter.com/StobiesGalaxy/status/1270755918330896395", {
|
||||||
|
"options": (("quoted", False),),
|
||||||
|
"pattern": r"https://pbs\.twimg\.com/media/EaK.+\.jpg",
|
||||||
|
"count": 4,
|
||||||
}),
|
}),
|
||||||
# TwitPic embeds (#579)
|
# TwitPic embeds (#579)
|
||||||
("https://twitter.com/i/web/status/112900228289540096", {
|
("https://twitter.com/i/web/status/112900228289540096", {
|
||||||
@@ -526,6 +533,7 @@ class TwitterAPI():
|
|||||||
if quoted:
|
if quoted:
|
||||||
quoted["author"] = users[quoted["user_id_str"]]
|
quoted["author"] = users[quoted["user_id_str"]]
|
||||||
quoted["user"] = tweet["user"]
|
quoted["user"] = tweet["user"]
|
||||||
|
quoted["quoted"] = True
|
||||||
yield quoted
|
yield quoted
|
||||||
|
|
||||||
elif entry["entryId"].startswith(entry_cursor):
|
elif entry["entryId"].startswith(entry_cursor):
|
||||||
|
|||||||
Reference in New Issue
Block a user