[misskey] refactor misskey extractor
This commit is contained in:
@@ -27,6 +27,8 @@ class MisskeyExtractor(BaseExtractor):
|
||||
|
||||
def items(self):
|
||||
for note in self.notes():
|
||||
if "note" in note:
|
||||
note = note["note"]
|
||||
files = note.pop("files") or []
|
||||
renote = note.get("renote")
|
||||
if renote:
|
||||
@@ -157,26 +159,12 @@ class MisskeyMyFavoritesExtractor(MisskeyExtractor):
|
||||
subcategory = "favorites"
|
||||
pattern = BASE_PATTERN + r"(/my/favorites|/api/i/favorites)"
|
||||
test = (
|
||||
("https://misskey.io/my/favorites",),
|
||||
("https://misskey.io/api/i/favorites",),
|
||||
("https://misskey.io/my/favorites"),
|
||||
("https://misskey.io/api/i/favorites"),
|
||||
)
|
||||
|
||||
def items(self):
|
||||
for fav in self.api.i_favorites():
|
||||
note = fav.get("note")
|
||||
note["instance"] = self.instance
|
||||
note["instance_remote"] = note["user"]["host"]
|
||||
note["count"] = len(note["files"])
|
||||
note["date"] = text.parse_datetime(
|
||||
note["createdAt"], "%Y-%m-%dT%H:%M:%S.%f%z")
|
||||
|
||||
yield Message.Directory, note
|
||||
for note["num"], file in enumerate(note["files"], 1):
|
||||
file["date"] = text.parse_datetime(
|
||||
file["createdAt"], "%Y-%m-%dT%H:%M:%S.%f%z")
|
||||
note["file"] = file
|
||||
url = file["url"]
|
||||
yield Message.Url, url, text.nameext_from_url(url, note)
|
||||
def notes(self):
|
||||
return self.api.i_favorites()
|
||||
|
||||
|
||||
class MisskeyAPI():
|
||||
@@ -217,10 +205,9 @@ class MisskeyAPI():
|
||||
|
||||
def i_favorites(self):
|
||||
endpoint = "/i/favorites"
|
||||
data = {}
|
||||
if not self.access_token:
|
||||
raise exception.AuthenticationError()
|
||||
data["i"] = self.access_token
|
||||
data = {"i": self.access_token}
|
||||
return self._pagination(endpoint, data)
|
||||
|
||||
def _call(self, endpoint, data):
|
||||
|
||||
Reference in New Issue
Block a user