1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-25 12:12:34 +01:00
gallery-dl/scripts/build_testresult_db.py
Mike Fährmann 0386503c80
fix (sub)category-transfer for DownloadJob instances (#41)
... and extend "parent" parameters to TestJob- and DataJob-classes
as well.
2017-10-06 15:38:35 +02:00

34 lines
875 B
Python
Executable File

#!/usr/bin/env python
import sys
import os.path
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
tests = [
([url[0] for url in extr.test if url[1]], extr)
for extr in extractor.extractors()
if hasattr(extr, "test")
]
if len(sys.argv) > 1:
tests = [
(urls, extr)
for urls, extr in tests
if extr.category in sys.argv
]
path = os.path.join(ROOTDIR, "archive/testdb", str(datetime.date.today()))
os.makedirs(path, exist_ok=True)
config.load()
for urls, extr in tests:
for i, url in enumerate(urls):
name = "%s-%s-%d.json" % (extr.category, extr.subcategory, i)
print(name)
with open(os.path.join(path, name), "w") as outfile:
job.DataJob(url, file=outfile).run()