put common directory- and filename formats in base classes
This commit is contained in:
@@ -17,6 +17,7 @@ import urllib.parse
|
|||||||
|
|
||||||
class BooruExtractor(Extractor):
|
class BooruExtractor(Extractor):
|
||||||
"""Base class for all booru extractors"""
|
"""Base class for all booru extractors"""
|
||||||
|
filename_fmt = "{category}_{id}_{md5}.{extension}"
|
||||||
info = {}
|
info = {}
|
||||||
headers = {}
|
headers = {}
|
||||||
pagestart = 1
|
pagestart = 1
|
||||||
@@ -113,7 +114,6 @@ class XMLBooruExtractor(BooruExtractor):
|
|||||||
class BooruTagExtractor(BooruExtractor):
|
class BooruTagExtractor(BooruExtractor):
|
||||||
"""Extractor for images based on search-tags"""
|
"""Extractor for images based on search-tags"""
|
||||||
directory_fmt = ["{category}", "{tags}"]
|
directory_fmt = ["{category}", "{tags}"]
|
||||||
filename_fmt = "{category}_{id}_{md5}.{extension}"
|
|
||||||
|
|
||||||
def __init__(self, match):
|
def __init__(self, match):
|
||||||
BooruExtractor.__init__(self)
|
BooruExtractor.__init__(self)
|
||||||
@@ -127,7 +127,6 @@ class BooruTagExtractor(BooruExtractor):
|
|||||||
class BooruPoolExtractor(BooruExtractor):
|
class BooruPoolExtractor(BooruExtractor):
|
||||||
"""Extractor for image-pools"""
|
"""Extractor for image-pools"""
|
||||||
directory_fmt = ["{category}", "pool", "{pool}"]
|
directory_fmt = ["{category}", "pool", "{pool}"]
|
||||||
filename_fmt = "{category}_{id}_{md5}.{extension}"
|
|
||||||
|
|
||||||
def __init__(self, match):
|
def __init__(self, match):
|
||||||
BooruExtractor.__init__(self)
|
BooruExtractor.__init__(self)
|
||||||
@@ -140,9 +139,6 @@ class BooruPoolExtractor(BooruExtractor):
|
|||||||
|
|
||||||
class BooruPostExtractor(BooruExtractor):
|
class BooruPostExtractor(BooruExtractor):
|
||||||
"""Extractor for single images"""
|
"""Extractor for single images"""
|
||||||
directory_fmt = ["{category}"]
|
|
||||||
filename_fmt = "{category}_{id}_{md5}.{extension}"
|
|
||||||
|
|
||||||
def __init__(self, match):
|
def __init__(self, match):
|
||||||
BooruExtractor.__init__(self)
|
BooruExtractor.__init__(self)
|
||||||
self.post = match.group(1)
|
self.post = match.group(1)
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ class Extractor():
|
|||||||
|
|
||||||
category = ""
|
category = ""
|
||||||
subcategory = ""
|
subcategory = ""
|
||||||
directory_fmt = [""]
|
directory_fmt = ["{category}"]
|
||||||
filename_fmt = ""
|
filename_fmt = "{filename}"
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.session = requests.Session()
|
self.session = requests.Session()
|
||||||
|
|||||||
@@ -15,8 +15,6 @@ from .. import text
|
|||||||
class DirectlinkExtractor(Extractor):
|
class DirectlinkExtractor(Extractor):
|
||||||
"""Extractor for direct links to images"""
|
"""Extractor for direct links to images"""
|
||||||
category = "directlink"
|
category = "directlink"
|
||||||
directory_fmt = []
|
|
||||||
filename_fmt = "{filename}"
|
|
||||||
pattern = [r"https?://[^?&#]+\.(?:jpe?g|png|gif|webm|mp4|ogg)"]
|
pattern = [r"https?://[^?&#]+\.(?:jpe?g|png|gif|webm|mp4|ogg)"]
|
||||||
test = [(("https://photos.smugmug.com/The-World/Hawaii/"
|
test = [(("https://photos.smugmug.com/The-World/Hawaii/"
|
||||||
"i-SWz2K6n/2/X3/IMG_0311-X3.jpg"), {
|
"i-SWz2K6n/2/X3/IMG_0311-X3.jpg"), {
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ class GfycatExtractor(Extractor):
|
|||||||
class GfycatImageExtractor(GfycatExtractor):
|
class GfycatImageExtractor(GfycatExtractor):
|
||||||
"""Extractor for individual images from gfycat.com"""
|
"""Extractor for individual images from gfycat.com"""
|
||||||
subcategory = "image"
|
subcategory = "image"
|
||||||
directory_fmt = ["{category}"]
|
|
||||||
filename_fmt = "{category}_{gfyName}.{extension}"
|
filename_fmt = "{category}_{gfyName}.{extension}"
|
||||||
pattern = [r"(?:https?://)?(?:[a-z]+\.)?gfycat\.com/"
|
pattern = [r"(?:https?://)?(?:[a-z]+\.)?gfycat\.com/"
|
||||||
r"(?:(?:gifs/)?detail/|ifr/)?([A-Za-z]+)"]
|
r"(?:(?:gifs/)?detail/|ifr/)?([A-Za-z]+)"]
|
||||||
|
|||||||
@@ -74,8 +74,6 @@ class ImagebamImageExtractor(Extractor):
|
|||||||
"""Extractor for single images from imagebam.com"""
|
"""Extractor for single images from imagebam.com"""
|
||||||
category = "imagebam"
|
category = "imagebam"
|
||||||
subcategory = "image"
|
subcategory = "image"
|
||||||
directory_fmt = ["{category}"]
|
|
||||||
filename_fmt = "{filename}"
|
|
||||||
pattern = [r"(?:https?://)?(?:www\.)?imagebam\.com/image/([0-9a-f]{15})"]
|
pattern = [r"(?:https?://)?(?:www\.)?imagebam\.com/image/([0-9a-f]{15})"]
|
||||||
test = [("http://www.imagebam.com/image/94d56c502511890", {
|
test = [("http://www.imagebam.com/image/94d56c502511890", {
|
||||||
"url": "94add9417c685d113a91bcdda4916e9538b5f8a9",
|
"url": "94add9417c685d113a91bcdda4916e9538b5f8a9",
|
||||||
|
|||||||
@@ -18,8 +18,6 @@ from urllib.parse import urljoin
|
|||||||
class ImagehostImageExtractor(Extractor):
|
class ImagehostImageExtractor(Extractor):
|
||||||
"""Base class for single-image extractors for various imagehosts"""
|
"""Base class for single-image extractors for various imagehosts"""
|
||||||
subcategory = "image"
|
subcategory = "image"
|
||||||
directory_fmt = ["{category}"]
|
|
||||||
filename_fmt = "{filename}"
|
|
||||||
https = False
|
https = False
|
||||||
method = "post"
|
method = "post"
|
||||||
params = "simple"
|
params = "simple"
|
||||||
|
|||||||
@@ -82,8 +82,6 @@ class ImgboxImageExtractor(Extractor):
|
|||||||
"""Extractor for single images from imgbox.com"""
|
"""Extractor for single images from imgbox.com"""
|
||||||
category = "imgbox"
|
category = "imgbox"
|
||||||
subcategory = "image"
|
subcategory = "image"
|
||||||
directory_fmt = ["{category}"]
|
|
||||||
filename_fmt = "{filename}"
|
|
||||||
pattern = [r"(?:https?://)?(?:www\.)?imgbox\.com/([A-Za-z0-9]{8})"]
|
pattern = [r"(?:https?://)?(?:www\.)?imgbox\.com/([A-Za-z0-9]{8})"]
|
||||||
test = [
|
test = [
|
||||||
("https://imgbox.com/qHhw7lpG", {
|
("https://imgbox.com/qHhw7lpG", {
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ from .. import text
|
|||||||
class ImgchiliExtractor(Extractor):
|
class ImgchiliExtractor(Extractor):
|
||||||
"""Base class for imgchili extractors"""
|
"""Base class for imgchili extractors"""
|
||||||
category = "imgchili"
|
category = "imgchili"
|
||||||
directory_fmt = ["{category}"]
|
|
||||||
url_base = "https://imgchili.net/"
|
url_base = "https://imgchili.net/"
|
||||||
|
|
||||||
def __init__(self, match):
|
def __init__(self, match):
|
||||||
@@ -46,7 +45,6 @@ class ImgchiliExtractor(Extractor):
|
|||||||
class ImgchiliImageExtractor(ImgchiliExtractor):
|
class ImgchiliImageExtractor(ImgchiliExtractor):
|
||||||
"""Extractor for single images from imgchili.net"""
|
"""Extractor for single images from imgchili.net"""
|
||||||
subcategory = "image"
|
subcategory = "image"
|
||||||
filename_fmt = "{filename}"
|
|
||||||
pattern = [r"(?:https?://)?(?:www\.)?imgchili\.net/show/\d+/(\d+)_[^/]+"]
|
pattern = [r"(?:https?://)?(?:www\.)?imgchili\.net/show/\d+/(\d+)_[^/]+"]
|
||||||
test = [(("http://imgchili.net/show/89427/"
|
test = [(("http://imgchili.net/show/89427/"
|
||||||
"89427136_test___quot;___gt;.png"), {
|
"89427136_test___quot;___gt;.png"), {
|
||||||
|
|||||||
@@ -54,7 +54,6 @@ class ImgurImageExtractor(ImgurExtractor):
|
|||||||
"""Extractor for individual images from imgur.com"""
|
"""Extractor for individual images from imgur.com"""
|
||||||
category = "imgur"
|
category = "imgur"
|
||||||
subcategory = "image"
|
subcategory = "image"
|
||||||
directory_fmt = ["{category}"]
|
|
||||||
filename_fmt = "{category}_{hash}.{extension}"
|
filename_fmt = "{category}_{hash}.{extension}"
|
||||||
pattern = [(r"(?:https?://)?(?:m\.|www\.)?imgur\.com/"
|
pattern = [(r"(?:https?://)?(?:m\.|www\.)?imgur\.com/"
|
||||||
r"(?:gallery/)?((?!gallery)[^/?&#]{7})/?"),
|
r"(?:gallery/)?((?!gallery)[^/?&#]{7})/?"),
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ class KhinsiderSoundtrackExtractor(AsynchronousExtractor):
|
|||||||
category = "khinsider"
|
category = "khinsider"
|
||||||
subcategory = "soundtrack"
|
subcategory = "soundtrack"
|
||||||
directory_fmt = ["{category}", "{album}"]
|
directory_fmt = ["{category}", "{album}"]
|
||||||
filename_fmt = "{filename}"
|
|
||||||
pattern = [r"(?:https?://)?downloads\.khinsider\.com/"
|
pattern = [r"(?:https?://)?downloads\.khinsider\.com/"
|
||||||
r"game-soundtracks/album/(.+)"]
|
r"game-soundtracks/album/(.+)"]
|
||||||
test = [(("http://downloads.khinsider.com/game-soundtracks/"
|
test = [(("http://downloads.khinsider.com/game-soundtracks/"
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ from .. import text, exception
|
|||||||
class PinterestExtractor(Extractor):
|
class PinterestExtractor(Extractor):
|
||||||
"""Base class for pinterest extractors"""
|
"""Base class for pinterest extractors"""
|
||||||
category = "pinterest"
|
category = "pinterest"
|
||||||
directory_fmt = ["{category}"]
|
|
||||||
filename_fmt = "{category}_{pin-id}.{extension}"
|
filename_fmt = "{category}_{pin-id}.{extension}"
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|||||||
@@ -114,7 +114,6 @@ class SeigaUserExtractor(SeigaExtractor):
|
|||||||
class SeigaImageExtractor(SeigaExtractor):
|
class SeigaImageExtractor(SeigaExtractor):
|
||||||
"""Extractor for single images from seiga.nicovideo.jp"""
|
"""Extractor for single images from seiga.nicovideo.jp"""
|
||||||
subcategory = "image"
|
subcategory = "image"
|
||||||
directory_fmt = ["{category}"]
|
|
||||||
filename_fmt = "{category}_{image-id}.{extension}"
|
filename_fmt = "{category}_{image-id}.{extension}"
|
||||||
pattern = [(r"(?:https?://)?(?:www\.|seiga\.)?nicovideo\.jp/"
|
pattern = [(r"(?:https?://)?(?:www\.|seiga\.)?nicovideo\.jp/"
|
||||||
r"(?:seiga/im|image/source/)(\d+)"),
|
r"(?:seiga/im|image/source/)(\d+)"),
|
||||||
|
|||||||
Reference in New Issue
Block a user