simplify extractor constants

- single strings for URL patterns
- tuples instead of lists for 'directory_fmt' and 'test'
- single-tuple tests where applicable
This commit is contained in:
Mike Fährmann
2019-02-08 13:45:40 +01:00
parent 34bab080ae
commit 6284731107
84 changed files with 1080 additions and 1108 deletions

View File

@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright 2014-2018 Mike Fährmann
# Copyright 2014-2019 Mike Fährmann
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
@@ -30,11 +30,11 @@ class ImagebamExtractor(Extractor):
class ImagebamGalleryExtractor(ImagebamExtractor):
"""Extractor for image galleries from imagebam.com"""
subcategory = "gallery"
directory_fmt = ["{category}", "{title} - {gallery_key}"]
directory_fmt = ("{category}", "{title} - {gallery_key}")
filename_fmt = "{num:>03}-{image_key}.{extension}"
archive_fmt = "{gallery_key}_{image_key}"
pattern = [r"(?:https?://)?(?:www\.)?imagebam\.com/gallery/([0-9a-z]+)"]
test = [
pattern = r"(?:https?://)?(?:www\.)?imagebam\.com/gallery/([0-9a-z]+)"
test = (
("http://www.imagebam.com/gallery/adz2y0f9574bjpmonaismyrhtjgvey4o", {
"url": "fb01925129a1ff1941762eaa3a2783a66de6847f",
"keyword": "9e25b8827474ac93c54855e798d60aa3cbecbd7a",
@@ -43,7 +43,7 @@ class ImagebamGalleryExtractor(ImagebamExtractor):
("http://www.imagebam.com/gallery/gsl8teckymt4vbvx1stjkyk37j70va2c", {
"exception": exception.NotFoundError,
}),
]
)
def __init__(self, match):
ImagebamExtractor.__init__(self)
@@ -87,16 +87,16 @@ class ImagebamImageExtractor(ImagebamExtractor):
subcategory = "image"
filename_fmt = "{image_key}.{extension}"
archive_fmt = "{image_key}"
pattern = [r"(?:https?://)?(?:\w+\.)?imagebam\.com"
r"/(?:image/|(?:[0-9a-f]{2}/){3})([0-9a-f]+)"]
test = [
pattern = (r"(?:https?://)?(?:\w+\.)?imagebam\.com"
r"/(?:image/|(?:[0-9a-f]{2}/){3})([0-9a-f]+)")
test = (
("http://www.imagebam.com/image/94d56c502511890", {
"url": "b384893c35a01a09c58018db71ddc4cf2480be95",
"keyword": "4263d4840007524129792b8587a562b5d20c2687",
"content": "0c8768055e4e20e7c7259608b67799171b691140",
}),
("http://images3.imagebam.com/1d/8c/44/94d56c502511890.png", None),
]
("http://images3.imagebam.com/1d/8c/44/94d56c502511890.png"),
)
def __init__(self, match):
ImagebamExtractor.__init__(self)