# -*- coding: utf-8 -*-12# Copyright 2015-2021 Mike Fährmann3#4# This program is free software; you can redistribute it and/or modify5# it under the terms of the GNU General Public License version 2 as6# published by the Free Software Foundation.78"""Downloader modules"""910modules = [11"http",12"text",13"ytdl",14]151617def find(scheme):18"""Return downloader class suitable for handling the given scheme"""19try:20return _cache[scheme]21except KeyError:22pass2324cls = None25if scheme == "https":26scheme = "http"27if scheme in modules: # prevent unwanted imports28try:29module = __import__(scheme, globals(), None, None, 1)30except ImportError:31pass32else:33cls = module.__downloader__3435if scheme == "http":36_cache["http"] = _cache["https"] = cls37else:38_cache[scheme] = cls39return cls404142# --------------------------------------------------------------------43# internals4445_cache = {}464748