summaryrefslogtreecommitdiffstats
path: root/gallery_dl/extractor/mastodon.py
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@unit193.net>2023-01-30 04:40:57 -0500
committerLibravatarUnit 193 <unit193@unit193.net>2023-01-30 04:40:57 -0500
commit919f8ba16a7b82ba1099bd25b2c61c7881a05aa2 (patch)
tree50eb34c3286538164a2f2b7048d110dc89b2a971 /gallery_dl/extractor/mastodon.py
parentf1051085013c0d702ef974b9b27ea43b3fc73259 (diff)
New upstream version 1.24.5.upstream/1.24.5
Diffstat (limited to 'gallery_dl/extractor/mastodon.py')
-rw-r--r--gallery_dl/extractor/mastodon.py19
1 files changed, 12 insertions, 7 deletions
diff --git a/gallery_dl/extractor/mastodon.py b/gallery_dl/extractor/mastodon.py
index 049e0af..e49d29a 100644
--- a/gallery_dl/extractor/mastodon.py
+++ b/gallery_dl/extractor/mastodon.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2019-2022 Mike Fährmann
+# Copyright 2019-2023 Mike Fährmann
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
@@ -31,8 +31,8 @@ class MastodonExtractor(BaseExtractor):
def items(self):
for status in self.statuses():
- if self._check_move:
- self._check_move(status["account"])
+ if self._check_moved:
+ self._check_moved(status["account"])
if not self.reblogs and status["reblog"]:
self.log.debug("Skipping %s (reblog)", status["id"])
continue
@@ -48,12 +48,13 @@ class MastodonExtractor(BaseExtractor):
status["instance_remote"] = \
acct.rpartition("@")[2] if "@" in acct else None
+ status["count"] = len(attachments)
status["tags"] = [tag["name"] for tag in status["tags"]]
status["date"] = text.parse_datetime(
status["created_at"][:19], "%Y-%m-%dT%H:%M:%S")
yield Message.Directory, status
- for media in attachments:
+ for status["num"], media in enumerate(attachments, 1):
status["media"] = media
url = media["url"]
yield Message.Url, url, text.nameext_from_url(url, status)
@@ -62,8 +63,8 @@ class MastodonExtractor(BaseExtractor):
"""Return an iterable containing all relevant Status objects"""
return ()
- def _check_move(self, account):
- self._check_move = None
+ def _check_moved(self, account):
+ self._check_moved = None
if "moved" in account:
self.log.warning("Account '%s' moved to '%s'",
account["acct"], account["moved"]["acct"])
@@ -181,6 +182,10 @@ class MastodonStatusExtractor(MastodonExtractor):
test = (
("https://mastodon.social/@jk/103794036899778366", {
"count": 4,
+ "keyword": {
+ "count": 4,
+ "num": int,
+ },
}),
("https://pawoo.net/@yoru_nine/105038878897832922", {
"content": "b52e807f8ab548d6f896b09218ece01eba83987a",
@@ -229,7 +234,7 @@ class MastodonAPI():
for account in self.account_search(handle, 1):
if account["acct"] == username:
- self.extractor._check_move(account)
+ self.extractor._check_moved(account)
return account["id"]
raise exception.NotFoundError("account")