mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-25 12:12:34 +01:00
49 lines
1.3 KiB
Python
Executable File
49 lines
1.3 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# Copyright 2015 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
|
|
# published by the Free Software Foundation.
|
|
|
|
"""Create testdata for extractor tests"""
|
|
|
|
import argparse
|
|
from gallery_dl import job, config, extractor
|
|
|
|
TESTDATA_FMT = """
|
|
test = [("{}", {{
|
|
"url": "{}",
|
|
"keyword": "{}",
|
|
"content": "{}",
|
|
}})]
|
|
"""
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("--content", action="store_true")
|
|
parser.add_argument("--recreate", action="store_true")
|
|
parser.add_argument("urls", nargs="*")
|
|
args = parser.parse_args()
|
|
|
|
if args.recreate:
|
|
urls = [
|
|
test[0]
|
|
for extr in extractor.extractors() if extr.category in args.urls
|
|
for test in extr.test
|
|
]
|
|
else:
|
|
urls = args.urls
|
|
|
|
config.load()
|
|
for url in urls:
|
|
tjob = job.TestJob(url, content=args.content)
|
|
tjob.run()
|
|
print(tjob.extractor.__class__.__name__)
|
|
print(TESTDATA_FMT.format(url, tjob.hash_url.hexdigest(),
|
|
tjob.hash_keyword.hexdigest(), tjob.hash_content.hexdigest()))
|
|
|
|
if __name__ == '__main__':
|
|
main()
|