You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gallery-dl/gallery_dl/__init__.py

59 lines
1.5 KiB

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