Moebooru Reference

pybooru.moebooru

This module contains Moebooru class for access to API calls, authentication, build url and return JSON response.

Classes:
Moebooru – Moebooru classs.
class pybooru.moebooru.Moebooru(site_name='', site_url='', username='', password='', hash_string='', api_version='1.13.0+update.3')

Bases: pybooru.pybooru._Pybooru, pybooru.api_moebooru.MoebooruApi_Mixin

Moebooru class (inherits: Pybooru and MoebooruApi_Mixin).

To initialize Pybooru, you need to specify one of these two parameters: ‘site_name’ or ‘site_url’. If you specify ‘site_name’, Pybooru checks whether there is in the list of default sites (You can get list of sites in the ‘resources’ module).

To specify a site that isn’t in list of default sites, you need use ‘site_url’ parameter and specify url.

Some actions may require you to log in. always specify three parameters to log in: ‘hash_string’, ‘username’ and ‘password’. Default sites has an associate hash string.

site_name

Get or set site name set.

Type:str
site_url

Get or set the URL of Moebooru/Danbooru based site.

Type:str
api_version

Version of Moebooru API.

Type:str
username

Return user name.

Type:str
password

Return password in plain text.

Type:str
hash_string

Return hash_string of the site.

Type:str
last_call
Type:dict
__init__(site_name='', site_url='', username='', password='', hash_string='', api_version='1.13.0+update.3')

Initialize Moebooru.

Keyword Arguments:
 
  • site_name (str) – Get or set site name set.
  • site_url (str) – Get or set the URL of Moebooru/Danbooru based site.
  • api_version (str) – Version of Moebooru API.
  • hash_string (str) – String that is hashed (required to login). (See the API documentation of the site for more information).
  • username (str) – Your username of the site (Required only for functions that modify the content).
  • password (str) – Your user password in plain text (Required only for functions that modify the content).
site_name

Get or set site name.

Getter:Return site name.
Setter:Validate and set site name.
Type:string
_build_url(api_call)

Build request url.

Parameters:api_call (str) – Base API Call.
Returns:Complete url (str).
_build_hash_string()

Function for build password hash string.

Raises:
  • PybooruError – When isn’t provide hash string.
  • PybooruError – When aren’t provide username or password.
  • PybooruError – When Pybooru can’t add password to hash strring.
_get(api_call, params, method='GET', file_=None)

Function to preapre API call.

Parameters:
  • api_call (str) – API function to be called.
  • params (dict) – API function parameters.
  • method (str) – (Defauld: GET) HTTP method ‘GET’ or ‘POST’
  • file (file) – File to upload.