1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-22 02:32:33 +01:00

script to easily create testdata

This commit is contained in:
Mike Fährmann 2015-12-22 01:49:25 +01:00
parent 565ea042c9
commit 2b8977cb2e
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

37
test/create_test_data.py Normal file
View File

@ -0,0 +1,37 @@
#!/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 jobs, config
TESTDATA_FMT = """
test = [("{}", {{
"url": "{}",
"keyword": "{}",
"content": "{}",
}})]
"""
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--content", action="store_true")
parser.add_argument("urls", nargs="*")
args = parser.parse_args()
config.load()
for url in args.urls:
job = jobs.HashJob(url, content=args.content)
job.run()
print(TESTDATA_FMT.format(url, job.hash_url.hexdigest(),
job.hash_keyword.hexdigest(), job.hash_content.hexdigest()))
if __name__ == '__main__':
main()