rename extractor classes starting with a digit
This commit is contained in:
@@ -6,13 +6,13 @@
|
|||||||
# it under the terms of the GNU General Public License version 2 as
|
# it under the terms of the GNU General Public License version 2 as
|
||||||
# published by the Free Software Foundation.
|
# published by the Free Software Foundation.
|
||||||
|
|
||||||
"""Extract images from https://www.2chan.net/"""
|
"""Extractors for https://www.2chan.net/"""
|
||||||
|
|
||||||
from .common import Extractor, Message
|
from .common import Extractor, Message
|
||||||
from .. import text
|
from .. import text
|
||||||
|
|
||||||
|
|
||||||
class FutabaThreadExtractor(Extractor):
|
class _2chanThreadExtractor(Extractor):
|
||||||
"""Extractor for images from threads on www.2chan.net"""
|
"""Extractor for images from threads on www.2chan.net"""
|
||||||
category = "2chan"
|
category = "2chan"
|
||||||
subcategory = "thread"
|
subcategory = "thread"
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
from . import booru
|
from . import booru
|
||||||
|
|
||||||
|
|
||||||
class ThreedeebooruExtractor(booru.MoebooruPageMixin, booru.BooruExtractor):
|
class _3dbooruExtractor(booru.MoebooruPageMixin, booru.BooruExtractor):
|
||||||
"""Base class for 3dbooru extractors"""
|
"""Base class for 3dbooru extractors"""
|
||||||
category = "3dbooru"
|
category = "3dbooru"
|
||||||
api_url = "http://behoimi.org/post/index.json"
|
api_url = "http://behoimi.org/post/index.json"
|
||||||
@@ -26,8 +26,7 @@ class ThreedeebooruExtractor(booru.MoebooruPageMixin, booru.BooruExtractor):
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
class ThreedeebooruTagExtractor(booru.TagMixin,
|
class _3dbooruTagExtractor(booru.TagMixin, _3dbooruExtractor):
|
||||||
ThreedeebooruExtractor):
|
|
||||||
"""Extractor for images from behoimi.org based on search-tags"""
|
"""Extractor for images from behoimi.org based on search-tags"""
|
||||||
pattern = (r"(?:https?://)?(?:www\.)?behoimi\.org/post"
|
pattern = (r"(?:https?://)?(?:www\.)?behoimi\.org/post"
|
||||||
r"(?:/(?:index)?)?\?tags=(?P<tags>[^&#]+)")
|
r"(?:/(?:index)?)?\?tags=(?P<tags>[^&#]+)")
|
||||||
@@ -37,8 +36,7 @@ class ThreedeebooruTagExtractor(booru.TagMixin,
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
class ThreedeebooruPoolExtractor(booru.PoolMixin,
|
class _3dbooruPoolExtractor(booru.PoolMixin, _3dbooruExtractor):
|
||||||
ThreedeebooruExtractor):
|
|
||||||
"""Extractor for image-pools from behoimi.org"""
|
"""Extractor for image-pools from behoimi.org"""
|
||||||
pattern = r"(?:https?://)?(?:www\.)?behoimi\.org/pool/show/(?P<pool>\d+)"
|
pattern = r"(?:https?://)?(?:www\.)?behoimi\.org/pool/show/(?P<pool>\d+)"
|
||||||
test = ("http://behoimi.org/pool/show/27", {
|
test = ("http://behoimi.org/pool/show/27", {
|
||||||
@@ -47,8 +45,7 @@ class ThreedeebooruPoolExtractor(booru.PoolMixin,
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
class ThreedeebooruPostExtractor(booru.PostMixin,
|
class _3dbooruPostExtractor(booru.PostMixin, _3dbooruExtractor):
|
||||||
ThreedeebooruExtractor):
|
|
||||||
"""Extractor for single images from behoimi.org"""
|
"""Extractor for single images from behoimi.org"""
|
||||||
pattern = r"(?:https?://)?(?:www\.)?behoimi\.org/post/show/(?P<post>\d+)"
|
pattern = r"(?:https?://)?(?:www\.)?behoimi\.org/post/show/(?P<post>\d+)"
|
||||||
test = ("http://behoimi.org/post/show/140852", {
|
test = ("http://behoimi.org/post/show/140852", {
|
||||||
@@ -64,8 +61,7 @@ class ThreedeebooruPostExtractor(booru.PostMixin,
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
class ThreedeebooruPopularExtractor(booru.MoebooruPopularMixin,
|
class _3dbooruPopularExtractor(booru.MoebooruPopularMixin, _3dbooruExtractor):
|
||||||
ThreedeebooruExtractor):
|
|
||||||
"""Extractor for popular images from behoimi.org"""
|
"""Extractor for popular images from behoimi.org"""
|
||||||
pattern = (r"(?:https?://)?(?:www\.)?behoimi\.org"
|
pattern = (r"(?:https?://)?(?:www\.)?behoimi\.org"
|
||||||
r"/post/popular_(?P<scale>by_(?:day|week|month)|recent)"
|
r"/post/popular_(?P<scale>by_(?:day|week|month)|recent)"
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ class FoolfuukaThreadExtractor(SharedConfigMixin, Extractor):
|
|||||||
|
|
||||||
EXTRACTORS = {
|
EXTRACTORS = {
|
||||||
"4plebs": {
|
"4plebs": {
|
||||||
"name": "fourplebs",
|
"name": "_4plebs",
|
||||||
"root": "https://archive.4plebs.org",
|
"root": "https://archive.4plebs.org",
|
||||||
"pattern": r"(?:archive\.)?4plebs\.org",
|
"pattern": r"(?:archive\.)?4plebs\.org",
|
||||||
"test-thread": ("https://archive.4plebs.org/tg/thread/54059290", {
|
"test-thread": ("https://archive.4plebs.org/tg/thread/54059290", {
|
||||||
|
|||||||
@@ -157,22 +157,12 @@ class TestExtractor(unittest.TestCase):
|
|||||||
def capitalize(c):
|
def capitalize(c):
|
||||||
if "-" in c:
|
if "-" in c:
|
||||||
return string.capwords(c.replace("-", " ")).replace(" ", "")
|
return string.capwords(c.replace("-", " ")).replace(" ", "")
|
||||||
if "." in c:
|
|
||||||
c = c.replace(".", "")
|
|
||||||
return c.capitalize()
|
return c.capitalize()
|
||||||
|
|
||||||
mapping = {
|
|
||||||
"2chan" : "futaba",
|
|
||||||
"3dbooru": "threedeebooru",
|
|
||||||
"4plebs" : "fourplebs",
|
|
||||||
"oauth" : None,
|
|
||||||
}
|
|
||||||
|
|
||||||
for extr in extractor.extractors():
|
for extr in extractor.extractors():
|
||||||
category = mapping.get(extr.category, extr.category)
|
if extr.category not in ("", "oauth"):
|
||||||
if category:
|
|
||||||
expected = "{}{}Extractor".format(
|
expected = "{}{}Extractor".format(
|
||||||
capitalize(category),
|
capitalize(extr.category),
|
||||||
capitalize(extr.subcategory),
|
capitalize(extr.subcategory),
|
||||||
)
|
)
|
||||||
if expected[0].isdigit():
|
if expected[0].isdigit():
|
||||||
|
|||||||
Reference in New Issue
Block a user