1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-25 04:02:32 +01:00
gallery-dl/test/create_test_data.py

39 lines
1019 B
Python
Raw Normal View History

2015-12-22 01:49:25 +01:00
#!/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
2016-07-23 17:50:42 +02:00
from gallery_dl import job, config
2015-12-22 01:49:25 +01:00
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:
2016-07-23 17:50:42 +02:00
hjob = job.HashJob(url, content=args.content)
hjob.run()
print(hjob.extractor.__class__.__name__)
print(TESTDATA_FMT.format(url, hjob.hash_url.hexdigest(),
hjob.hash_keyword.hexdigest(), hjob.hash_content.hexdigest()))
2015-12-22 01:49:25 +01:00
if __name__ == '__main__':
main()