[danbooru] add authentication support (closes #151)

... via HTTP Basic Auth with username and "password".

The password value in this case is not the account password itself,
but the"api_key" found in your user profile.
This commit is contained in:
Mike Fährmann
2019-01-09 14:08:06 +01:00
parent 06cbf5f9c4
commit 1e4d351ad3
3 changed files with 20 additions and 2 deletions

View File

@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright 2014-2018 Mike Fährmann
# Copyright 2014-2019 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
@@ -29,6 +29,11 @@ class DanbooruExtractor(booru.DanbooruPageMixin, booru.BooruExtractor):
self.api_url = "{scheme}://{subdomain}.donmai.us/posts.json".format(
scheme=self.scheme, subdomain=self.subdomain)
username, api_key = self._get_auth_info()
if username:
self.log.debug("Using HTTP Basic Auth for user '%s'", username)
self.session.auth = (username, api_key)
class DanbooruTagExtractor(booru.TagMixin, DanbooruExtractor):
"""Extractor for images from danbooru based on search-tags"""