[misskey] add 'renotes' and 'replies' options

This commit is contained in:
enduser420
2023-03-02 19:56:19 +05:30
parent a95b5e0d8e
commit e1867cf5eb
2 changed files with 37 additions and 1 deletions

View File

@@ -2029,6 +2029,26 @@ Description
Also emit metadata for text-only posts without media content.
extractor.[misskey].renotes
----------------------------
Type
``bool``
Default
``false``
Description
Fetch media from renoted notes.
extractor.[misskey].replies
----------------------------
Type
``bool``
Default
``true``
Description
Fetch media from replies to other notes.
extractor.nana.favkey
---------------------
Type

View File

@@ -20,10 +20,26 @@ class MisskeyExtractor(BaseExtractor):
self.api = MisskeyAPI(self)
self.instance = self.root.rpartition("://")[2]
self.item = match.group(match.lastindex)
self.renotes = self.config("renotes", False)
self.replies = self.config("replies", True)
def items(self):
for note in self.notes():
files = note.pop("files") or ()
files = note.pop("files") or []
renote = note.get("renote")
if renote:
if not self.renotes:
self.log.debug("Skipping %s (renote)", note["id"])
continue
files.extend(renote.get("files") or ())
reply = note.get("reply")
if reply:
if not self.replies:
self.log.debug("Skipping %s (reply)", note["id"])
continue
files.extend(reply.get("files") or ())
note["instance"] = self.instance
note["instance_remote"] = note["user"]["host"]
note["count"] = len(files)