summaryrefslogtreecommitdiffstats
path: root/gallery_dl/extractor/twitter.py
diff options
context:
space:
mode:
Diffstat (limited to 'gallery_dl/extractor/twitter.py')
-rw-r--r--gallery_dl/extractor/twitter.py30
1 files changed, 23 insertions, 7 deletions
diff --git a/gallery_dl/extractor/twitter.py b/gallery_dl/extractor/twitter.py
index ff77828..ec098aa 100644
--- a/gallery_dl/extractor/twitter.py
+++ b/gallery_dl/extractor/twitter.py
@@ -36,6 +36,7 @@ class TwitterExtractor(Extractor):
self.user = match.group(1)
def _init(self):
+ self.unavailable = self.config("unavailable", False)
self.textonly = self.config("text-tweets", False)
self.retweets = self.config("retweets", False)
self.replies = self.config("replies", True)
@@ -143,6 +144,15 @@ class TwitterExtractor(Extractor):
def _extract_media(self, tweet, entities, files):
for media in entities:
+
+ if "ext_media_availability" in media:
+ ext = media["ext_media_availability"]
+ if ext.get("status") == "Unavailable":
+ self.log.warning("Media unavailable (%s - '%s')",
+ tweet["id_str"], ext.get("reason"))
+ if not self.unavailable:
+ continue
+
descr = media.get("ext_alt_text")
width = media["original_info"].get("width", 0)
height = media["original_info"].get("height", 0)
@@ -1709,11 +1719,16 @@ class TwitterAPI():
variables["cursor"] = cursor
def _handle_ratelimit(self, response):
- if self.extractor.config("ratelimit") == "abort":
+ rl = self.extractor.config("ratelimit")
+ if rl == "abort":
raise exception.StopExtraction("Rate limit exceeded")
-
- until = response.headers.get("x-rate-limit-reset")
- self.extractor.wait(until=until, seconds=None if until else 60)
+ elif rl and isinstance(rl, str) and rl.startswith("wait:"):
+ until = None
+ seconds = text.parse_float(rl.partition(":")[2]) or 60.0
+ else:
+ until = response.headers.get("x-rate-limit-reset")
+ seconds = None if until else 60.0
+ self.extractor.wait(until=until, seconds=seconds)
def _process_tombstone(self, entry, tombstone):
text = (tombstone.get("richText") or tombstone["text"])["text"]
@@ -1849,7 +1864,7 @@ def _login_impl(extr, username, password):
},
}
elif subtask == "LoginEnterAlternateIdentifierSubtask":
- alt = extr.input(
+ alt = extr.config("username_alt") or extr.input(
"Alternate Identifier (username, email, phone number): ")
data = {
"enter_text": {
@@ -1881,8 +1896,9 @@ def _login_impl(extr, username, password):
raise exception.AuthenticationError("Login requires CAPTCHA")
elif subtask == "DenyLoginSubtask":
raise exception.AuthenticationError("Login rejected as suspicious")
- elif subtask == "ArkoseLogin":
- raise exception.AuthenticationError("No auth token cookie")
+ elif subtask == "LoginSuccessSubtask":
+ raise exception.AuthenticationError(
+ "No 'auth_token' cookie received")
else:
raise exception.StopExtraction("Unrecognized subtask %s", subtask)