update handling of extractor URL patterns

When loading extractor classes during 'extractor.find(…)', their
'pattern' attribute will be replaced with a compiled version of itself.
This commit is contained in:
Mike Fährmann
2019-02-08 20:08:16 +01:00
parent 6284731107
commit abbd45d0f4
6 changed files with 43 additions and 41 deletions

View File

@@ -211,13 +211,15 @@ def get_domain(classes):
if hasattr(cls, "root") and cls.root:
return cls.root + "/"
if hasattr(cls, "test") and cls.test:
url = cls.test[0][0]
return url[:url.find("/", 8)+1]
if hasattr(cls, "https"):
scheme = "https" if cls.https else "http"
domain = cls.__doc__.split()[-1]
return "{}://{}/".format(scheme, domain)
scheme = "http" if hasattr(cls, "https") and not cls.https else "https"
host = cls.__doc__.split()[-1]
return scheme + "://" + host + "/"
test = next(cls._get_tests(), None)
if test:
url = test[0]
return url[:url.find("/", 8)+1]
except (IndexError, AttributeError):
pass
return ""

View File

@@ -6,6 +6,7 @@ import datetime
ROOTDIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, os.path.realpath(ROOTDIR))
from gallery_dl import extractor, job, config
from test.test_results import setup_test_config
@@ -19,7 +20,7 @@ tests = [
if hasattr(extr, "test") and extr.test
if len(sys.argv) <= 1 or extr.category in sys.argv
for idx, (url, result) in enumerate(extr.test)
for idx, (url, result) in enumerate(extr._get_tests())
if result
]