From c184e47ee3b599819f4af4cb5ce04c79e4310dbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Tue, 30 May 2017 12:10:16 +0200 Subject: [PATCH] put common directory- and filename formats in base classes --- gallery_dl/extractor/booru.py | 6 +----- gallery_dl/extractor/common.py | 4 ++-- gallery_dl/extractor/directlink.py | 2 -- gallery_dl/extractor/gfycat.py | 1 - gallery_dl/extractor/imagebam.py | 2 -- gallery_dl/extractor/imagehosts.py | 2 -- gallery_dl/extractor/imgbox.py | 2 -- gallery_dl/extractor/imgchili.py | 2 -- gallery_dl/extractor/imgur.py | 1 - gallery_dl/extractor/khinsider.py | 1 - gallery_dl/extractor/pinterest.py | 1 - gallery_dl/extractor/seiga.py | 1 - 12 files changed, 3 insertions(+), 22 deletions(-) diff --git a/gallery_dl/extractor/booru.py b/gallery_dl/extractor/booru.py index bc86a33c..36fbfb15 100644 --- a/gallery_dl/extractor/booru.py +++ b/gallery_dl/extractor/booru.py @@ -17,6 +17,7 @@ import urllib.parse class BooruExtractor(Extractor): """Base class for all booru extractors""" + filename_fmt = "{category}_{id}_{md5}.{extension}" info = {} headers = {} pagestart = 1 @@ -113,7 +114,6 @@ class XMLBooruExtractor(BooruExtractor): class BooruTagExtractor(BooruExtractor): """Extractor for images based on search-tags""" directory_fmt = ["{category}", "{tags}"] - filename_fmt = "{category}_{id}_{md5}.{extension}" def __init__(self, match): BooruExtractor.__init__(self) @@ -127,7 +127,6 @@ class BooruTagExtractor(BooruExtractor): class BooruPoolExtractor(BooruExtractor): """Extractor for image-pools""" directory_fmt = ["{category}", "pool", "{pool}"] - filename_fmt = "{category}_{id}_{md5}.{extension}" def __init__(self, match): BooruExtractor.__init__(self) @@ -140,9 +139,6 @@ class BooruPoolExtractor(BooruExtractor): class BooruPostExtractor(BooruExtractor): """Extractor for single images""" - directory_fmt = ["{category}"] - filename_fmt = "{category}_{id}_{md5}.{extension}" - def __init__(self, match): BooruExtractor.__init__(self) self.post = match.group(1) diff --git a/gallery_dl/extractor/common.py b/gallery_dl/extractor/common.py index ab299fc8..320b170f 100644 --- a/gallery_dl/extractor/common.py +++ b/gallery_dl/extractor/common.py @@ -22,8 +22,8 @@ class Extractor(): category = "" subcategory = "" - directory_fmt = [""] - filename_fmt = "" + directory_fmt = ["{category}"] + filename_fmt = "{filename}" def __init__(self): self.session = requests.Session() diff --git a/gallery_dl/extractor/directlink.py b/gallery_dl/extractor/directlink.py index 4870cd73..3161e373 100644 --- a/gallery_dl/extractor/directlink.py +++ b/gallery_dl/extractor/directlink.py @@ -15,8 +15,6 @@ from .. import text class DirectlinkExtractor(Extractor): """Extractor for direct links to images""" category = "directlink" - directory_fmt = [] - filename_fmt = "{filename}" pattern = [r"https?://[^?&#]+\.(?:jpe?g|png|gif|webm|mp4|ogg)"] test = [(("https://photos.smugmug.com/The-World/Hawaii/" "i-SWz2K6n/2/X3/IMG_0311-X3.jpg"), { diff --git a/gallery_dl/extractor/gfycat.py b/gallery_dl/extractor/gfycat.py index 364c0b40..10e02492 100644 --- a/gallery_dl/extractor/gfycat.py +++ b/gallery_dl/extractor/gfycat.py @@ -39,7 +39,6 @@ class GfycatExtractor(Extractor): class GfycatImageExtractor(GfycatExtractor): """Extractor for individual images from gfycat.com""" subcategory = "image" - directory_fmt = ["{category}"] filename_fmt = "{category}_{gfyName}.{extension}" pattern = [r"(?:https?://)?(?:[a-z]+\.)?gfycat\.com/" r"(?:(?:gifs/)?detail/|ifr/)?([A-Za-z]+)"] diff --git a/gallery_dl/extractor/imagebam.py b/gallery_dl/extractor/imagebam.py index 3e27f591..2dd39c8d 100644 --- a/gallery_dl/extractor/imagebam.py +++ b/gallery_dl/extractor/imagebam.py @@ -74,8 +74,6 @@ class ImagebamImageExtractor(Extractor): """Extractor for single images from imagebam.com""" category = "imagebam" subcategory = "image" - directory_fmt = ["{category}"] - filename_fmt = "{filename}" pattern = [r"(?:https?://)?(?:www\.)?imagebam\.com/image/([0-9a-f]{15})"] test = [("http://www.imagebam.com/image/94d56c502511890", { "url": "94add9417c685d113a91bcdda4916e9538b5f8a9", diff --git a/gallery_dl/extractor/imagehosts.py b/gallery_dl/extractor/imagehosts.py index d2527f4c..c3494237 100644 --- a/gallery_dl/extractor/imagehosts.py +++ b/gallery_dl/extractor/imagehosts.py @@ -18,8 +18,6 @@ from urllib.parse import urljoin class ImagehostImageExtractor(Extractor): """Base class for single-image extractors for various imagehosts""" subcategory = "image" - directory_fmt = ["{category}"] - filename_fmt = "{filename}" https = False method = "post" params = "simple" diff --git a/gallery_dl/extractor/imgbox.py b/gallery_dl/extractor/imgbox.py index bd29f515..dddee7e7 100644 --- a/gallery_dl/extractor/imgbox.py +++ b/gallery_dl/extractor/imgbox.py @@ -82,8 +82,6 @@ class ImgboxImageExtractor(Extractor): """Extractor for single images from imgbox.com""" category = "imgbox" subcategory = "image" - directory_fmt = ["{category}"] - filename_fmt = "{filename}" pattern = [r"(?:https?://)?(?:www\.)?imgbox\.com/([A-Za-z0-9]{8})"] test = [ ("https://imgbox.com/qHhw7lpG", { diff --git a/gallery_dl/extractor/imgchili.py b/gallery_dl/extractor/imgchili.py index 333123cb..18501ef1 100644 --- a/gallery_dl/extractor/imgchili.py +++ b/gallery_dl/extractor/imgchili.py @@ -15,7 +15,6 @@ from .. import text class ImgchiliExtractor(Extractor): """Base class for imgchili extractors""" category = "imgchili" - directory_fmt = ["{category}"] url_base = "https://imgchili.net/" def __init__(self, match): @@ -46,7 +45,6 @@ class ImgchiliExtractor(Extractor): class ImgchiliImageExtractor(ImgchiliExtractor): """Extractor for single images from imgchili.net""" subcategory = "image" - filename_fmt = "{filename}" pattern = [r"(?:https?://)?(?:www\.)?imgchili\.net/show/\d+/(\d+)_[^/]+"] test = [(("http://imgchili.net/show/89427/" "89427136_test___quot;___gt;.png"), { diff --git a/gallery_dl/extractor/imgur.py b/gallery_dl/extractor/imgur.py index 96458298..f2599aa8 100644 --- a/gallery_dl/extractor/imgur.py +++ b/gallery_dl/extractor/imgur.py @@ -54,7 +54,6 @@ class ImgurImageExtractor(ImgurExtractor): """Extractor for individual images from imgur.com""" category = "imgur" subcategory = "image" - directory_fmt = ["{category}"] filename_fmt = "{category}_{hash}.{extension}" pattern = [(r"(?:https?://)?(?:m\.|www\.)?imgur\.com/" r"(?:gallery/)?((?!gallery)[^/?&#]{7})/?"), diff --git a/gallery_dl/extractor/khinsider.py b/gallery_dl/extractor/khinsider.py index dcca08aa..e8881f88 100644 --- a/gallery_dl/extractor/khinsider.py +++ b/gallery_dl/extractor/khinsider.py @@ -17,7 +17,6 @@ class KhinsiderSoundtrackExtractor(AsynchronousExtractor): category = "khinsider" subcategory = "soundtrack" directory_fmt = ["{category}", "{album}"] - filename_fmt = "{filename}" pattern = [r"(?:https?://)?downloads\.khinsider\.com/" r"game-soundtracks/album/(.+)"] test = [(("http://downloads.khinsider.com/game-soundtracks/" diff --git a/gallery_dl/extractor/pinterest.py b/gallery_dl/extractor/pinterest.py index daf72658..66016cf6 100644 --- a/gallery_dl/extractor/pinterest.py +++ b/gallery_dl/extractor/pinterest.py @@ -15,7 +15,6 @@ from .. import text, exception class PinterestExtractor(Extractor): """Base class for pinterest extractors""" category = "pinterest" - directory_fmt = ["{category}"] filename_fmt = "{category}_{pin-id}.{extension}" def __init__(self): diff --git a/gallery_dl/extractor/seiga.py b/gallery_dl/extractor/seiga.py index fce82223..570e9a01 100644 --- a/gallery_dl/extractor/seiga.py +++ b/gallery_dl/extractor/seiga.py @@ -114,7 +114,6 @@ class SeigaUserExtractor(SeigaExtractor): class SeigaImageExtractor(SeigaExtractor): """Extractor for single images from seiga.nicovideo.jp""" subcategory = "image" - directory_fmt = ["{category}"] filename_fmt = "{category}_{image-id}.{extension}" pattern = [(r"(?:https?://)?(?:www\.|seiga\.)?nicovideo\.jp/" r"(?:seiga/im|image/source/)(\d+)"),