add common config category for boorus and foolslide
This commit is contained in:
parent
c0755a4d5e
commit
be30fb2f98
@ -8,15 +8,16 @@
|
||||
|
||||
"""Base classes for extractors for danbooru and co"""
|
||||
|
||||
from .common import Extractor, Message
|
||||
from .common import SharedConfigExtractor, Message
|
||||
from .. import text
|
||||
import xml.etree.ElementTree as ET
|
||||
import urllib.parse
|
||||
import datetime
|
||||
|
||||
|
||||
class BooruExtractor(Extractor):
|
||||
class BooruExtractor(SharedConfigExtractor):
|
||||
"""Base class for all booru extractors"""
|
||||
basecategory = "booru"
|
||||
filename_fmt = "{category}_{id}_{md5}.{extension}"
|
||||
headers = {}
|
||||
pagestart = 1
|
||||
@ -24,7 +25,7 @@ class BooruExtractor(Extractor):
|
||||
api_url = ""
|
||||
|
||||
def __init__(self):
|
||||
Extractor.__init__(self)
|
||||
SharedConfigExtractor.__init__(self)
|
||||
self.session.headers.update(self.headers)
|
||||
self.params = {"limit": 50}
|
||||
self.setup()
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
"""Base classes for extractors for different Futaba Channel-like boards"""
|
||||
|
||||
from .common import Extractor, Message
|
||||
from .common import Extractor, SharedConfigExtractor, Message
|
||||
from .. import text
|
||||
import itertools
|
||||
import operator
|
||||
@ -62,9 +62,9 @@ class ChanThreadExtractor(Extractor):
|
||||
return text.unescape(title)[:50]
|
||||
|
||||
|
||||
class FoolfuukaThreadExtractor(Extractor):
|
||||
class FoolfuukaThreadExtractor(SharedConfigExtractor):
|
||||
"""Base extractor for FoolFuuka based boards/archives"""
|
||||
category = "foolfuuka"
|
||||
basecategory = "foolfuuka"
|
||||
subcategory = "thread"
|
||||
directory_fmt = ["{category}", "{board[shortname]}",
|
||||
"{thread_num} - {title}"]
|
||||
@ -72,19 +72,11 @@ class FoolfuukaThreadExtractor(Extractor):
|
||||
root = ""
|
||||
|
||||
def __init__(self, match):
|
||||
Extractor.__init__(self)
|
||||
SharedConfigExtractor.__init__(self)
|
||||
self.board, self.thread = match.groups()
|
||||
self.session.headers["User-Agent"] = "Mozilla 5.0"
|
||||
self.session.headers["Referer"] = self.root
|
||||
|
||||
def config(self, key, default=None, sentinel=object()):
|
||||
value = Extractor.config(self, key, sentinel)
|
||||
if value is sentinel:
|
||||
cat, self.category = self.category, "foolfuuka"
|
||||
value = Extractor.config(self, key, default)
|
||||
self.category = cat
|
||||
return value
|
||||
|
||||
def items(self):
|
||||
op = True
|
||||
yield Message.Version, 1
|
||||
|
@ -175,6 +175,19 @@ class MangaExtractor(Extractor):
|
||||
return []
|
||||
|
||||
|
||||
class SharedConfigExtractor(Extractor):
|
||||
|
||||
basecategory = ""
|
||||
|
||||
def config(self, key, default=None, sentinel=object()):
|
||||
value = Extractor.config(self, key, sentinel)
|
||||
if value is sentinel:
|
||||
cat, self.category = self.category, self.basecategory
|
||||
value = Extractor.config(self, key, default)
|
||||
self.category = cat
|
||||
return value
|
||||
|
||||
|
||||
# Reduce strictness of the expected magic string in cookiejar files.
|
||||
# (This allows the use of Wget-generated cookiejars without modification)
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
"""Base classes for extractors for FoOlSlide based sites"""
|
||||
|
||||
from .common import Extractor, MangaExtractor, Message
|
||||
from .common import SharedConfigExtractor, MangaExtractor, Message
|
||||
from .. import text, util
|
||||
import json
|
||||
|
||||
@ -34,8 +34,9 @@ def manga_pattern(domain_re):
|
||||
return [r"(?:https?://)?(" + domain_re + MANGA_RE]
|
||||
|
||||
|
||||
class FoolslideChapterExtractor(Extractor):
|
||||
class FoolslideChapterExtractor(SharedConfigExtractor):
|
||||
"""Base class for chapter extractors for FoOlSlide based sites"""
|
||||
basecategory = "foolslide"
|
||||
subcategory = "chapter"
|
||||
directory_fmt = ["{category}", "{manga}", "{chapter_string}"]
|
||||
filename_fmt = "{manga}_{chapter:>03}_{page:>03}.{extension}"
|
||||
@ -43,7 +44,7 @@ class FoolslideChapterExtractor(Extractor):
|
||||
single = True
|
||||
|
||||
def __init__(self, match, url=None):
|
||||
Extractor.__init__(self)
|
||||
SharedConfigExtractor.__init__(self)
|
||||
self.url = url or self.scheme + "://" + match.group(1)
|
||||
self.data = match.groupdict(default="")
|
||||
|
||||
@ -94,7 +95,7 @@ class FoolslideChapterExtractor(Extractor):
|
||||
return json.loads(text.extract(page, needle, ";", pos)[0])
|
||||
|
||||
|
||||
class FoolslideMangaExtractor(MangaExtractor):
|
||||
class FoolslideMangaExtractor(MangaExtractor, SharedConfigExtractor):
|
||||
"""Base class for manga extractors for FoOlSlide based sites"""
|
||||
scheme = "https"
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user