1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-22 10:42:34 +01:00

update __init__.py

This commit is contained in:
Mike Fährmann 2015-04-05 17:15:27 +02:00
parent 7c12ba1c31
commit 63bf0d1725

View File

@ -1,8 +1,16 @@
__author__ = "Mike Fährmann" # -*- coding: utf-8 -*-
__copyright__ = "Copyright 2014, Mike Fährmann"
__license__ = "GPLv3" # Copyright 2014, 2015 Mike Fährmann
__version__ = "0.4" #
# 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.
__author__ = "Mike Fährmann"
__copyright__ = "Copyright 2014, 2015 Mike Fährmann"
__license__ = "GPLv2"
__version__ = "0.2"
__maintainer__ = "Mike Fährmann" __maintainer__ = "Mike Fährmann"
__email__ = "mike_faehrmann@web.de" __email__ = "mike_faehrmann@web.de"
@ -11,34 +19,40 @@ import sys
import argparse import argparse
import configparser import configparser
from . import extractor from download import DownloadManager
from . import downloader
def parse_cmdline_options(): def parse_cmdline_options():
p = argparse.ArgumentParser( parser = argparse.ArgumentParser(
description='Download images from various sources') description='Download images from various sources')
p.add_argument("-c", "--config", parser.add_argument(
default="~/.config/gallery/config", metavar="CFG", help="alternate configuration file") "-c", "--config",
p.add_argument("-d", "--dest", default="~/.config/gallery/config", metavar="CFG",
metavar="DEST", help="destination directory") help="alternate configuration file"
p.add_argument("urls", nargs="+", )
metavar="URL", help="url to download images from") parser.add_argument(
return p.parse_args() "-d", "--dest",
metavar="DEST",
help="destination directory"
)
parser.add_argument(
"urls",
nargs="+", metavar="URL",
help="url to download images from"
)
return parser.parse_args()
def parse_config_file(path): def parse_config_file(path):
config = configparser.ConfigParser( config = configparser.ConfigParser(
interpolation=None, interpolation=None,
) )
config.optionxform = lambda opt:opt config.optionxform = lambda opt: opt
config.read(os.path.expanduser(path)) config.read(os.path.expanduser(path))
return config return config
def main(): def main():
opts = parse_cmdline_options() opts = parse_cmdline_options()
conf = parse_config_file(opts.config) conf = parse_config_file(opts.config)
extf = extractor.ExtractorFinder(conf) dlmgr = DownloadManager(opts, conf)
dlmg = downloader.DownloadManager(opts, conf)
for url in opts.urls: for url in opts.urls:
ex = extf.match(url) dlmgr.add(url)
dlmg.add(ex)