[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,27 +74,34 @@ 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 = (
|
||||||
"pattern": r"https://kemono\.party/files/fanbox"
|
("https://kemono.party/fanbox/user/6993449/post/506575", {
|
||||||
r"/6993449/506575/P058kDFYus7DbqAkGlfWTlOr\.jpeg",
|
"pattern": r"https://kemono\.party/files/fanbox"
|
||||||
"keyword": {
|
r"/6993449/506575/P058kDFYus7DbqAkGlfWTlOr\.jpeg",
|
||||||
"added": "Wed, 06 May 2020 20:28:02 GMT",
|
"keyword": {
|
||||||
"content": str,
|
"added": "Wed, 06 May 2020 20:28:02 GMT",
|
||||||
"date": "dt:2019-08-11 02:09:04",
|
"content": str,
|
||||||
"edited": None,
|
"date": "dt:2019-08-11 02:09:04",
|
||||||
"embed": dict,
|
"edited": None,
|
||||||
"extension": "jpeg",
|
"embed": dict,
|
||||||
"filename": "P058kDFYus7DbqAkGlfWTlOr",
|
"extension": "jpeg",
|
||||||
"id": "506575",
|
"filename": "P058kDFYus7DbqAkGlfWTlOr",
|
||||||
"num": 1,
|
"id": "506575",
|
||||||
"published": "Sun, 11 Aug 2019 02:09:04 GMT",
|
"num": 1,
|
||||||
"service": "fanbox",
|
"published": "Sun, 11 Aug 2019 02:09:04 GMT",
|
||||||
"shared_file": False,
|
"service": "fanbox",
|
||||||
"subcategory": "post",
|
"shared_file": False,
|
||||||
"title": "c96取り置き",
|
"subcategory": "post",
|
||||||
"user": "6993449",
|
"title": "c96取り置き",
|
||||||
},
|
"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