[misskey] implement 'include' option (#5347)

This commit is contained in:
Mike Fährmann
2025-06-06 20:52:03 +02:00
parent 5cd3f3977e
commit 3e423937d2
7 changed files with 96 additions and 17 deletions

View File

@@ -3509,6 +3509,29 @@ Description
Your access token, necessary to fetch favorited notes. Your access token, necessary to fetch favorited notes.
extractor.[misskey].include
---------------------------
Type
* ``string``
* ``list`` of ``strings``
Default
``"notes"``
Example
* ``"avatar,background,notes"``
* ``["avatar", "background", "notes"]``
Description
A (comma-separated) list of subcategories to include
when processing a user profile.
Possible values are
``"info"``,
``"avatar"``,
``"background"``,
``"notes"``,
It is possible to use ``"all"`` instead of listing all values separately.
extractor.[misskey].renotes extractor.[misskey].renotes
--------------------------- ---------------------------
Type Type

View File

@@ -913,6 +913,7 @@
"misskey": "misskey":
{ {
"access-token": null, "access-token": null,
"include" : ["notes"],
"renotes" : false, "renotes" : false,
"replies" : true "replies" : true
}, },

View File

@@ -1424,25 +1424,25 @@ Consider all listed sites to potentially be NSFW.
<tr> <tr>
<td>Misskey.io</td> <td>Misskey.io</td>
<td>https://misskey.io/</td> <td>https://misskey.io/</td>
<td>Avatars, Backgrounds, Favorites, Followed Users, User Profile Information, Images from Notes, User Profiles</td> <td>Avatars, Backgrounds, Favorites, Followed Users, User Profile Information, Notes, User Notes, User Profiles</td>
<td></td> <td></td>
</tr> </tr>
<tr> <tr>
<td>Misskey.design</td> <td>Misskey.design</td>
<td>https://misskey.design/</td> <td>https://misskey.design/</td>
<td>Avatars, Backgrounds, Favorites, Followed Users, User Profile Information, Images from Notes, User Profiles</td> <td>Avatars, Backgrounds, Favorites, Followed Users, User Profile Information, Notes, User Notes, User Profiles</td>
<td></td> <td></td>
</tr> </tr>
<tr> <tr>
<td>Lesbian.energy</td> <td>Lesbian.energy</td>
<td>https://lesbian.energy/</td> <td>https://lesbian.energy/</td>
<td>Avatars, Backgrounds, Favorites, Followed Users, User Profile Information, Images from Notes, User Profiles</td> <td>Avatars, Backgrounds, Favorites, Followed Users, User Profile Information, Notes, User Notes, User Profiles</td>
<td></td> <td></td>
</tr> </tr>
<tr> <tr>
<td>Sushi.ski</td> <td>Sushi.ski</td>
<td>https://sushi.ski/</td> <td>https://sushi.ski/</td>
<td>Avatars, Backgrounds, Favorites, Followed Users, User Profile Information, Images from Notes, User Profiles</td> <td>Avatars, Backgrounds, Favorites, Followed Users, User Profile Information, Notes, User Notes, User Profiles</td>
<td></td> <td></td>
</tr> </tr>

View File

@@ -6,7 +6,7 @@
"""Extractors for Misskey instances""" """Extractors for Misskey instances"""
from .common import BaseExtractor, Message from .common import BaseExtractor, Message, Dispatch
from .. import text, exception from .. import text, exception
from ..cache import memcache from ..cache import memcache
@@ -103,12 +103,28 @@ BASE_PATTERN = MisskeyExtractor.update({
}) })
class MisskeyUserExtractor(MisskeyExtractor): class MisskeyUserExtractor(Dispatch, MisskeyExtractor):
"""Extractor for all images of a Misskey user""" """Extractor for all images of a Misskey user"""
subcategory = "user" subcategory = "user"
pattern = BASE_PATTERN + r"/@([^/?#]+)/?$" pattern = BASE_PATTERN + r"/@([^/?#]+)/?$"
example = "https://misskey.io/@USER" example = "https://misskey.io/@USER"
def items(self):
base = "{}/@{}/".format(self.root, self.item)
return self._dispatch_extractors((
(MisskeyInfoExtractor , base + "info"),
(MisskeyAvatarExtractor , base + "avatar"),
(MisskeyBackgroundExtractor, base + "banner"),
(MisskeyNotesExtractor , base + "notes"),
), ("notes",))
class MisskeyNotesExtractor(MisskeyExtractor):
"""Extractor for a Misskey user's notes"""
subcategory = "notes"
pattern = BASE_PATTERN + r"/@([^/?#]+)/notes"
example = "https://misskey.io/@USER/notes"
def notes(self): def notes(self):
return self.api.users_notes(self.api.user_id_by_username(self.item)) return self.api.users_notes(self.api.user_id_by_username(self.item))

View File

@@ -183,7 +183,6 @@ SUBCATEGORY_MAP = {
"issue" : "Comic Issues", "issue" : "Comic Issues",
"manga" : "Manga", "manga" : "Manga",
"media" : "Media Files", "media" : "Media Files",
"note" : "Images from Notes",
"popular": "Popular Images", "popular": "Popular Images",
"recent" : "Recent Images", "recent" : "Recent Images",
"search" : "Search Results", "search" : "Search Results",
@@ -296,6 +295,10 @@ SUBCATEGORY_MAP = {
"following" : "Library", "following" : "Library",
"list": "MDLists", "list": "MDLists",
}, },
"misskey": {
"note" : "Notes",
"notes": "User Notes",
},
"nijie": { "nijie": {
"followed": "Followed Users", "followed": "Followed Users",
"nuita" : "Nuita History", "nuita" : "Nuita History",

View File

@@ -12,7 +12,20 @@ __tests__ = (
"#url" : "https://misskey.design/@machina_3D", "#url" : "https://misskey.design/@machina_3D",
"#category": ("misskey", "misskey.design", "user"), "#category": ("misskey", "misskey.design", "user"),
"#class" : misskey.MisskeyUserExtractor, "#class" : misskey.MisskeyUserExtractor,
"#pattern" : r"https://file\.misskey\.design/post/[\w-]{36}\.\w+", "#options" : {"include": "all"},
"#urls" : (
"https://misskey.design/@machina_3D/info",
"https://misskey.design/@machina_3D/avatar",
"https://misskey.design/@machina_3D/banner",
"https://misskey.design/@machina_3D/notes",
),
},
{
"#url" : "https://misskey.design/@machina_3D/notes",
"#category": ("misskey", "misskey.design", "notes"),
"#class" : misskey.MisskeyNotesExtractor,
"#pattern" : r"https://file\.misskey\.design/post/(webpublic-)?[\w-]{36}\.\w+",
"#range" : "1-50", "#range" : "1-50",
"#count" : 50, "#count" : 50,
}, },
@@ -48,9 +61,9 @@ __tests__ = (
}, },
{ {
"#url" : "https://misskey.design/@blooddj@pawoo.net", "#url" : "https://misskey.design/@blooddj@pawoo.net/notes",
"#category": ("misskey", "misskey.design", "user"), "#category": ("misskey", "misskey.design", "notes"),
"#class" : misskey.MisskeyUserExtractor, "#class" : misskey.MisskeyNotesExtractor,
"#count" : "> 30", "#count" : "> 30",
}, },

View File

@@ -12,11 +12,30 @@ __tests__ = (
"#url" : "https://misskey.io/@lithla", "#url" : "https://misskey.io/@lithla",
"#category": ("misskey", "misskey.io", "user"), "#category": ("misskey", "misskey.io", "user"),
"#class" : misskey.MisskeyUserExtractor, "#class" : misskey.MisskeyUserExtractor,
"#pattern" : r"https://(media.misskeyusercontent.com|s\d+\.arkjp\.net)/(misskey|io)/[\w-]+\.\w+", "#options" : {"include": "all"},
"#urls" : (
"https://misskey.io/@lithla/info",
"https://misskey.io/@lithla/avatar",
"https://misskey.io/@lithla/banner",
"https://misskey.io/@lithla/notes",
),
},
{
"#url" : "https://misskey.io/@lithla/notes",
"#category": ("misskey", "misskey.io", "notes"),
"#class" : misskey.MisskeyNotesExtractor,
"#pattern" : r"https://(media.misskeyusercontent.(jp|com)|s\d+\.arkjp\.net)/(misskey|io)/[\w-]+\.\w+",
"#range" : "1-50", "#range" : "1-50",
"#count" : 50, "#count" : 50,
}, },
{
"#url" : "https://misskey.io/@lithla/info",
"#category": ("misskey", "misskey.io", "info"),
"#class" : misskey.MisskeyInfoExtractor,
},
{ {
"#url" : "https://misskey.io/@lithla/avatar", "#url" : "https://misskey.io/@lithla/avatar",
"#category": ("misskey", "misskey.io", "avatar"), "#category": ("misskey", "misskey.io", "avatar"),
@@ -48,9 +67,9 @@ __tests__ = (
}, },
{ {
"#url" : "https://misskey.io/@blooddj@pawoo.net", "#url" : "https://misskey.io/@blooddj@pawoo.net/notes",
"#category": ("misskey", "misskey.io", "user"), "#category": ("misskey", "misskey.io", "notes"),
"#class" : misskey.MisskeyUserExtractor, "#class" : misskey.MisskeyNotesExtractor,
"#range" : "1-50", "#range" : "1-50",
"#count" : 50, "#count" : 50,
}, },
@@ -67,8 +86,12 @@ __tests__ = (
"#url" : "https://misskey.io/notes/9bhqfo835v", "#url" : "https://misskey.io/notes/9bhqfo835v",
"#category": ("misskey", "misskey.io", "note"), "#category": ("misskey", "misskey.io", "note"),
"#class" : misskey.MisskeyNoteExtractor, "#class" : misskey.MisskeyNoteExtractor,
"#pattern" : r"https://(media\.misskeyusercontent\.com|s\d+\.arkjp\.net)/misskey/[\w-]+\.\w+", "#urls" : (
"#count" : 4, "https://media.misskeyusercontent.jp/misskey/1cbba095-5a19-4107-8e20-3efb0456dda4.png?sensitive=true",
"https://media.misskeyusercontent.jp/misskey/6baa558b-94ac-4bd2-a393-a52324a9d2d4.png?sensitive=true",
"https://media.misskeyusercontent.jp/misskey/14133ad0-ea40-4fed-b6e7-65d4cbe19b96.png?sensitive=true",
"https://media.misskeyusercontent.jp/misskey/e11164a2-9de5-4769-8c73-0ae44124b565.png?sensitive=true",
),
}, },
{ {