Skip to content

Commit

Permalink
rename extractor classes starting with a digit
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Nov 2, 2019
1 parent b3b9da6 commit 2a3bd4e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 24 deletions.
4 changes: 2 additions & 2 deletions gallery_dl/extractor/2chan.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
# it under the terms of the GNU General Public License version 2 as
# 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 .. import text


class FutabaThreadExtractor(Extractor):
class _2chanThreadExtractor(Extractor):
"""Extractor for images from threads on www.2chan.net"""
category = "2chan"
subcategory = "thread"
Expand Down
14 changes: 5 additions & 9 deletions gallery_dl/extractor/3dbooru.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from . import booru


class ThreedeebooruExtractor(booru.MoebooruPageMixin, booru.BooruExtractor):
class _3dbooruExtractor(booru.MoebooruPageMixin, booru.BooruExtractor):
"""Base class for 3dbooru extractors"""
category = "3dbooru"
api_url = "http://behoimi.org/post/index.json"
Expand All @@ -26,8 +26,7 @@ def __init__(self, match):
})


class ThreedeebooruTagExtractor(booru.TagMixin,
ThreedeebooruExtractor):
class _3dbooruTagExtractor(booru.TagMixin, _3dbooruExtractor):
"""Extractor for images from behoimi.org based on search-tags"""
pattern = (r"(?:https?://)?(?:www\.)?behoimi\.org/post"
r"(?:/(?:index)?)?\?tags=(?P<tags>[^&#]+)")
Expand All @@ -37,8 +36,7 @@ class ThreedeebooruTagExtractor(booru.TagMixin,
})


class ThreedeebooruPoolExtractor(booru.PoolMixin,
ThreedeebooruExtractor):
class _3dbooruPoolExtractor(booru.PoolMixin, _3dbooruExtractor):
"""Extractor for image-pools from behoimi.org"""
pattern = r"(?:https?://)?(?:www\.)?behoimi\.org/pool/show/(?P<pool>\d+)"
test = ("http://behoimi.org/pool/show/27", {
Expand All @@ -47,8 +45,7 @@ class ThreedeebooruPoolExtractor(booru.PoolMixin,
})


class ThreedeebooruPostExtractor(booru.PostMixin,
ThreedeebooruExtractor):
class _3dbooruPostExtractor(booru.PostMixin, _3dbooruExtractor):
"""Extractor for single images from behoimi.org"""
pattern = r"(?:https?://)?(?:www\.)?behoimi\.org/post/show/(?P<post>\d+)"
test = ("http://behoimi.org/post/show/140852", {
Expand All @@ -64,8 +61,7 @@ class ThreedeebooruPostExtractor(booru.PostMixin,
})


class ThreedeebooruPopularExtractor(booru.MoebooruPopularMixin,
ThreedeebooruExtractor):
class _3dbooruPopularExtractor(booru.MoebooruPopularMixin, _3dbooruExtractor):
"""Extractor for popular images from behoimi.org"""
pattern = (r"(?:https?://)?(?:www\.)?behoimi\.org"
r"/post/popular_(?P<scale>by_(?:day|week|month)|recent)"
Expand Down
2 changes: 1 addition & 1 deletion gallery_dl/extractor/foolfuuka.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def _remote_direct(media):

EXTRACTORS = {
"4plebs": {
"name": "fourplebs",
"name": "_4plebs",
"root": "https://archive.4plebs.org",
"pattern": r"(?:archive\.)?4plebs\.org",
"test-thread": ("https://archive.4plebs.org/tg/thread/54059290", {
Expand Down
14 changes: 2 additions & 12 deletions test/test_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,22 +157,12 @@ def test_names(self):
def capitalize(c):
if "-" in c:
return string.capwords(c.replace("-", " ")).replace(" ", "")
if "." in c:
c = c.replace(".", "")
return c.capitalize()

mapping = {
"2chan" : "futaba",
"3dbooru": "threedeebooru",
"4plebs" : "fourplebs",
"oauth" : None,
}

for extr in extractor.extractors():
category = mapping.get(extr.category, extr.category)
if category:
if extr.category not in ("", "oauth"):
expected = "{}{}Extractor".format(
capitalize(category),
capitalize(extr.category),
capitalize(extr.subcategory),
)
if expected[0].isdigit():
Expand Down

0 comments on commit 2a3bd4e

Please sign in to comment.