[kemonoparty] extract inline images (fixes #1286)
This commit is contained in:
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
from .common import Extractor, Message
|
from .common import Extractor, Message
|
||||||
from .. import text
|
from .. import text
|
||||||
|
import re
|
||||||
|
|
||||||
|
|
||||||
class KemonopartyExtractor(Extractor):
|
class KemonopartyExtractor(Extractor):
|
||||||
@@ -21,6 +22,8 @@ class KemonopartyExtractor(Extractor):
|
|||||||
archive_fmt = "{user}_{id}_{filename}.{extension}"
|
archive_fmt = "{user}_{id}_{filename}.{extension}"
|
||||||
|
|
||||||
def items(self):
|
def items(self):
|
||||||
|
find_inline = re.compile(r'src="(/inline/[^"]+)').findall
|
||||||
|
|
||||||
for post in self.posts():
|
for post in self.posts():
|
||||||
|
|
||||||
files = []
|
files = []
|
||||||
@@ -28,6 +31,9 @@ class KemonopartyExtractor(Extractor):
|
|||||||
files.append(post["file"])
|
files.append(post["file"])
|
||||||
if post["attachments"]:
|
if post["attachments"]:
|
||||||
files.extend(post["attachments"])
|
files.extend(post["attachments"])
|
||||||
|
for path in find_inline(post["content"] or ""):
|
||||||
|
files.append({"path": path, "name": path})
|
||||||
|
|
||||||
post["date"] = text.parse_datetime(
|
post["date"] = text.parse_datetime(
|
||||||
post["published"], "%a, %d %b %Y %H:%M:%S %Z")
|
post["published"], "%a, %d %b %Y %H:%M:%S %Z")
|
||||||
yield Message.Directory, post
|
yield Message.Directory, post
|
||||||
@@ -68,7 +74,8 @@ class KemonopartyPostExtractor(KemonopartyExtractor):
|
|||||||
"""Extractor for a single kemono.party post"""
|
"""Extractor for a single kemono.party post"""
|
||||||
subcategory = "post"
|
subcategory = "post"
|
||||||
pattern = r"(?:https?://)?kemono\.party/([^/?#]+)/user/(\d+)/post/(\d+)"
|
pattern = r"(?:https?://)?kemono\.party/([^/?#]+)/user/(\d+)/post/(\d+)"
|
||||||
test = ("https://kemono.party/fanbox/user/6993449/post/506575", {
|
test = (
|
||||||
|
("https://kemono.party/fanbox/user/6993449/post/506575", {
|
||||||
"pattern": r"https://kemono\.party/files/fanbox"
|
"pattern": r"https://kemono\.party/files/fanbox"
|
||||||
r"/6993449/506575/P058kDFYus7DbqAkGlfWTlOr\.jpeg",
|
r"/6993449/506575/P058kDFYus7DbqAkGlfWTlOr\.jpeg",
|
||||||
"keyword": {
|
"keyword": {
|
||||||
@@ -88,7 +95,13 @@ class KemonopartyPostExtractor(KemonopartyExtractor):
|
|||||||
"title": "c96取り置き",
|
"title": "c96取り置き",
|
||||||
"user": "6993449",
|
"user": "6993449",
|
||||||
},
|
},
|
||||||
})
|
}),
|
||||||
|
# inline image (#1286)
|
||||||
|
("https://kemono.party/fanbox/user/7356311/post/802343", {
|
||||||
|
"pattern": r"https://kemono\.party/inline/fanbox"
|
||||||
|
r"/uaozO4Yga6ydkGIJFAQDixfE\.jpeg",
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
|
||||||
def __init__(self, match):
|
def __init__(self, match):
|
||||||
KemonopartyExtractor.__init__(self, match)
|
KemonopartyExtractor.__init__(self, match)
|
||||||
|
|||||||
Reference in New Issue
Block a user