add 'ads' option in case someone actually wants to download promoted content for whatever reason
This commit is contained in:
@@ -3109,6 +3109,16 @@ Description
|
|||||||
See `Filters <https://twibooru.org/filters>`__ for details.
|
See `Filters <https://twibooru.org/filters>`__ for details.
|
||||||
|
|
||||||
|
|
||||||
|
extractor.twitter.ads
|
||||||
|
---------------------
|
||||||
|
Type
|
||||||
|
``bool``
|
||||||
|
Default
|
||||||
|
``false``
|
||||||
|
Description
|
||||||
|
Fetch media from promoted Tweets.
|
||||||
|
|
||||||
|
|
||||||
extractor.twitter.cards
|
extractor.twitter.cards
|
||||||
-----------------------
|
-----------------------
|
||||||
Type
|
Type
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ class TwitterExtractor(Extractor):
|
|||||||
self.quoted = self.config("quoted", False)
|
self.quoted = self.config("quoted", False)
|
||||||
self.videos = self.config("videos", True)
|
self.videos = self.config("videos", True)
|
||||||
self.cards = self.config("cards", False)
|
self.cards = self.config("cards", False)
|
||||||
|
self.ads = self.config("ads", False)
|
||||||
self.cards_blacklist = self.config("cards-blacklist")
|
self.cards_blacklist = self.config("cards-blacklist")
|
||||||
self.syndication = self.config("syndication")
|
self.syndication = self.config("syndication")
|
||||||
|
|
||||||
@@ -1034,7 +1035,7 @@ class TwitterAPI():
|
|||||||
"focalTweetId": tweet_id,
|
"focalTweetId": tweet_id,
|
||||||
"referrer": "profile",
|
"referrer": "profile",
|
||||||
"with_rux_injections": False,
|
"with_rux_injections": False,
|
||||||
"includePromotedContent": True,
|
"includePromotedContent": False,
|
||||||
"withCommunity": True,
|
"withCommunity": True,
|
||||||
"withQuickPromoteEligibilityTweetFields": True,
|
"withQuickPromoteEligibilityTweetFields": True,
|
||||||
"withBirdwatchNotes": True,
|
"withBirdwatchNotes": True,
|
||||||
@@ -1049,7 +1050,7 @@ class TwitterAPI():
|
|||||||
variables = {
|
variables = {
|
||||||
"userId": self._user_id_by_screen_name(screen_name),
|
"userId": self._user_id_by_screen_name(screen_name),
|
||||||
"count": 100,
|
"count": 100,
|
||||||
"includePromotedContent": True,
|
"includePromotedContent": False,
|
||||||
"withQuickPromoteEligibilityTweetFields": True,
|
"withQuickPromoteEligibilityTweetFields": True,
|
||||||
"withVoice": True,
|
"withVoice": True,
|
||||||
"withV2Timeline": True,
|
"withV2Timeline": True,
|
||||||
@@ -1061,7 +1062,7 @@ class TwitterAPI():
|
|||||||
variables = {
|
variables = {
|
||||||
"userId": self._user_id_by_screen_name(screen_name),
|
"userId": self._user_id_by_screen_name(screen_name),
|
||||||
"count": 100,
|
"count": 100,
|
||||||
"includePromotedContent": True,
|
"includePromotedContent": False,
|
||||||
"withCommunity": True,
|
"withCommunity": True,
|
||||||
"withVoice": True,
|
"withVoice": True,
|
||||||
"withV2Timeline": True,
|
"withV2Timeline": True,
|
||||||
@@ -1498,13 +1499,21 @@ class TwitterAPI():
|
|||||||
|
|
||||||
for entry in tweets:
|
for entry in tweets:
|
||||||
try:
|
try:
|
||||||
tweet = ((entry.get("content") or entry["item"])
|
item = ((entry.get("content") or entry["item"])
|
||||||
["itemContent"]["tweet_results"]["result"])
|
["itemContent"])
|
||||||
|
if "promotedMetadata" in item and not extr.ads:
|
||||||
|
extr.log.debug(
|
||||||
|
"Skipping %s (ad)",
|
||||||
|
(entry.get("entryId") or "").rpartition("-")[2])
|
||||||
|
continue
|
||||||
|
|
||||||
|
tweet = item["tweet_results"]["result"]
|
||||||
if "tombstone" in tweet:
|
if "tombstone" in tweet:
|
||||||
tweet = self._process_tombstone(
|
tweet = self._process_tombstone(
|
||||||
entry, tweet["tombstone"])
|
entry, tweet["tombstone"])
|
||||||
if not tweet:
|
if not tweet:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if "tweet" in tweet:
|
if "tweet" in tweet:
|
||||||
tweet = tweet["tweet"]
|
tweet = tweet["tweet"]
|
||||||
legacy = tweet["legacy"]
|
legacy = tweet["legacy"]
|
||||||
|
|||||||
Reference in New Issue
Block a user