def getInstanceBySetting(setting): if setting.type == "sabnzbd": return Sabnzbd(setting) if setting.type == "nzbget": return Nzbget(setting) raise DownloaderNotFoundException("No downloader with type %s found" % setting.type)
def getDownloaderInstanceByName(name): for i in config.settings.downloaders: if i.name == name: return getInstanceBySetting(i) raise DownloaderNotFoundException("No downloader with name %s found" % name)