[yaplog] match blog names with '-' (#443)

This commit is contained in:
Mike Fährmann
2019-10-09 17:30:30 +02:00
parent cf5e716b9d
commit a782b009b8

View File

@@ -12,6 +12,9 @@ from .common import Extractor, Message, AsynchronousMixin
from .. import text, util from .. import text, util
BASE_PATTERN = r"(?:https?://)?(?:www\.)?yaplog\.jp/([\w-]+)"
class YaplogExtractor(AsynchronousMixin, Extractor): class YaplogExtractor(AsynchronousMixin, Extractor):
"""Base class for yaplog extractors""" """Base class for yaplog extractors"""
category = "yaplog" category = "yaplog"
@@ -76,7 +79,7 @@ class YaplogExtractor(AsynchronousMixin, Extractor):
class YaplogBlogExtractor(YaplogExtractor): class YaplogBlogExtractor(YaplogExtractor):
"""Extractor for a user's blog on yaplog.jp""" """Extractor for a user's blog on yaplog.jp"""
subcategory = "blog" subcategory = "blog"
pattern = r"(?:https?://)?(?:www\.)?yaplog\.jp/(\w+)/?(?:$|[?&#])" pattern = BASE_PATTERN + r"/?(?:$|[?&#])"
test = ("https://yaplog.jp/omitakashi3", { test = ("https://yaplog.jp/omitakashi3", {
"pattern": r"https://img.yaplog.jp/img/18/pc/o/m/i/omitakashi3/0/", "pattern": r"https://img.yaplog.jp/img/18/pc/o/m/i/omitakashi3/0/",
"count": ">= 2", "count": ">= 2",
@@ -92,12 +95,15 @@ class YaplogBlogExtractor(YaplogExtractor):
class YaplogPostExtractor(YaplogExtractor): class YaplogPostExtractor(YaplogExtractor):
"""Extractor for images from a blog post on yaplog.jp""" """Extractor for images from a blog post on yaplog.jp"""
subcategory = "post" subcategory = "post"
pattern = (r"(?:https?://)?(?:www\.)?yaplog\.jp" pattern = BASE_PATTERN + r"/(?:archive|image)/(\d+)"
r"/(\w+)/(?:archive|image)/(\d+)") test = (
test = ("https://yaplog.jp/imamiami0726/image/1299", { ("https://yaplog.jp/imamiami0726/image/1299", {
"url": "896cae20fa718735a57e723c48544e830ff31345", "url": "896cae20fa718735a57e723c48544e830ff31345",
"keyword": "f8d8781e61c4c38238a7622d6df6c905f864e5d3", "keyword": "f8d8781e61c4c38238a7622d6df6c905f864e5d3",
}) }),
# blog names with '-' (#443)
("https://yaplog.jp/a-pierrot-o/image/3946/22779"),
)
def __init__(self, match): def __init__(self, match):
YaplogExtractor.__init__(self, match) YaplogExtractor.__init__(self, match)